Closed javierhonduco closed 1 month ago
bpf-linker 0.9.4
was released 2y ago according to https://crates.io/crates/bpf-linker/versions, I tried installing the latest version, 0.9.13
, and it works fine. Not closing the issue just yet because I believe @rdelfin spotted this error with a modern bpf-linker
version on his box
Not closing the issue just yet because I believe @rdelfin spotted this error with a modern
bpf-linker
version on his box
If the similar error still occurs with the newest bpf-linker, it most likely means that Rust nightly is outdated and uses LLVM 18. Make sure that you have both up to date bpf-linker and nightly toolchain.
The core of this issue is that LLVM version used by Rust compiler needs to match the LLVM version used by bpf-linker. So if you are using nightly from this month, you need LLVM 19. If you're using nightly from before they switched to LLVM 19, you need LLVM 18.
But if the issue still persists with both being up to date, please post the full log. :)
Thanks. I'll do my best to replicate it and provide more details. It was quite a strange issue when we hit it
Thanks for your reply!
The core of this issue is that LLVM version used by Rust compiler needs to match the LLVM version used by bpf-linker.
That's very good to know, was not aware of this.
@vadorovsky would it be ok to open an issue to add a check to ensure the LLVM version of rustc
and bpf-linker
matches? I see that rustc
prints it with rustc --version --verbose
. Let me know!
I also meet this problem, however when I build with --release
it disappear
the error output is
error: linking with
bpf-linker
failed: exit status: 2 | = note: LC_ALL="C" PATH="/home/sherlock/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/bin:/home/sherlock/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/bin:/home/sherlock/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/bin:/home/sherlock/.local/bin:/home/sherlock/.cargo/bin:/home/sherlock/.local/bin:/home/sherlock/.cargo/bin:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/lib/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl:/usr/lib/rustup/bin:/home/sherlock/.local/share/JetBrains/Toolbox/scripts" VSLANG="1033" "bpf-linker" "--export-symbols" "/tmp/rustctSZAxE/symbols" "/tmp/rustctSZAxE/symbols.o" "/home/sherlock/git/wiresquirrel/target/bpfel-unknown-none/debug/deps/bpf-5f82aa83bb828146.1wmi8vltjyih6w6vs5hpz3gce.rcgu.o" "/home/sherlock/git/wiresquirrel/target/bpfel-unknown-none/debug/deps/bpf-5f82aa83bb828146.2thvllu9xv7ixzcfne74nxk3b.rcgu.o" "/home/sherlock/git/wiresquirrel/target/bpfel-unknown-none/debug/deps/bpf-5f82aa83bb828146.3514g41f843i7g6elovcoob4q.rcgu.o" "/home/sherlock/git/wiresquirrel/target/bpfel-unknown-none/debug/deps/bpf-5f82aa83bb828146.4qp9v74o4xw7r6ui4znhdnlce.rcgu.o" "/home/sherlock/git/wiresquirrel/target/bpfel-unknown-none/debug/deps/bpf-5f82aa83bb828146.5krpiu9po0gy7s8aqw2ej39k2.rcgu.o" "/home/sherlock/git/wiresquirrel/target/bpfel-unknown-none/debug/deps/libbpf-e10d06608150ea75.rlib" "/home/sherlock/git/wiresquirrel/target/bpfel-unknown-none/debug/deps/libaya_log_ebpf-483ff5ff8c8f7bd4.rlib" "/home/sherlock/git/wiresquirrel/target/bpfel-unknown-none/debug/deps/libaya_log_common-cde91de2d19ed58d.rlib" "/home/sherlock/git/wiresquirrel/target/bpfel-unknown-none/debug/deps/libnum_enum-2b3374f4d0e1099c.rlib" "/home/sherlock/git/wiresquirrel/target/bpfel-unknown-none/debug/deps/libaya_ebpf-79ba6bc20d234ef8.rlib" "/home/sherlock/git/wiresquirrel/target/bpfel-unknown-none/debug/deps/libaya_ebpf_bindings-66840fc57a124bea.rlib" "/home/sherlock/git/wiresquirrel/target/bpfel-unknown-none/debug/deps/libaya_ebpf_cty-b572a482c2d98ac8.rlib" "/home/sherlock/git/wiresquirrel/target/bpfel-unknown-none/debug/deps/librustc_std_workspace_core-3cbf9c5d8705edfa.rlib" "/home/sherlock/git/wiresquirrel/target/bpfel-unknown-none/debug/deps/libcore-5023775ddfe6d40b.rlib" "/home/sherlock/git/wiresquirrel/target/bpfel-unknown-none/debug/deps/libcompiler_builtins-f9e8c717abd72cac.rlib" "--cpu" "generic" "-o" "/home/sherlock/git/wiresquirrel/target/bpfel-unknown-none/debug/deps/bpf-5f82aa83bb828146" "-O0" "--debug" "--btf" = note: unable to open LLVM shared lib /home/sherlock/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/libLLVM-19-rust-1.82.0-nightly.so: /home/sherlock/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/libLLVM-19-rust-1.82.0-nightly.so: file too short error: LLVM issued diagnostic with error severity
I am using nightly rustc
rustc 1.82.0-nightly (0d634185d 2024-08-29) binary: rustc commit-hash: 0d634185dfddefe09047881175f35c65d68dcff1 commit-date: 2024-08-29 host: x86_64-unknown-linux-gnu release: 1.82.0-nightly LLVM version: 19.1.0
that's my .cargo/config.toml file
[build]
target = "bpfel-unknown-none"
[unstable]
build-std = ["core"]
[target.bpfel-unknown-none]
rustflags = ["-C", "debuginfo=2", "-C", "link-arg=--btf"]
bpf-linker version is 0.9.12
Hi, for what it's worth, I'm hitting the same thing on my setup:
$ bpf-linker --version
bpf-linker 0.9.13
$ rustc --version --verbose
rustc 1.83.0-nightly (8d6b88b16 2024-09-11)
binary: rustc
commit-hash: 8d6b88b168e45ee1624699c19443c49665322a91
commit-date: 2024-09-11
host: x86_64-unknown-linux-gnu
release: 1.83.0-nightly
LLVM version: 19.1.0
$ cat /home/qmo/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/libLLVM-19-rust-1.83.0-nightly.so
INPUT(libLLVM.so.19.1-rust-1.83.0-nightly)
I get a similar error message:
$ cargo build --target=bpfel-unknown-none -Z build-std=core
[...]
= note: unable to open LLVM shared lib /home/qmo/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/libLLVM-19-rust-1.83.0-nightly.so: /home/qmo/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/libLLVM-19-rust-1.83.0-nightly.so: file too short
ERROR llvm: <unknown>:0:0: in function memmove ptr (ptr, ptr, i64): A call to built-in function 'abort' is not supported.
ERROR llvm: <unknown>:0:0: in function memmove ptr (ptr, ptr, i64): A call to built-in function 'abort' is not supported.
Error: LLVM issued diagnostic with error severity
Adding --release
fixes the issue
@javierhonduco
@vadorovsky would it be ok to open an issue to add a check to ensure the LLVM version of
rustc
andbpf-linker
matches? I see thatrustc
prints it withrustc --version --verbose
. Let me know!
I'm very sorry for missing this comment! Sure, we could add such check, I think it would be valuable.
@qmonnet
Hi, for what it's worth, I'm hitting the same thing on my setup:
$ bpf-linker --version bpf-linker 0.9.13 $ rustc --version --verbose rustc 1.83.0-nightly (8d6b88b16 2024-09-11) binary: rustc commit-hash: 8d6b88b168e45ee1624699c19443c49665322a91 commit-date: 2024-09-11 host: x86_64-unknown-linux-gnu release: 1.83.0-nightly LLVM version: 19.1.0
$ cat /home/qmo/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/libLLVM-19-rust-1.83.0-nightly.so INPUT(libLLVM.so.19.1-rust-1.83.0-nightly)
I get a similar error message:
$ cargo build --target=bpfel-unknown-none -Z build-std=core [...] = note: unable to open LLVM shared lib /home/qmo/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/libLLVM-19-rust-1.83.0-nightly.so: /home/qmo/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/libLLVM-19-rust-1.83.0-nightly.so: file too short ERROR llvm: <unknown>:0:0: in function memmove ptr (ptr, ptr, i64): A call to built-in function 'abort' is not supported. ERROR llvm: <unknown>:0:0: in function memmove ptr (ptr, ptr, i64): A call to built-in function 'abort' is not supported. Error: LLVM issued diagnostic with error severity
Adding
--release
fixes the issue
This is a different issue than the original one. I think this one is about a lack of memmove
builtin. We fixed it in aya-rs/aya#971, but that fix is not released yet.
To double-check whether that's really an issue, you could use aya-ebpf
from git (aya-ebpf = { git = "https://github.com/aya-rs/aya", branch = "main" }
in your Cargo.toml).
Or you could try adding the following code in your eBPF program code:
#[no_mangle]
pub unsafe extern "C" fn memmove(dest: *mut u8, src: *mut u8, n: usize) {
let delta = (dest as usize).wrapping_sub(src as usize);
if delta >= n {
// We can copy forwards because either dest is far enough ahead of src,
// or src is ahead of dest (and delta overflowed).
copy_forward(dest, src, n);
} else {
copy_backward(dest, src, n);
}
}
#[inline(always)]
unsafe fn copy_forward(dest: *mut u8, src: *mut u8, n: usize) {
for i in 0..n {
*dest.add(i) = *src.add(i);
}
}
#[inline(always)]
unsafe fn copy_backward(dest: *mut u8, src: *mut u8, n: usize) {
for i in (0..n).rev() {
*dest.add(i) = *src.add(i);
}
}
Let me know whether that helps.
If it doesn't, an another option might be that you have code which can panic (unwrap
, panic!
etc.). Panics are not supported in Aya for now and all errors have to be handled explicitly.
Apologies for mixing up two different issues. Yes, it does work correctly in my case with the current HEAD from main
, thank you Michal!
@qmonnet No worries, happy to hear that it works for you now! :slightly_smiling_face:
@javierhonduco Are you still facing issues on your side?
cc @rdelfin 👀
I will close this issue for now, feel free to re-open if it still occurs.
The original issue reported was fixed by #214, the release was already made (0.9.13).
And @qmonnet's issue is fixed by aya-rs/aya#971, which is not released yet.
Hi,
When trying to compile https://github.com/aya-rs/book/tree/1d62046f4addf513ceb29298e38116625e776a3e/examples/xdp-hello
cargo xtask build-ebpf
panics withUnable to open LLVM shared lib: [...]/libLLVM-18-rust-1.79.0-nightly.so: file too short
, see full stack trace below. I am not sure if this could be related to https://github.com/aya-rs/bpf-linker/issues/210, the stack trace contains a similar top error, but it looks a bit different. Thanks!cc @rdelfin
Full stacktrace
Environment info