mirror of
https://github.com/sched-ext/scx.git
synced 2024-11-21 18:41:47 +00:00
Remove libbpf as a submodule
Instead clone the libbpf repo at a specific hash during setup. This is to fix an issue whereby submodules are not included in the tarball and therefore won't be updated/fetched during setup after unzipping the tarball.
This commit is contained in:
parent
1a6ff1a871
commit
1769dece7d
7
.github/workflows/build-scheds.yml
vendored
7
.github/workflows/build-scheds.yml
vendored
@ -36,11 +36,6 @@ jobs:
|
||||
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
# libbpf
|
||||
- run: git clone --recurse-submodules --branch v1.3.0 https://github.com/libbpf/libbpf.git
|
||||
- run: make -j -C libbpf/src
|
||||
- run: sudo make -j -C libbpf/src install
|
||||
|
||||
# meson
|
||||
- run: pip install meson
|
||||
|
||||
@ -61,7 +56,7 @@ jobs:
|
||||
### END DEPENDENCIES ###
|
||||
|
||||
# The actual build:
|
||||
- run: meson setup build -Dlibbpf_a=`pwd`/libbpf/src/libbpf.a -Dkernel=$(pwd)/linux
|
||||
- run: meson setup build -Dkernel=$(pwd)/linux
|
||||
- run: meson compile -C build
|
||||
|
||||
# Print CPU model before running the tests (this can be useful for
|
||||
|
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
libbpf/
|
3
.gitmodules
vendored
3
.gitmodules
vendored
@ -1,3 +0,0 @@
|
||||
[submodule "libbpf"]
|
||||
path = libbpf
|
||||
url = https://github.com/libbpf/libbpf
|
@ -198,7 +198,7 @@ repo](https://mesonbuild.com/Quick-guide.html#installation-from-source) and call
|
||||
standard utilities including `awk`.
|
||||
- `clang`: >=16 required, >=17 recommended
|
||||
- `libbpf`: >=1.2.2 required, >=1.3 recommended (`RESIZE_ARRAY` support is
|
||||
new in 1.3). It's preferred to link statically against the source from the libbpf git submodule.
|
||||
new in 1.3). It's preferred to link statically against the source from the libbpf git repo, which is cloned during setup.
|
||||
- Rust toolchain: >=1.72
|
||||
- `libelf`, `libz`, `libzstd` if linking against staic `libbpf.a`
|
||||
- `bpftool` (usually available in `linux-tools-common`)
|
||||
@ -210,7 +210,7 @@ repo](https://mesonbuild.com/Quick-guide.html#installation-from-source) and call
|
||||
commands in the root of the tree builds and installs all schedulers under
|
||||
`~/bin`.
|
||||
|
||||
#### Static linking against libbpf submodule (preferred)
|
||||
#### Static linking against libbpf (preferred)
|
||||
|
||||
```
|
||||
$ cd $SCX
|
||||
@ -219,7 +219,7 @@ $ meson compile -C build
|
||||
$ meson install -C build
|
||||
```
|
||||
|
||||
Note: `meson setup` will also fetch the libbpf submodule and `meson compile` will build it.
|
||||
Note: `meson setup` will also clone the libbpf repo and `meson compile` will build it.
|
||||
|
||||
#### Dynamic linking against libbpf
|
||||
```
|
||||
|
1
libbpf
1
libbpf
@ -1 +0,0 @@
|
||||
Subproject commit 20c0a9e3d7e7d4aeb283eae982543c9cacc29477
|
@ -23,5 +23,5 @@ for arg in ${args[@]:(idx+1)}; do
|
||||
esac
|
||||
done
|
||||
|
||||
make_out=$(env CC="$cc" CFLAGS="$cflags" BUILD_STATIC_ONLY=y "$2" -C "$3" -j"$4")
|
||||
make_out=$(env CC="$cc" CFLAGS="$cflags" BUILD_STATIC_ONLY=y DESTDIR=. "$2" install -C "$3" -j"$4")
|
||||
exit $?
|
||||
|
13
meson-scripts/fetch_libbpf
Normal file
13
meson-scripts/fetch_libbpf
Normal file
@ -0,0 +1,13 @@
|
||||
#!/bin/bash
|
||||
|
||||
cd $1
|
||||
rm -rf libbpf
|
||||
git clone --depth=1 https://github.com/libbpf/libbpf
|
||||
cd libbpf
|
||||
git fetch --depth=1 origin $2
|
||||
git checkout $2
|
||||
|
||||
# This is needed because we haven't built libbpf yet
|
||||
# and this is where the headers will end up
|
||||
mkdir src/usr
|
||||
mkdir src/usr/include
|
22
meson.build
22
meson.build
@ -28,6 +28,8 @@ 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(),
|
||||
'meson-scripts/test_sched'))
|
||||
fetch_libbpf = find_program(join_paths(meson.current_source_dir(),
|
||||
'meson-scripts/fetch_libbpf'))
|
||||
build_libbpf = find_program(join_paths(meson.current_source_dir(),
|
||||
'meson-scripts/build_libbpf'))
|
||||
if enable_rust
|
||||
@ -46,9 +48,11 @@ elif bpf_clang_maj < 17
|
||||
.format(bpf_clang.full_path(), bpf_clang_ver))
|
||||
endif
|
||||
|
||||
libbpf_path = '@0@/libbpf/src'.format(meson.current_source_dir())
|
||||
libbpf_path = '@0@/libbpf/src'.format(meson.current_build_dir())
|
||||
libbpf_a = '@0@/libbpf.a'.format(libbpf_path)
|
||||
should_build_libbpf = true
|
||||
libbpf_h = get_option('libbpf_h')
|
||||
libbpf_local_h = get_option('libbpf_h')
|
||||
|
||||
if get_option('libbpf_a') == 'disabled'
|
||||
libbpf_a = ''
|
||||
@ -74,10 +78,12 @@ if should_build_libbpf
|
||||
error('To build the libbpf library "make" and "jq" are required')
|
||||
endif
|
||||
|
||||
message('Updating libbpf submodule')
|
||||
run_command('git', 'submodule', 'update', '--init', '--recursive', check: true)
|
||||
# make sure it's clean
|
||||
run_command('git', 'submodule', 'foreach', '--recursive', 'git', 'clean', '-xfd', check: true)
|
||||
libbpf_h = ['@0@/usr/include'.format(libbpf_path)]
|
||||
libbpf_local_h = ['.@0@/libbpf/src/usr/include'.format(meson.current_build_dir().replace(meson.current_source_dir(), ''))]
|
||||
|
||||
message('Fetching libbpf repo')
|
||||
libbpf_commit = '4f875865b772c4f534bc0a665bbd988193825bd4'
|
||||
run_command(fetch_libbpf, meson.current_build_dir(), libbpf_commit, check: true)
|
||||
|
||||
# setup the build target
|
||||
executable('cc_cflags_probe', 'meson-scripts/cc_cflags_probe.c', install: false, pie: true)
|
||||
@ -104,7 +110,7 @@ endif
|
||||
if libbpf_a != ''
|
||||
libbpf_dep = [declare_dependency(
|
||||
link_args: libbpf_a,
|
||||
include_directories: get_option('libbpf_h')),
|
||||
include_directories: libbpf_local_h),
|
||||
cc.find_library('elf'),
|
||||
cc.find_library('z'),
|
||||
cc.find_library('zstd')]
|
||||
@ -156,7 +162,7 @@ message('cpu=@0@ bpf_base_cflags=@1@'.format(cpu, bpf_base_cflags))
|
||||
libbpf_c_headers = []
|
||||
|
||||
if libbpf_a != ''
|
||||
foreach header: get_option('libbpf_h')
|
||||
foreach header: libbpf_h
|
||||
libbpf_c_headers += ['-I', header]
|
||||
endforeach
|
||||
endif
|
||||
@ -194,7 +200,7 @@ foreach flag: bpf_base_cflags
|
||||
endforeach
|
||||
|
||||
if libbpf_a != ''
|
||||
foreach header: get_option('libbpf_h')
|
||||
foreach header: libbpf_h
|
||||
cargo_env.append('BPF_EXTRA_CFLAGS_PRE_INCL', '-I' + header, separator: ' ')
|
||||
endforeach
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user