Skip to content

Commit 9d5a03d

Browse files
KarstenBchenhengqi
authored andcommitted
Fixes chenhengqi#5
Calling make on libbpf Whitelist only relevant symbols Signed-off-by: Karsten Becker <[email protected]>
1 parent 6910eab commit 9d5a03d

File tree

2 files changed

+2826
-14464
lines changed

2 files changed

+2826
-14464
lines changed

build.rs

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,19 @@ fn main() {
1717
.status()
1818
.expect("could not execute make");
1919

20-
assert!(status.success(), "make failed");
20+
assert!(status.success(), "make libxdp failed");
21+
22+
let status = process::Command::new("make")
23+
.current_dir(&libbpf_dir)
24+
.status()
25+
.expect("could not execute make");
26+
27+
assert!(status.success(), "make libbpf failed");
2128

22-
println!("cargo:rustc-link-search={}", libbpf_dir.display());
2329
println!("cargo:rustc-link-search={}", libxdp_dir.display());
24-
println!("cargo:rustc-link-lib=static=bpf");
30+
println!("cargo:rustc-link-search={}", libbpf_dir.display());
2531
println!("cargo:rustc-link-lib=static=xdp");
32+
println!("cargo:rustc-link-lib=static=bpf");
2633
println!("cargo:rustc-link-lib=elf");
2734
println!("cargo:rustc-link-lib=z");
2835

@@ -31,6 +38,21 @@ fn main() {
3138
.generate_inline_functions(true)
3239
.clang_arg(format!("-I{}", bpf_headers_dir.display()))
3340
.clang_arg(format!("-I{}", headers_dir.display()))
41+
.allowlist_var("BPF_.*")
42+
.allowlist_var("LIBBPF.*")
43+
.allowlist_var("XDP_.*")
44+
.allowlist_var("MAX_DISPATCHER_ACTIONS")
45+
.allowlist_var("XSK_.*")
46+
.allowlist_var("BTF_.*")
47+
.allowlist_function("xdp_.*")
48+
.allowlist_function("libxdp_.*")
49+
.allowlist_function("xsk_.*")
50+
.allowlist_function("btf_.*")
51+
.allowlist_function("bpf_.*")
52+
.allowlist_type("xsk_.*")
53+
.allowlist_type("xdp_.*")
54+
.allowlist_type("bpf_.*")
55+
.allowlist_type("btf_.*")
3456
.generate()
3557
.expect("Unable to generate bindings")
3658
.write_to_file(src_dir.join("src/bindings.rs"))

0 commit comments

Comments
 (0)