[COMMITTED] bpf: remove -mkernel option and BPF_KERNEL_VERSION_CODE

Message ID 20230724095712.14497-1-jose.marchesi@oracle.com
State Accepted
Headers
Series [COMMITTED] bpf: remove -mkernel option and BPF_KERNEL_VERSION_CODE |

Checks

Context Check Description
snail/gcc-patch-check success Github commit url

Commit Message

Jose E. Marchesi July 24, 2023, 9:57 a.m. UTC
  Having the ability of specifying a target kernel version when building
a BPF program is one of these things that sound pretty good in theory,
but simply don't work in practice: kernels in practice contain
backports, etc.  Also, the addition of CO-RE to BPF has made this
uneccessary.

This patch removes the -mkernel command line option and also the
associated BPF_KERNEL_VERSION_CODE pre-processor constant.

Tested in bpf-unknown-none.

gcc/ChangeLog

	* config/bpf/bpf-opts.h (enum bpf_kernel_version): Remove enum.
	* config/bpf/bpf.opt (mkernel): Remove option.
	* config/bpf/bpf.cc (bpf_target_macros): Do not define
	BPF_KERNEL_VERSION_CODE.
---
 gcc/config/bpf/bpf-opts.h | 33 ---------------
 gcc/config/bpf/bpf.cc     | 40 ------------------
 gcc/config/bpf/bpf.opt    | 87 ---------------------------------------
 3 files changed, 160 deletions(-)
  

Patch

diff --git a/gcc/config/bpf/bpf-opts.h b/gcc/config/bpf/bpf-opts.h
index e0be591b479..5c9441ccb28 100644
--- a/gcc/config/bpf/bpf-opts.h
+++ b/gcc/config/bpf/bpf-opts.h
@@ -20,39 +20,6 @@ 
 #ifndef BPF_OPTS_H
 #define BPF_OPTS_H
 
