mirror of
https://github.com/systemd/systemd.git
synced 2025-04-01 18:50:16 +03:00
meson: move bpf hookup into main meson build file
This way we can use it in systemd-userdbd later on, too.
This commit is contained in:
parent
33054db730
commit
4d3ef2d1a2
112
meson.build
112
meson.build
@ -1966,6 +1966,118 @@ pymod = import('python')
|
||||
python = pymod.find_installation('python3', required : true, modules : ['jinja2'])
|
||||
python_39 = python.language_version().version_compare('>=3.9')
|
||||
|
||||
############################################################
|
||||
|
||||
if conf.get('BPF_FRAMEWORK') == 1
|
||||
bpf_clang_flags = [
|
||||
'-std=gnu11',
|
||||
'-Wno-compare-distinct-pointer-types',
|
||||
'-fno-stack-protector',
|
||||
'-O2',
|
||||
'-target',
|
||||
'bpf',
|
||||
'-g',
|
||||
'-c',
|
||||
]
|
||||
|
||||
bpf_gcc_flags = [
|
||||
'-std=gnu11',
|
||||
'-fno-stack-protector',
|
||||
'-O2',
|
||||
'-mkernel=5.2',
|
||||
'-mcpu=v3',
|
||||
'-mco-re',
|
||||
'-gbtf',
|
||||
'-c',
|
||||
]
|
||||
|
||||
# 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'],
|
||||
}
|
||||
|
||||
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 = []
|
||||
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() 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()
|
||||
bpf_o_unstripped_cmd += [
|
||||
'-isystem',
|
||||
'/usr/include/@0@'.format(target_triplet)
|
||||
]
|
||||
endif
|
||||
endif
|
||||
|
||||
bpf_o_unstripped_cmd += [
|
||||
'-idirafter',
|
||||
libbpf_include_dir,
|
||||
'@INPUT@',
|
||||
'-o',
|
||||
'@OUTPUT@'
|
||||
]
|
||||
|
||||
if bpftool_strip
|
||||
bpf_o_cmd = [
|
||||
bpftool,
|
||||
'gen',
|
||||
'object',
|
||||
'@OUTPUT@',
|
||||
'@INPUT@'
|
||||
]
|
||||
elif bpf_compiler == 'clang'
|
||||
bpf_o_cmd = [
|
||||
llvm_strip,
|
||||
'-g',
|
||||
'@INPUT@',
|
||||
'-o',
|
||||
'@OUTPUT@'
|
||||
]
|
||||
endif
|
||||
|
||||
skel_h_cmd = [
|
||||
bpftool,
|
||||
'gen',
|
||||
'skeleton',
|
||||
'@INPUT@'
|
||||
]
|
||||
endif
|
||||
|
||||
#####################################################################
|
||||
|
||||
efi_arch = {
|
||||
|
@ -1,113 +0,0 @@
|
||||
# SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
|
||||
if conf.get('BPF_FRAMEWORK') != 1
|
||||
subdir_done()
|
||||
endif
|
||||
|
||||
bpf_clang_flags = [
|
||||
'-std=gnu11',
|
||||
'-Wno-compare-distinct-pointer-types',
|
||||
'-fno-stack-protector',
|
||||
'-O2',
|
||||
'-target',
|
||||
'bpf',
|
||||
'-g',
|
||||
'-c',
|
||||
]
|
||||
|
||||
bpf_gcc_flags = [
|
||||
'-std=gnu11',
|
||||
'-fno-stack-protector',
|
||||
'-O2',
|
||||
'-mkernel=5.2',
|
||||
'-mcpu=v3',
|
||||
'-mco-re',
|
||||
'-gbtf',
|
||||
'-c',
|
||||
]
|
||||
|
||||
# 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'],
|
||||
}
|
||||
|
||||
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 = []
|
||||
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() 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()
|
||||
bpf_o_unstripped_cmd += [
|
||||
'-isystem',
|
||||
'/usr/include/@0@'.format(target_triplet)
|
||||
]
|
||||
endif
|
||||
endif
|
||||
|
||||
bpf_o_unstripped_cmd += [
|
||||
'-idirafter',
|
||||
libbpf_include_dir,
|
||||
'@INPUT@',
|
||||
'-o',
|
||||
'@OUTPUT@'
|
||||
]
|
||||
|
||||
if bpftool_strip
|
||||
bpf_o_cmd = [
|
||||
bpftool,
|
||||
'gen',
|
||||
'object',
|
||||
'@OUTPUT@',
|
||||
'@INPUT@'
|
||||
]
|
||||
elif bpf_compiler == 'clang'
|
||||
bpf_o_cmd = [
|
||||
llvm_strip,
|
||||
'-g',
|
||||
'@INPUT@',
|
||||
'-o',
|
||||
'@OUTPUT@'
|
||||
]
|
||||
endif
|
||||
|
||||
skel_h_cmd = [
|
||||
bpftool,
|
||||
'gen',
|
||||
'skeleton',
|
||||
'@INPUT@'
|
||||
]
|
@ -74,8 +74,6 @@ if conf.get('BPF_FRAMEWORK') == 1
|
||||
)
|
||||
endif
|
||||
|
||||
subdir('bpf')
|
||||
|
||||
subdir('bpf/socket_bind')
|
||||
if conf.get('BPF_FRAMEWORK') == 1
|
||||
libcore_sources += [socket_bind_skel_h]
|
||||
|
Loading…
x
Reference in New Issue
Block a user