redbpf icon indicating copy to clipboard operation
redbpf copied to clipboard

[cargo-bpf] Can't build

Open irevoire opened this issue 3 years ago • 6 comments
trafficstars

Hello,

I'm trying to install cargo-bpf but it doesn't build. Here is the error:

error: Can not use LLVM12 with Rust >= 1.56
  --> /home/irevoire/.cargo/registry/src/github.com-1ecc6299db9ec823/cargo-bpf-2.3.0/src/llvm.rs:26:9
   |
26 |         compile_error!("Can not use LLVM12 with Rust >= 1.56");
   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: could not compile `cargo-bpf` 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-installoQlyiW`

Caused by:
  build failed

The problem is that I'm using LLVM13:

% llvm-config --version
13.0.0
% pacman -Q llvm
llvm 13.0.0-6

I also tried to specify the location of my llvm installation with the LLVM_SYS_130_PREFIX env var but it changed nothing.

export LLVM_SYS_130_PREFIX=$(whereis llvm)

If it helps, I'm also using this version of rust:

% rustc --version
rustc 1.60.0-nightly (6abb6385b 2022-01-26)

And I tried with stable rust (1.58.0) but I have the same error.

Can I do something about it?

irevoire avatar Jan 27 '22 14:01 irevoire

I had the same issue, after searching through the code I found that the following worked for me: cargo install cargo-bpf --features llvm-sys-130.

secana avatar Feb 03 '22 13:02 secana

Having another problem while trying to build cargo-bpf. Installed llvm-13 (as mentioned in tutorial), but the compiler still can't build llvm-sys.

cargo install cargo-bpf --features llvm-sys-130
error: could not find native static library `Polly`, perhaps an -L flag is missing?

Ubuntu 20.04.3 LTS

sherman avatar Feb 06 '22 14:02 sherman

llvm-13 which is provided by Ubuntu for some reason doesn't provide Polly, you have to install 'libclang' or something to get it. Alternative is to install official llvm package.

kriomant avatar Feb 08 '22 04:02 kriomant

@kriomant thank for reply, but I installed llvm 13 via llvm.sh script (which I believe, the official way). Anyway, I downgraded rust version to the one, which is supported llvm 12.

sherman avatar Feb 08 '22 07:02 sherman

@irevoire I also had same issue. This is solved mine. cargo install cargo-bpf --no-default-features --features=llvm13,command-line

yasin-cs-ko-ak avatar Jun 13 '22 12:06 yasin-cs-ko-ak

In case it is helpful to anyone I ran into this problem on Arch Linux with LLVM 14.0.6 and noticed that they had made a change to the error in the main branch, which had not yet been released:

https://github.com/foniod/redbpf/commit/15ac8def9a97b908c7a48a59af31a5d2b1ad1b2f#diff-07726f98f61f7b41779df39f71d89a27822be16e60c0ade60258a611af61ae33R26

And so as mentioned in above posts, the following worked for me to install:

$ cargo install cargo-bpf --features=llvm13

And additionally in my application where cargo-bpf was a build dependency I needed:

[build-dependencies]
cargo-bpf = { version = "2.3.0", features = ["llvm13"] }

shaneutt avatar Sep 14 '22 12:09 shaneutt