-/* Supported versions of the Linux kernel.  */
-enum bpf_kernel_version
-{
-  /* Linux 4.x */
-  LINUX_V4_0,
-  LINUX_V4_1,
-  LINUX_V4_2,
-  LINUX_V4_3,
-  LINUX_V4_4,
-  LINUX_V4_5,
-  LINUX_V4_6,
-  LINUX_V4_7,
-  LINUX_V4_8,
-  LINUX_V4_9,
-  LINUX_V4_10,
-  LINUX_V4_11,
-  LINUX_V4_12,
-  LINUX_V4_13,
-  LINUX_V4_14,
-  LINUX_V4_15,
-  LINUX_V4_16,
-  LINUX_V4_17,
-  LINUX_V4_18,
-  LINUX_V4_19,
-  LINUX_V4_20,
-  /* Linux 5.x  */
-  LINUX_V5_0,
-  LINUX_V5_1,
-  LINUX_V5_2,
-  LINUX_LATEST = LINUX_V5_2,
-  LINUX_NATIVE,
-};
-
 enum bpf_isa_version
 {
   ISA_V1,
diff --git a/gcc/config/bpf/bpf.cc b/gcc/config/bpf/bpf.cc
index 6bc715429dc..18d3b5f14d6 100644
--- a/gcc/config/bpf/bpf.cc
+++ b/gcc/config/bpf/bpf.cc
@@ -308,46 +308,6 @@  bpf_target_macros (cpp_reader *pfile)
     builtin_define ("__BPF_BIG_ENDIAN__");
   else
     builtin_define ("__BPF_LITTLE_ENDIAN__");
-
-  /* Define BPF_KERNEL_VERSION_CODE */
-  {
-    const char *version_code;
-    char *kernel_version_code;
-
-    switch (bpf_kernel)
-      {
-      case LINUX_V4_0: version_code = "0x40000"; break;
-      case LINUX_V4_1: version_code = "0x40100"; break;
-      case LINUX_V4_2: version_code = "0x40200"; break;
-      case LINUX_V4_3: version_code = "0x40300"; break;
-      case LINUX_V4_4: version_code = "0x40400"; break;
-      case LINUX_V4_5: version_code = "0x40500"; break;
-      case LINUX_V4_6: version_code = "0x40600"; break;
-      case LINUX_V4_7: version_code = "0x40700"; break;
-      case LINUX_V4_8: version_code = "0x40800"; break;
-      case LINUX_V4_9: version_code = "0x40900"; break;
-      case LINUX_V4_10: version_code = "0x40a00"; break;
-      case LINUX_V4_11: version_code = "0x40b00"; break;
-      case LINUX_V4_12: version_code = "0x40c00"; break;
-      case LINUX_V4_13: version_code = "0x40d00"; break;
-      case LINUX_V4_14: version_code = "0x40e00"; break;
-      case LINUX_V4_15: version_code = "0x40f00"; break;
-      case LINUX_V4_16: version_code = "0x41000"; break;
-      case LINUX_V4_17: version_code = "0x42000"; break;
-      case LINUX_V4_18: version_code = "0x43000"; break;
-      case LINUX_V4_19: version_code = "0x44000"; break;
-      case LINUX_V4_20: version_code = "0x45000"; break;
-      case LINUX_V5_0: version_code = "0x50000"; break;
-      case LINUX_V5_1: version_code = "0x50100"; break;
-      case LINUX_V5_2: version_code = "0x50200"; break;
-      default:
-	gcc_unreachable ();
-      }
-
-    kernel_version_code = ACONCAT (("__BPF_KERNEL_VERSION_CODE__=",
-				    version_code, NULL));
-    builtin_define (kernel_version_code);
-  }
 }
 
 /* Return an RTX representing the place where a function returns or
diff --git a/gcc/config/bpf/bpf.opt b/gcc/config/bpf/bpf.opt
index 1e4dcc871d7..3bf9033279b 100644
--- a/gcc/config/bpf/bpf.opt
+++ b/gcc/config/bpf/bpf.opt
@@ -21,93 +21,6 @@ 
 HeaderInclude
 config/bpf/bpf-opts.h
 
-; Selecting the kind of kernel the eBPF will be running on.
-
-mkernel=
-Target RejectNegative Joined Var(bpf_kernel) Enum(bpf_kernel) Init(LINUX_LATEST)
-Generate eBPF for the given Linux kernel version.
-
-Enum
-Name(bpf_kernel) Type(enum bpf_kernel_version)
-
-EnumValue
-Enum(bpf_kernel) String(native) Value(LINUX_NATIVE) DriverOnly
-
-EnumValue
-Enum(bpf_kernel) String(latest) Value(LINUX_LATEST) DriverOnly
-
-EnumValue
-Enum(bpf_kernel) String(4.0) Value(LINUX_V4_0)
-
-EnumValue
-Enum(bpf_kernel) String(4.1) Value(LINUX_V4_1)
-
-EnumValue
-Enum(bpf_kernel) String(4.2) Value(LINUX_V4_2)
-
-EnumValue
-Enum(bpf_kernel) String(4.3) Value(LINUX_V4_3)
-
-EnumValue
-Enum(bpf_kernel) String(4.4) Value(LINUX_V4_4)
-
-EnumValue
-Enum(bpf_kernel) String(4.5) Value(LINUX_V4_5)
-
-EnumValue
-Enum(bpf_kernel) String(4.6) Value(LINUX_V4_6)
-
-EnumValue
-Enum(bpf_kernel) String(4.7) Value(LINUX_V4_7)
-
-EnumValue
-Enum(bpf_kernel) String(4.8) Value(LINUX_V4_8)
-
-EnumValue
-Enum(bpf_kernel) String(4.9) Value(LINUX_V4_9)
-
-EnumValue
-Enum(bpf_kernel) String(4.10) Value(LINUX_V4_10)
-
-EnumValue
-Enum(bpf_kernel) String(4.11) Value(LINUX_V4_11)
-
-EnumValue
-Enum(bpf_kernel) String(4.12) Value(LINUX_V4_12)
-
-EnumValue
-Enum(bpf_kernel) String(4.13) Value(LINUX_V4_13)
-
-EnumValue
-Enum(bpf_kernel) String(4.14) Value(LINUX_V4_14)
-
-EnumValue
-Enum(bpf_kernel) String(4.15) Value(LINUX_V4_15)
-
-EnumValue
-Enum(bpf_kernel) String(4.16) Value(LINUX_V4_16)
-
-EnumValue
-Enum(bpf_kernel) String(4.17) Value(LINUX_V4_17)
-
-EnumValue
-Enum(bpf_kernel) String(4.18) Value(LINUX_V4_18)
-
-EnumValue
-Enum(bpf_kernel) String(4.19) Value(LINUX_V4_19)
-
-EnumValue
-Enum(bpf_kernel) String(4.20) Value(LINUX_V4_20)
-
-EnumValue
-Enum(bpf_kernel) String(5.0) Value(LINUX_V5_0)
-
-EnumValue
-Enum(bpf_kernel) String(5.1) Value(LINUX_V5_1)
-
-EnumValue
-Enum(bpf_kernel) String(5.2) Value(LINUX_V5_2)
-
 ; Use xBPF extensions.
 
 mxbpf