From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ed1-x534.google.com (mail-ed1-x534.google.com [IPv6:2a00:1450:4864:20::534]) by sourceware.org (Postfix) with ESMTPS id 813953959E4B for ; Tue, 10 Aug 2021 11:51:44 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 813953959E4B Received: by mail-ed1-x534.google.com with SMTP id i6so29829659edu.1 for ; Tue, 10 Aug 2021 04:51:44 -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=8zxedButycx1A3KxXVwdpwKry6EIOtX33pWxeaxI0Pk=; b=H4pbEfZNsHnkXEDimO3hqur2/CbmW+uDj+s8JtljlovmEmuY03h2b2y/3hBEppJziL ukJJPpRUmHhqcGdcq+arC5pj2I9o0x/lcRC131W+MCPmZvMgAcFPpYRjxTYDtpyfVhT5 PxnfxxMgCxv/VXWEaLAVpezvYAxshmI84ZiHmMPZkB5jJZSq1AJcwwd78+JERljWs4WN 9vQVZ09Cc3pXxaTR0wXrssC7IyorTnN+wJtCfXWYFUwx7togZfOZkASGdgfcN8aDhN9y GR1W5nC1Rqz9wsCfDoTBC/AW16YbTBVMHd1luADsoVS5kBlrMR63u2IJ9AdsT7bM5khU g1cA== X-Gm-Message-State: AOAM532wtEIpKMpUtzBLcUKx+1jn8LSqH2U9/wtOrs+X+YbApZB5HUWy wEJqrBgR/HfNquo7rH7pr6s/pjDIsIYptbslOKM= X-Google-Smtp-Source: ABdhPJzFU1UtaqNsqdKM8FwBNgSzieyxILo2u43zOv7TtEWfuoHYSX+2kFbzk7Jrv7WTYT2zTD80KhnSM3bmJKcobvI= X-Received: by 2002:a05:6402:1603:: with SMTP id f3mr4444520edv.274.1628596303540; Tue, 10 Aug 2021 04:51:43 -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> In-Reply-To: <1628124628-28706-2-git-send-email-indu.bhagat@oracle.com> From: Richard Biener Date: Tue, 10 Aug 2021 13:51:32 +0200 Message-ID: Subject: Re: [PATCH,V2 1/3] bpf: Add new -mcore option for BPF CO-RE To: Indu Bhagat Cc: GCC Patches Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-9.0 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: Tue, 10 Aug 2021 11:51:55 -0000 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. 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 >