mirror of
https://github.com/sched-ext/scx.git
synced 2024-11-25 12:10:24 +00:00
Add libbpf as a submodule
This is to potentinally reduce issues with folks using different versions of libbpf at runtime.
This commit is contained in:
parent
4dfb898a08
commit
626e66686a
3
.gitmodules
vendored
Normal file
3
.gitmodules
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
[submodule "libbpf"]
|
||||
path = libbpf
|
||||
url = https://github.com/libbpf/libbpf
|
16
README.md
16
README.md
@ -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)
|
||||
new in 1.3). It's preferred to link statically against the source from the libbpf git submodule.
|
||||
- Rust toolchain: >=1.72
|
||||
- `libelf`, `libz`, `libzstd` if linking against staic `libbpf.a`
|
||||
- `bpftool` (usually available in `linux-tools-common`)
|
||||
@ -210,9 +210,21 @@ 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)
|
||||
|
||||
```
|
||||
$ cd $SCX
|
||||
$ git submodule init
|
||||
$ make -C libbpf/src
|
||||
$ meson setup build --prefix ~
|
||||
$ meson compile -C build
|
||||
$ meson install -C build
|
||||
```
|
||||
|
||||
#### Dynamic linking against libbpf
|
||||
```
|
||||
$ cd $SCX
|
||||
$ meson setup build --prefix ~
|
||||
$ meson setup build --prefix ~ -D libbpf_a=disabled
|
||||
$ meson compile -C build
|
||||
$ meson install -C build
|
||||
```
|
||||
|
1
libbpf
Submodule
1
libbpf
Submodule
@ -0,0 +1 @@
|
||||
Subproject commit 20c0a9e3d7e7d4aeb283eae982543c9cacc29477
|
22
meson.build
22
meson.build
@ -44,9 +44,21 @@ elif bpf_clang_maj < 17
|
||||
.format(bpf_clang.full_path(), bpf_clang_ver))
|
||||
endif
|
||||
|
||||
if get_option('libbpf_a') != ''
|
||||
libbpf_a = '@0@/libbpf/src/libbpf.a'.format(meson.current_source_dir())
|
||||
|
||||
if get_option('libbpf_a') == 'disabled'
|
||||
libbpf_a = ''
|
||||
elif get_option('libbpf_a') != ''
|
||||
libbpf_a = get_option('libbpf_a')
|
||||
endif
|
||||
|
||||
if libbpf_a != ''
|
||||
if not fs.exists(libbpf_a)
|
||||
error('@0@ does not exist. You need to build/make libbpf.'.format(libbpf_a))
|
||||
endif
|
||||
|
||||
libbpf_dep = [declare_dependency(
|
||||
link_args: get_option('libbpf_a'),
|
||||
link_args: libbpf_a,
|
||||
include_directories: get_option('libbpf_h')),
|
||||
cc.find_library('elf'),
|
||||
cc.find_library('z'),
|
||||
@ -98,7 +110,7 @@ message('cpu=@0@ bpf_base_cflags=@1@'.format(cpu, bpf_base_cflags))
|
||||
|
||||
libbpf_c_headers = []
|
||||
|
||||
if get_option('libbpf_a') != ''
|
||||
if libbpf_a != ''
|
||||
foreach header: get_option('libbpf_h')
|
||||
libbpf_c_headers += ['-I', header]
|
||||
endforeach
|
||||
@ -134,14 +146,14 @@ foreach flag: bpf_base_cflags
|
||||
cargo_env.append('BPF_BASE_CFLAGS', flag, separator: ' ')
|
||||
endforeach
|
||||
|
||||
if get_option('libbpf_a') != ''
|
||||
if libbpf_a != ''
|
||||
foreach header: get_option('libbpf_h')
|
||||
cargo_env.append('BPF_EXTRA_CFLAGS_PRE_INCL', '-I' + header, separator: ' ')
|
||||
endforeach
|
||||
|
||||
cargo_env.append('RUSTFLAGS',
|
||||
'-C link-args=-lelf -C link-args=-lz -C link-args=-lzstd -L '
|
||||
+ fs.parent(get_option('libbpf_a')))
|
||||
+ fs.parent(libbpf_a))
|
||||
|
||||
#
|
||||
# XXX - scx_rusty's original Cargo.toml contained a dependency matching
|
||||
|
@ -3,7 +3,7 @@ option('bpf_clang', type: 'string', value: 'clang',
|
||||
option('bpftool', type: 'string', value: 'bpftool',
|
||||
description: 'bpftool to use when generating .bpf.skel.h')
|
||||
option('libbpf_a', type: 'string',
|
||||
description: 'Static libbpf.a to use')
|
||||
description: 'Static libbpf.a to use. Default is to use the one inside the libbpf submodule. Set this option to "disabled" to link libbpf dynamically.')
|
||||
option('libbpf_h', type: 'array',
|
||||
description: 'libbpf header directories, only meaningful with libbpf_a option')
|
||||
option('cargo', type: 'string', value: 'cargo',
|
||||
|
Loading…
Reference in New Issue
Block a user