public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: "Jose E. Marchesi" <jose.marchesi@oracle.com>
To: Richard Biener via Gcc-patches <gcc-patches@gcc.gnu.org>
Cc: Indu Bhagat <indu.bhagat@oracle.com>,
	Richard Biener <richard.guenther@gmail.com>
Subject: Re: [PATCH,V2 1/3] bpf: Add new -mcore option for BPF CO-RE
Date: Tue, 10 Aug 2021 17:45:13 +0200	[thread overview]
Message-ID: <87sfzhnw1i.fsf@oracle.com> (raw)
In-Reply-To: <CAFiYyc3-oTk+c8FtKQkKWWZwLGrQgOTvsbHeKME9apE4uPQCdQ@mail.gmail.com> (Richard Biener via Gcc-patches's message of "Tue, 10 Aug 2021 13:51:32 +0200")


> On Thu, Aug 5, 2021 at 2:54 AM Indu Bhagat via Gcc-patches
> <gcc-patches@gcc.gnu.org> wrote:
>>
>> -mcore in the BPF backend enables code generation for the CO-RE usecase. LTO is
>> disabled for CO-RE compilations.
>
> -mcore reads like "core", why not -mco-re?  Anyway, ...
>
>> gcc/ChangeLog:
>>
>>         * config/bpf/bpf.c (bpf_option_override): For BPF backend, disable LTO
>>         support when compiling for CO-RE.
>>         * config/bpf/bpf.opt: Add new command line option -mcore.
>>
>> gcc/testsuite/ChangeLog:
>>
>>         * gcc.target/bpf/core-lto-1.c: New test.
>> ---
>>  gcc/config/bpf/bpf.c                      | 15 +++++++++++++++
>>  gcc/config/bpf/bpf.opt                    |  4 ++++
>>  gcc/testsuite/gcc.target/bpf/core-lto-1.c |  9 +++++++++
>>  3 files changed, 28 insertions(+)
>>  create mode 100644 gcc/testsuite/gcc.target/bpf/core-lto-1.c
>>
>> diff --git a/gcc/config/bpf/bpf.c b/gcc/config/bpf/bpf.c
>> index e635f9e..028013e 100644
>> --- a/gcc/config/bpf/bpf.c
>> +++ b/gcc/config/bpf/bpf.c
>> @@ -158,6 +158,21 @@ bpf_option_override (void)
>>  {
>>    /* Set the initializer for the per-function status structure.  */
>>    init_machine_status = bpf_init_machine_status;
>> +
>> +  /* To support the portability needs of BPF CO-RE approach, BTF debug
>> +     information includes the BPF CO-RE relocations.  The information
>> +     necessary for these relocations is added to the CTF container by the
>> +     BPF backend.  Enabling LTO poses challenges in the generation of the BPF
>> +     CO-RE relocations because if LTO is in effect, they need to be
>> +     generated late in the LTO link phase.  This in turn means the compiler
>> +     needs to provide means to combine the early and late BTF debug info,
>> +     similar to DWARF debug info.
>> +
>> +     In any case, in absence of linker support for BTF sections at this time,
>> +     it is acceptable to simply disallow LTO for BPF CO-RE compilations.  */
>> +
>> +  if (flag_lto && TARGET_BPF_CORE)
>> +    error ("BPF CO-RE does not support LTO");
>
> ... these "errors" should use sorry ("...") which annotate places where the
> compiler has to give up because sth is not implemented.
>
> otherwise this patch needs BPF maintainer review of course.

I agree -mco-re is more clear than -mcore.

Other than that this looks OK BPF-wise.

>>  }
>>
>>  #undef TARGET_OPTION_OVERRIDE
>> diff --git a/gcc/config/bpf/bpf.opt b/gcc/config/bpf/bpf.opt
>> index 916b53c..e8926f5 100644
>> --- a/gcc/config/bpf/bpf.opt
>> +++ b/gcc/config/bpf/bpf.opt
>> @@ -127,3 +127,7 @@ Generate little-endian eBPF.
>>  mframe-limit=
>>  Target Joined RejectNegative UInteger IntegerRange(0, 32767) Var(bpf_frame_limit) Init(512)
>>  Set a hard limit for the size of each stack frame, in bytes.
>> +
>> +mcore
>> +Target Mask(BPF_CORE)
>> +Generate all necessary information for BPF Compile Once - Run Everywhere.
>> diff --git a/gcc/testsuite/gcc.target/bpf/core-lto-1.c
>> b/gcc/testsuite/gcc.target/bpf/core-lto-1.c
>> new file mode 100644
>> index 0000000..a90dc5b
>> --- /dev/null
>> +++ b/gcc/testsuite/gcc.target/bpf/core-lto-1.c
>> @@ -0,0 +1,9 @@
>> +/* Test -mcore with -flto.
>> +
>> +   -mcore is used to generate information for BPF CO-RE usecase. To support
>> +   the generataion of the .BTF and .BTF.ext sections in GCC, -flto is disabled
>> +   with -mcore.  */
>> +
>> +/* { dg-do compile } */
>> +/* { dg-error "BPF CO-RE does not support LTO" "" { target bpf-*-* } 0 } */
>> +/* { dg-options "-gbtf -mcore -flto" } */
>> --
>> 1.8.3.1
>>

  reply	other threads:[~2021-08-10 15:45 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-05  0:50 [PATCH,V2 0/3] Allow means for late BTF generation " Indu Bhagat
2021-08-05  0:50 ` [PATCH,V2 1/3] bpf: Add new -mcore option " Indu Bhagat
2021-08-10 11:51   ` Richard Biener
2021-08-10 15:45     ` Jose E. Marchesi [this message]
2021-08-26 10:05       ` Richard Biener
2021-08-26 13:27         ` Jose E. Marchesi
2021-08-05  0:50 ` [PATCH, V2 2/3] targhooks: New target hook for CTF/BTF debug info emission Indu Bhagat
2021-08-10 11:54   ` Richard Biener
2021-08-16 17:39     ` Indu Bhagat
2021-08-17  8:04       ` Richard Biener
2021-08-17 17:26         ` Indu Bhagat
2021-08-18  7:00           ` Richard Biener
2021-08-18 14:20             ` Indu Bhagat
2021-08-19 14:41             ` Jose E. Marchesi
2021-08-19 15:10             ` Jose E. Marchesi
2021-08-24 17:06             ` Indu Bhagat
2021-08-26 10:03               ` Richard Biener
2021-08-26 18:55                 ` Indu Bhagat
2021-08-27  6:12                   ` Richard Biener
2021-09-02 19:21                     ` Indu Bhagat
2021-08-05  0:50 ` [PATCH, V2 3/3] dwarf2out: Emit BTF in dwarf2out_finish for BPF CO-RE usecase Indu Bhagat
2021-08-10 12:00   ` Richard Biener
2021-08-10 16:39     ` David Faust

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87sfzhnw1i.fsf@oracle.com \
    --to=jose.marchesi@oracle.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=indu.bhagat@oracle.com \
    --cc=richard.guenther@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).