1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2024-12-23 17:34:00 +03:00

Merge pull request #21722 from yuwata/bpf-framework

build: include BPF_FRAMEWORK in version string
This commit is contained in:
Zbigniew Jędrzejewski-Szmek 2021-12-10 17:18:24 +01:00 committed by GitHub
commit 40676ce6f8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 135 additions and 116 deletions

View File

@ -194,6 +194,12 @@ const char* const systemd_features =
/* other stuff that doesn't fit above */ /* other stuff that doesn't fit above */
#if BPF_FRAMEWORK
" +BPF_FRAMEWORK"
#else
" -BPF_FRAMEWORK"
#endif
#if HAVE_XKBCOMMON #if HAVE_XKBCOMMON
" +XKBCOMMON" " +XKBCOMMON"
#else #else

View File

@ -1,61 +1,63 @@
# SPDX-License-Identifier: LGPL-2.1+ # SPDX-License-Identifier: LGPL-2.1+
if conf.get('BPF_FRAMEWORK') == 1 if conf.get('BPF_FRAMEWORK') != 1
clang_flags = [ subdir_done()
'-Wno-compare-distinct-pointer-types',
'-O2',
'-target',
'bpf',
'-g',
'-c',
]
clang_arch_flag = '-D__@0@__'.format(host_machine.cpu_family())
if meson.version().version_compare('>= 0.58')
libbpf_include_dir = libbpf.get_variable('includedir')
else
libbpf_include_dir = libbpf.get_variable(pkgconfig : 'includedir')
endif
bpf_o_unstripped_cmd = [
clang,
clang_flags,
clang_arch_flag,
'-I.'
]
if not meson.is_cross_build()
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@'
]
bpf_o_cmd = [
llvm_strip,
'-g',
'@INPUT@',
'-o',
'@OUTPUT@'
]
skel_h_cmd = [
bpftool,
'g',
's',
'@INPUT@'
]
endif endif
clang_flags = [
'-Wno-compare-distinct-pointer-types',
'-O2',
'-target',
'bpf',
'-g',
'-c',
]
clang_arch_flag = '-D__@0@__'.format(host_machine.cpu_family())
if meson.version().version_compare('>= 0.58')
libbpf_include_dir = libbpf.get_variable('includedir')
else
libbpf_include_dir = libbpf.get_variable(pkgconfig : 'includedir')
endif
bpf_o_unstripped_cmd = [
clang,
clang_flags,
clang_arch_flag,
'-I.'
]
if not meson.is_cross_build()
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@'
]
bpf_o_cmd = [
llvm_strip,
'-g',
'@INPUT@',
'-o',
'@OUTPUT@'
]
skel_h_cmd = [
bpftool,
'g',
's',
'@INPUT@'
]

View File

@ -1,22 +1,24 @@
# SPDX-License-Identifier: LGPL-2.1-or-later # SPDX-License-Identifier: LGPL-2.1-or-later
if conf.get('BPF_FRAMEWORK') == 1 if conf.get('BPF_FRAMEWORK') != 1
restrict_fs_bpf_o_unstripped = custom_target( subdir_done()
'restrict-fs.bpf.unstripped.o',
input : 'restrict-fs.bpf.c',
output : 'restrict-fs.bpf.unstripped.o',
command : bpf_o_unstripped_cmd)
restrict_fs_bpf_o = custom_target(
'restrict-fs.bpf.o',
input : restrict_fs_bpf_o_unstripped,
output : 'restrict-fs.bpf.o',
command : bpf_o_cmd)
restrict_fs_skel_h = custom_target(
'restrict-fs.skel.h',
input : restrict_fs_bpf_o,
output : 'restrict-fs.skel.h',
command : skel_h_cmd,
capture : true)
endif endif
restrict_fs_bpf_o_unstripped = custom_target(
'restrict-fs.bpf.unstripped.o',
input : 'restrict-fs.bpf.c',
output : 'restrict-fs.bpf.unstripped.o',
command : bpf_o_unstripped_cmd)
restrict_fs_bpf_o = custom_target(
'restrict-fs.bpf.o',
input : restrict_fs_bpf_o_unstripped,
output : 'restrict-fs.bpf.o',
command : bpf_o_cmd)
restrict_fs_skel_h = custom_target(
'restrict-fs.skel.h',
input : restrict_fs_bpf_o,
output : 'restrict-fs.skel.h',
command : skel_h_cmd,
capture : true)

View File

