summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/core/bpf/meson.build22
1 files changed, 20 insertions, 2 deletions
diff --git a/src/core/bpf/meson.build b/src/core/bpf/meson.build
index cd0cd3230b..c2465a845f 100644
--- a/src/core/bpf/meson.build
+++ b/src/core/bpf/meson.build
@@ -13,7 +13,25 @@ clang_flags = [
'-c',
]
-clang_arch_flag = '-D__@0@__'.format(host_machine.cpu_family())
+# Generate defines that are appropriate to tell the compiler what architecture
+# we're compiling for. By default we just map meson's cpu_family to __<cpu_family>__.
+# This dictionary contains the exceptions where this doesn't work.
+#
+# C.f. https://mesonbuild.com/Reference-tables.html#cpu-families
+# and src/basic/missing_syscall_def.h.
+cpu_arch_defines = {
+ 'ppc' : ['-D__powerpc__'],
+ 'ppc64' : ['-D__powerpc64__', '-D_CALL_ELF=2'],
+ 'riscv32' : ['-D__riscv', '-D__riscv_xlen=32'],
+ 'riscv64' : ['-D__riscv', '-D__riscv_xlen=64'],
+ 'x86' : ['-D__i386__'],
+
+ # For arm, assume hardware fp is available.
+ 'arm' : ['-D__arm__', '-D__ARM_PCS_VFP'],
+}
+
+clang_arch_flags = cpu_arch_defines.get(host_machine.cpu_family(),
+ ['-D__@0@__'.format(host_machine.cpu_family())])
if meson.version().version_compare('>= 0.58')
libbpf_include_dir = libbpf.get_variable('includedir')
@@ -24,7 +42,7 @@ endif
bpf_o_unstripped_cmd = [
clang,
clang_flags,
- clang_arch_flag,
+ clang_arch_flags,
'-I.'
]