public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r12-3390] bpf: Add new -mco-re option for BPF CO-RE
@ 2021-09-07 18:21 Indu Bhagat
0 siblings, 0 replies; only message in thread
From: Indu Bhagat @ 2021-09-07 18:21 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:e29a9607faae320a92f19b38f0424037ac3bdbfe
commit r12-3390-ge29a9607faae320a92f19b38f0424037ac3bdbfe
Author: Indu Bhagat <indu.bhagat@oracle.com>
Date: Tue Sep 7 11:17:55 2021 -0700
bpf: Add new -mco-re option for BPF CO-RE
-mco-re in the BPF backend enables code generation for the CO-RE usecase. LTO is
disabled for CO-RE compilations.
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 -mco-re.
gcc/testsuite/ChangeLog:
* gcc.target/bpf/core-lto-1.c: New test.
Diff:
---
gcc/config/bpf/bpf.c | 25 +++++++++++++++++++++++++
gcc/config/bpf/bpf.opt | 4 ++++
gcc/testsuite/gcc.target/bpf/core-lto-1.c | 9 +++++++++
3 files changed, 38 insertions(+)
diff --git a/gcc/config/bpf/bpf.c b/gcc/config/bpf/bpf.c
index e635f9edb40..7228978a3a9 100644
--- a/gcc/config/bpf/bpf.c
+++ b/gcc/config/bpf/bpf.c
@@ -54,6 +54,7 @@ along with GCC; see the file COPYING3. If not see
#include "builtins.h"
#include "predict.h"
#include "langhooks.h"
+#include "flags.h"
/* Per-function machine data. */
struct GTY(()) machine_function
@@ -158,6 +159,30 @@ bpf_option_override (void)
{
/* Set the initializer for the per-function status structure. */
init_machine_status = bpf_init_machine_status;
+
+ /* BPF CO-RE support requires BTF debug info generation. */
+ if (TARGET_BPF_CORE && !btf_debuginfo_p ())
+ error ("BPF CO-RE requires BTF debugging information, use %<-gbtf%>");
+
+ /* To support the portability needs of BPF CO-RE approach, BTF debug
+ information includes the BPF CO-RE relocations. */
+ if (TARGET_BPF_CORE)
+ write_symbols |= BTF_WITH_CORE_DEBUG;
+
+ /* Unlike much of the other BTF debug information, the information necessary
+ for CO-RE relocations is added to the CTF container by the BPF backend.
+ Enabling LTO adds some complications in the generation of the BPF CO-RE
+ relocations because if LTO is in effect, the relocations need to be
+ generated late in the LTO link phase. This poses a new challenge for the
+ compiler to now provide means to combine the early BTF and late BTF CO-RE
+ debug info, similar to DWARF debug info. BTF/CO-RE debug info is not
+ amenable to such a split generation and a later merging.
+
+ 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)
+ sorry ("BPF CO-RE does not support LTO");
}
#undef TARGET_OPTION_OVERRIDE
diff --git a/gcc/config/bpf/bpf.opt b/gcc/config/bpf/bpf.opt
index 916b53c15ea..4493067b987 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.
+
+mco-re
+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 00000000000..927de23671b
--- /dev/null
+++ b/gcc/testsuite/gcc.target/bpf/core-lto-1.c
@@ -0,0 +1,9 @@
+/* Test -mco-re with -flto.
+
+ -mco-re 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 -mco-re. */
+
+/* { dg-do compile } */
+/* { dg-message "sorry, unimplemented: BPF CO-RE does not support LTO" "" { target bpf-*-* } 0 } */
+/* { dg-options "-gbtf -mco-re -flto" } */
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2021-09-07 18:21 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-07 18:21 [gcc r12-3390] bpf: Add new -mco-re option for BPF CO-RE Indu Bhagat
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).