diff options
author | James Hilliard <james.hilliard1@gmail.com> | 2022-06-08 10:13:42 +0000 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2022-06-10 14:01:19 +0200 |
commit | 76abad4d4794ef9990afc7f4af1e7737984ec729 (patch) | |
tree | 22f629c0d5ad5cc97d211e11c9150478f1ae81ee /src/core | |
parent | 02bf03405ba513672daf4c8419b888228bda7396 (diff) | |
download | systemd-76abad4d4794ef9990afc7f4af1e7737984ec729.tar.gz |
meson: add experimental bpf-gcc compiler support
Not fully working but should make it easier to clean up remaining
issues.
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/bpf/meson.build | 43 |
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', |