Open yasin-cs-ko-ak opened 2 years ago
Same issue here. I'm on Ubuntu 22.04 and have btf.h
in /usr/include/linux/btf.h
as well as /usr/include/bpf/btf.h
. The command llvm-config --version
returns 14.0.0
. So the default llvm version installed on Ubuntu 22 is newer than required as per the specs. I don't think that this is an issue though.
Any help/input would be highly appreciated. Thanks in advance! Let me know if you need any more information.
https://github.com/foniod/redbpf#building-redbpf-from-source Please make sure you sync the submodules and try again. Let me know if build still fails then!
@bendahl RedBPF on master
will not work with LLVM 14. You will need to check out the branch for #316 to test that.
@rsdy Thanks for the super quick reply!
I just gave this a try (using thellvm14
-branch of nbaksalyar/redbpf
). Unfortunately, the issue persists. So I'm guessing there is something wrong in my environment. Besides the two locations that I mentioned earlier, I also noticed, that another btf.h
is generated by the build process in ./target/debug/build/libbpf-sys-7dd166d0a8efc198/out/include/bpf
. This is also picked up correctly when browsing the code in my local IDE.
I will make sure to check out the other link you provided to see whether I'm missing some important step.
Quick update: This was totally my fault. I missed the important step of syncing/updating the git submodules (as described in the document you linked above). Doing this and using the llvm14
branch worked.
Thank you so much!
@bendahl If you could provide me the steps that you did to solve this problem, that would be very much helpful. ex: how to sync the git sub-modules?
@bendahl I hope you followed these steps
$ git clone https://github.com/foniod/redbpf.git
$ cd redbpf
$ git submodule sync
$ git submodule update --init
$ cargo build
$ cargo build --examples
@yasin-cs-ko-ak
$ git submodule sync
$ git submodule update --init
are the 2 commands specifically you'll need. Let me know how it goes.
@rsdy
when I followed those steps you mentioned above I have encountered with these errors and warning.
$ cargo build
warning: field is never read: `flags`
--> redbpf/src/symbols.rs:110:5
|
110 | flags: i32,
| ^^^^^^^^^^
|
= note: `#[warn(dead_code)]` on by default
note: `CacheEntry` has a derived impl for the trait `Debug`, but this is intentionally ignored during dead code analysis
--> redbpf/src/symbols.rs:106:10
|
106 | #[derive(Debug)]
| ^^^^^
= note: this warning originates in the derive macro `Debug` (in Nightly builds, run with -Z macro-backtrace for more info)
warning: `redbpf` (lib) generated 1 warning
Compiling redbpf-probes v2.3.0 (/home/u1tron/redbpf/redbpf-probes)
Compiling probes v0.1.0 (/home/u1tron/redbpf/redbpf-tools/probes)
Compiling redbpf-tools v0.1.0 (/home/u1tron/redbpf/redbpf-tools)
Compiling example-probes v0.1.0 (/home/u1tron/redbpf/examples/example-probes)
error: failed to run custom build command for `redbpf-tools v0.1.0 (/home/u1tron/redbpf/redbpf-tools)`
Caused by:
process didn't exit successfully: `/home/u1tron/redbpf/target/debug/build/redbpf-tools-3d0d971cdb53b260/build-script-build` (exit status: 101)
--- stderr
thread 'main' panicked at 'couldn't compile probes: InvalidLLVMVersion("LLVM version that cargo-bpf linked to (13.0) < LLVM version that rustc depends on (14.0). You should re-build cargo-bpf with LLVM version (14.0), or downgrade rustc that uses LLVM version (13.0)")', redbpf-tools/build.rs:16:10
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
warning: build failed, waiting for other jobs to finish...
Do I have to use this build command instead of that one
cargo build --no-default-features --features=llvm13,command-line
?
@yasin-cs-ko-ak Seems like I'm a bit late to the party... However, to answer your question: Yes, I used the following commands to update the submodules:
git submodule sync
git submodule update --init
I then ran cargo build
and cargo build --examples
. Both commands worked fine.
My setup is as follows:
Due to the fact that I'm using llvm 14 I had to switch to nbaksalyar/redbpf:llvm14. As mentioned by @rsdy there is a pull request regarding llvm 14 support (see #316).
I hope this helps!
@bendahl Well, I have tried with that repository mentioned above. I still got the same error as previous and then I decided to try again with different method. I downloaded that repository as ZIP and then initiated using git init
and then ran that two commands.
But still
Compiling toml_edit v0.2.1
error: No suitable version of LLVM was found system-wide or pointed
to by LLVM_SYS_140_PREFIX.
Consider using `llvmenv` to compile an appropriate copy of LLVM, and
refer to the llvm-sys documentation for more information.
llvm-sys: https://crates.io/crates/llvm-sys
llvmenv: https://crates.io/crates/llvmenv
--> /home/u1tron/.cargo/registry/src/github.com-1ecc6299db9ec823/llvm-sys-140.0.0/src/lib.rs:487:1
|
487 | / std::compile_error!(concat!(
488 | | "No suitable version of LLVM was found system-wide or pointed
489 | | to by LLVM_SYS_",
490 | | env!("CARGO_PKG_VERSION_MAJOR"),
... |
497 | | llvmenv: https://crates.io/crates/llvmenv"
498 | | ));
| |__^
error: could not compile `llvm-sys` due to previous error
warning: build failed, waiting for other jobs to finish...
I think there is something wrong with my LLVM version. If you need any details of my system, kindly let me know. Thanks for the help!
@rsdy @bendahl For your information. This is my rustc and llvm configs
❯ rustc -vV
rustc 1.61.0 (fe5b13d68 2022-05-18)
binary: rustc
commit-hash: fe5b13d681f25ee6474be29d748c65adcd91f69e
commit-date: 2022-05-18
host: x86_64-unknown-linux-gnu
release: 1.61.0
LLVM version: 14.0.0
❯ llvm-config --version
13.0.1
and also I was looking at this. This might be helpful for this. #213
@yasin-cs-ko-ak Please try the branch with LLVM14 support among the PRs. master
doesn't support LLVM14 at this point.
I do have my header file in this directory
/usr/include/uapi/linux/btf.h
. But it's not compiling properly. and also I am installedcargo-bpf
with this commandcargo install cargo-bpf --no-default-features --features=llvm13,command-line
any thoughts?