Skip to content

Commit

Permalink
Merge pull request #1158 from etsal/etsal/meson-no-default-lib
Browse files Browse the repository at this point in the history
meson: do not link BPF library into C schedulers by default
  • Loading branch information
etsal authored Jan 7, 2025
2 parents 391d21b + a7247f7 commit 78237c3
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 17 deletions.
18 changes: 6 additions & 12 deletions meson-scripts/bpftool_build_skel
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,14 @@ bpftool="$1"
input="$2"
skel="$3"
subskel="$4"
lib="$5"

stem="${input%.o}"
name="${input%.bpf.o}"
name="${name##*/}"

if [ `basename $lib` == $name ];
then
"$bpftool" gen object "$stem".l1o "$input"
else
"$bpftool" gen object "$stem".l1o "$input" "$lib".bpf.o
"$bpftool" gen object "$stem".l2o "$stem".l1o
"$bpftool" gen object "$stem".l3o "$stem".l2o
cmp "$stem".l2o "$stem".l3o
"$bpftool" gen skeleton "$stem".l3o name "$name" > "$skel"
"$bpftool" gen subskeleton "$stem".l3o name "$name" > "$subskel"
fi
"$bpftool" gen object "$stem".l1o "$input"
"$bpftool" gen object "$stem".l2o "$stem".l1o
"$bpftool" gen object "$stem".l3o "$stem".l2o
cmp "$stem".l2o "$stem".l3o
"$bpftool" gen skeleton "$stem".l3o name "$name" > "$skel"
"$bpftool" gen subskeleton "$stem".l3o name "$name" > "$subskel"
25 changes: 25 additions & 0 deletions meson-scripts/bpftool_build_skel_lib
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/bash

set -e

bpftool="$1"
input="$2"
skel="$3"
subskel="$4"
lib="$5"

stem="${input%.o}"
name="${input%.bpf.o}"
name="${name##*/}"

if [ -z "$lib" ] || [ `basename $lib` == $name ];
then
"$bpftool" gen object "$stem".l1o "$input"
else
"$bpftool" gen object "$stem".l1o "$input" "$lib".bpf.o
"$bpftool" gen object "$stem".l2o "$stem".l1o
"$bpftool" gen object "$stem".l3o "$stem".l2o
cmp "$stem".l2o "$stem".l3o
"$bpftool" gen skeleton "$stem".l3o name "$name" > "$skel"
"$bpftool" gen subskeleton "$stem".l3o name "$name" > "$subskel"
fi
10 changes: 8 additions & 2 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ get_bpftool_ver = find_program(join_paths(meson.current_source_dir(),
'meson-scripts/get_bpftool_ver'))
bpftool_build_skel = find_program(join_paths(meson.current_source_dir(),
'meson-scripts/bpftool_build_skel'))
bpftool_build_skel_lib = find_program(join_paths(meson.current_source_dir(),
'meson-scripts/bpftool_build_skel_lib'))
get_sys_incls = find_program(join_paths(meson.current_source_dir(),
'meson-scripts/get_sys_incls'))
test_sched = find_program(join_paths(meson.current_source_dir(),
Expand Down Expand Up @@ -278,15 +280,19 @@ subdir('lib')
#
gen_bpf_o = generator(bpf_clang,
output: '@[email protected]',
depends: [libbpf, scx_lib],
depends: [libbpf],
arguments: [bpf_base_cflags, '-target', 'bpf', libbpf_c_headers, bpf_includes,
'-c', '@INPUT@', '-o', '@OUTPUT@'])

gen_bpf_skel = generator(bpftool_build_skel,
output: ['@[email protected]','@[email protected]' ],
depends: [libbpf, bpftool_target],
arguments: [bpftool_exe_path, '@INPUT@', '@OUTPUT0@', '@OUTPUT1@', scx_lib_path])
arguments: [bpftool_exe_path, '@INPUT@', '@OUTPUT0@', '@OUTPUT1@'])

gen_bpf_skel_lib = generator(bpftool_build_skel_lib,
output: ['@[email protected]','@[email protected]' ],
depends: [libbpf, bpftool_target, scx_lib],
arguments: [bpftool_exe_path, '@INPUT@', '@OUTPUT0@', '@OUTPUT1@', scx_lib_path])

#
# For rust sub-projects.
Expand Down
18 changes: 15 additions & 3 deletions scheds/c/meson.build
Original file line number Diff line number Diff line change
@@ -1,10 +1,22 @@
c_scheds = ['scx_simple', 'scx_qmap', 'scx_central', 'scx_userland', 'scx_nest',
'scx_flatcg', 'scx_pair', 'scx_sdt']
'scx_flatcg', 'scx_pair']

c_scheds_lib = ['scx_sdt']

thread_dep = dependency('threads')

foreach sched: c_scheds
thread_dep = dependency('threads')
bpf_o = gen_bpf_o.process(sched + '.bpf.c')
bpf_skel = gen_bpf_skel.process(bpf_o, scx_lib)
bpf_skel = gen_bpf_skel.process(bpf_o)
executable(sched, [bpf_skel, sched + '.c'],
include_directories: [user_c_includes],
dependencies: [kernel_dep, libbpf_dep, thread_dep],
install: true)
endforeach

foreach sched: c_scheds_lib
bpf_o = gen_bpf_o.process(sched + '.bpf.c')
bpf_skel = gen_bpf_skel_lib.process(bpf_o)
executable(sched, [bpf_skel, sched + '.c'],
include_directories: [user_c_includes],
dependencies: [kernel_dep, libbpf_dep, thread_dep],
Expand Down

0 comments on commit 78237c3

Please sign in to comment.