Skip to content

Commit

Permalink
meson: do not link lib/ to C schedulers by default
Browse files Browse the repository at this point in the history
  • Loading branch information
etsal committed Jan 6, 2025
1 parent d98a352 commit a7247f7
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 15 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
8 changes: 7 additions & 1 deletion 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 @@ -283,11 +285,15 @@ gen_bpf_o = generator(bpf_clang,
'-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@'])

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
16 changes: 14 additions & 2 deletions scheds/c/meson.build
Original file line number Diff line number Diff line change
@@ -1,12 +1,24 @@
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)
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],
install: true)
endforeach

0 comments on commit a7247f7

Please sign in to comment.