summaryrefslogtreecommitdiff
path: root/src/core/bpf/meson.build
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/bpf/meson.build')
-rw-r--r--src/core/bpf/meson.build43
1 files changed, 32 insertions, 11 deletions
diff --git a/src/core/bpf/meson.build b/src/core/bpf/meson.build
index c88e457716..c2f9b5ac42 100644
--- a/src/core/bpf/meson.build
+++ b/src/core/bpf/meson.build
@@ -4,7 +4,7 @@ if conf.get('BPF_FRAMEWORK') != 1
subdir_done()
endif
-clang_flags = [
+bpf_clang_flags = [
'-Wno-compare-distinct-pointer-types',
'-O2',
'-target',
@@ -13,6 +13,14 @@ clang_flags = [
'-c',
]
+bpf_gcc_flags = [
+ '-O2',
+ '-mkernel=5.2',
+ '-mcpu=v3',
+ '-mco-re',
+ '-gbtf',
+]
+
# 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.
@@ -30,19 +38,32 @@ cpu_arch_defines = {
'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())])
+bpf_arch_flags = cpu_arch_defines.get(host_machine.cpu_family(),
+ ['-D__@0@__'.format(host_machine.cpu_family())])
+if bpf_compiler == 'gcc'
+ bpf_arch_flags += ['-m' + host_machine.endian() + '-endian']
+endif
libbpf_include_dir = libbpf.get_variable(pkgconfig : 'includedir')
-bpf_o_unstripped_cmd = [
- clang,
- clang_flags,
- clang_arch_flags,
- '-I.'
-]
+bpf_o_unstripped_cmd = []
+if bpf_compiler == 'clang'
+ bpf_o_unstripped_cmd += [
+ clang,
+ bpf_clang_flags,
+ bpf_arch_flags,
+ ]
+elif bpf_compiler == 'gcc'
+ bpf_o_unstripped_cmd += [
+ bpf_gcc,
+ bpf_gcc_flags,
+ bpf_arch_flags,
+ ]
+endif
+
+bpf_o_unstripped_cmd += ['-I.']
-if not meson.is_cross_build()
+if not meson.is_cross_build() and bpf_compiler == 'clang'
target_triplet_cmd = run_command('gcc', '-dumpmachine', check: false)
if target_triplet_cmd.returncode() == 0
target_triplet = target_triplet_cmd.stdout().strip()
@@ -69,7 +90,7 @@ if bpftool_strip
'@OUTPUT@',
'@INPUT@'
]
-else
+elif bpf_compiler == 'clang'
bpf_o_cmd = [
llvm_strip,
'-g',