@ -1,22 +1,24 @@
# SPDX-License-Identifier: LGPL-2.1-or-later # SPDX-License-Identifier: LGPL-2.1-or-later
if conf.get('BPF_FRAMEWORK') == 1 if conf.get('BPF_FRAMEWORK') != 1
restrict_ifaces_bpf_o_unstripped = custom_target( subdir_done()
'restrict-ifaces.bpf.unstripped.o',
input : 'restrict-ifaces.bpf.c',
output : 'restrict-ifaces.bpf.unstripped.o',
command : bpf_o_unstripped_cmd)
restrict_ifaces_bpf_o = custom_target(
'restrict-ifaces.bpf.o',
input : restrict_ifaces_bpf_o_unstripped,
output : 'restrict-ifaces.bpf.o',
command : bpf_o_cmd)
restrict_ifaces_skel_h = custom_target(
'restrict-ifaces.skel.h',
input : restrict_ifaces_bpf_o,
output : 'restrict-ifaces.skel.h',
command : skel_h_cmd,
capture : true)
endif endif
restrict_ifaces_bpf_o_unstripped = custom_target(
'restrict-ifaces.bpf.unstripped.o',
input : 'restrict-ifaces.bpf.c',
output : 'restrict-ifaces.bpf.unstripped.o',
command : bpf_o_unstripped_cmd)
restrict_ifaces_bpf_o = custom_target(
'restrict-ifaces.bpf.o',
input : restrict_ifaces_bpf_o_unstripped,
output : 'restrict-ifaces.bpf.o',
command : bpf_o_cmd)
restrict_ifaces_skel_h = custom_target(
'restrict-ifaces.skel.h',
input : restrict_ifaces_bpf_o,
output : 'restrict-ifaces.skel.h',
command : skel_h_cmd,
capture : true)

View File

@ -1,22 +1,24 @@
# SPDX-License-Identifier: LGPL-2.1-or-later # SPDX-License-Identifier: LGPL-2.1-or-later
if conf.get('BPF_FRAMEWORK') == 1 if conf.get('BPF_FRAMEWORK') != 1
socket_bind_bpf_o_unstripped = custom_target( subdir_done()
'socket-bind.bpf.unstripped.o',
input : 'socket-bind.bpf.c',
output : 'socket-bind.bpf.unstripped.o',
command : bpf_o_unstripped_cmd)
socket_bind_bpf_o = custom_target(
'socket-bind.bpf.o',
input : socket_bind_bpf_o_unstripped,
output : 'socket-bind.bpf.o',
command : bpf_o_cmd)
socket_bind_skel_h = custom_target(
'socket-bind.skel.h',
input : socket_bind_bpf_o,
output : 'socket-bind.skel.h',
command : skel_h_cmd,
capture : true)
endif endif
socket_bind_bpf_o_unstripped = custom_target(
'socket-bind.bpf.unstripped.o',
input : 'socket-bind.bpf.c',
output : 'socket-bind.bpf.unstripped.o',
command : bpf_o_unstripped_cmd)
socket_bind_bpf_o = custom_target(
'socket-bind.bpf.o',
input : socket_bind_bpf_o_unstripped,
output : 'socket-bind.bpf.o',
command : bpf_o_cmd)
socket_bind_skel_h = custom_target(
'socket-bind.skel.h',
input : socket_bind_bpf_o,
output : 'socket-bind.skel.h',
command : skel_h_cmd,
capture : true)

View File

@ -36,7 +36,7 @@ teardown() {
KERNEL_VERSION="$(uname -r)" KERNEL_VERSION="$(uname -r)"
KERNEL_MAJOR="${KERNEL_VERSION%%.*}" KERNEL_MAJOR="${KERNEL_VERSION%%.*}"
KERNEL_MINOR="${KERNEL_VERSION#$KERNEL_MAJOR.}" KERNEL_MINOR="${KERNEL_VERSION#"$KERNEL_MAJOR".}"
KERNEL_MINOR="${KERNEL_MINOR%%.*}" KERNEL_MINOR="${KERNEL_MINOR%%.*}"
MAJOR_REQUIRED=5 MAJOR_REQUIRED=5
@ -47,6 +47,11 @@ if [[ "$KERNEL_MAJOR" -lt $MAJOR_REQUIRED || ("$KERNEL_MAJOR" -eq $MAJOR_REQUIRE
exit 0 exit 0
fi fi
if systemctl --version | grep -q -F "-BPF_FRAMEWORK"; then
echo "bpf-framework is disabled" >>/skipped
exit 0
fi
trap teardown EXIT trap teardown EXIT
setup setup