Skip to content
This repository has been archived by the owner on Jul 11, 2023. It is now read-only.

cargo-bpf: compilation error #342

Open
Banyc opened this issue Aug 30, 2022 · 3 comments
Open

cargo-bpf: compilation error #342

Banyc opened this issue Aug 30, 2022 · 3 comments

Comments

@Banyc
Copy link

Banyc commented Aug 30, 2022

I was following the instructions of https://github.com/foniod/redbpf/blob/main/README.md.

I first installed llvm as README.md said at section On Ubuntu 20.04 LTS:

$ llvm-config-13 --version | grep 13
13.0.1

But after running cargo install cargo-bpf, the compilation throws errors:

   Compiling llvm-sys v120.2.4
error: No suitable version of LLVM was found system-wide or pointed
              to by LLVM_SYS_120_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/USERNAME/.cargo/registry/src/github.com-1ecc6299db9ec823/llvm-sys-120.2.4/src/lib.rs:486:1
    |
486 | / std::compile_error!(concat!(
487 | |     "No suitable version of LLVM was found system-wide or pointed
488 | |        to by LLVM_SYS_",
489 | |     env!("CARGO_PKG_VERSION_MAJOR"),
...   |
496 | |        llvmenv: https://crates.io/crates/llvmenv"
497 | | ));
    | |__^

error: could not compile `llvm-sys` due to previous error
warning: build failed, waiting for other jobs to finish...
error: failed to compile `cargo-bpf v2.3.0`, intermediate artifacts can be found at `/tmp/cargo-install4oXpIf`

rustc version: rustc 1.63.0 (4b91a6ea7 2022-08-08)

@A1kmm
Copy link

A1kmm commented Sep 2, 2022

I had a similar error, but running cargo install cargo-bpf --features llvm13 made it work.

@brsamb9
Copy link

brsamb9 commented Nov 6, 2022

I ran into the same problem by going through the instructions, and tried out using the feature flag mentioned above yet got the same error.

This was solved on my end by making creating a symbolic link to llvm-config - e.g. sudo ln -s /usr/bin/llvm-config-13 /usr/bin/llvm-config

@aphostrophy
Copy link

aphostrophy commented Jan 23, 2023

This could be caused by having multiple LLVM toolchains in your machine. My existing /usr/bin/llvm-config points to /usr/bin/llvm-config-10. Removing and recreating a symlink to /usr/bin/llvm-config from /usr/bin/llvm-config-13 seems to have fixed the issue.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants