From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ed1-x531.google.com (mail-ed1-x531.google.com [IPv6:2a00:1450:4864:20::531]) by sourceware.org (Postfix) with ESMTPS id 747063858415 for ; Thu, 26 Aug 2021 10:06:06 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 747063858415 Received: by mail-ed1-x531.google.com with SMTP id i6so3849745edu.1 for ; Thu, 26 Aug 2021 03:06:06 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=xWP/VT1idS/UkjnuJ8RAMkfiA0OE7R8bFQ6+eh5ULP8=; b=sDjIBgVmLZPGwNmeSBeXF8TqViXAwmpyPTo+yMP1claIe4mdo20O2S/jqycGuhC5tm NzhqkeHS4ow/an1H0NqE+RRZs7k2B2q4Q+oULGvwxX8ZmpQdhTy87jFDdvLaROrgmYKF s71EBdt68QCQwXf5LbeZLYI0SnBhtwzTh5neS13FltEpZFwMG9YP4Mz7UB9g8Vf8okr/ MlN/4mLQ26QaEpH2XAtNxC1JJb38WssgwWHJhnr6whQwXfS5gYQtaTSRwj3kH2aFrqQM YLwA/0xCXUtCnXfONnSwn2JjxNeWZhGUrOpuE3495gvj3D9f1SMlPdUnr2pu0+7mk4lK TcTg== X-Gm-Message-State: AOAM53281Il1E2pmOGN4ahIzSDyCBKh1fMVQumdgHJi9/nnF8VTQGEu+ CM2A1Cr437YpDeLJwb+eDn8m4IGULXMNjQf+Qjlf3wnz X-Google-Smtp-Source: ABdhPJx/5XKX/woBbswxiX7cvtIPFlHlgrT/lqQRhsYic42ZF6bUDMOBvP6VMsGkiWwppGmut640JSyLx2Fz3BD2Q7A= X-Received: by 2002:a50:d749:: with SMTP id i9mr3435799edj.248.1629972365435; Thu, 26 Aug 2021 03:06:05 -0700 (PDT) MIME-Version: 1.0 References: <1628124628-28706-1-git-send-email-indu.bhagat@oracle.com> <1628124628-28706-2-git-send-email-indu.bhagat@oracle.com> <87sfzhnw1i.fsf@oracle.com> In-Reply-To: <87sfzhnw1i.fsf@oracle.com> From: Richard Biener Date: Thu, 26 Aug 2021 12:05:54 +0200 Message-ID: Subject: Re: [PATCH,V2 1/3] bpf: Add new -mcore option for BPF CO-RE To: "Jose E. Marchesi" Cc: Richard Biener via Gcc-patches , Indu Bhagat Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-8.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 26 Aug 2021 10:06:17 -0000 On Tue, Aug 10, 2021 at 5:45 PM Jose E. Marchesi wrote: > > > > On Thu, Aug 5, 2021 at 2:54 AM Indu Bhagat via Gcc-patches > > 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. So in other context I wonder if CO-RE is really target specific, it's a flavor of the BTF debug format, so shouldn't it be -gbtf-core or sth like that? Richard. > >> } > >> > >> #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 > >>