redbpf icon indicating copy to clipboard operation
redbpf copied to clipboard

Redbpf, llvm, rust version mismatch issue.

Open arayu05 opened this issue 4 years ago • 14 comments

We are refering https://www.infinyon.com/blog/2021/05/ebpf-routing-rust/ for routing traffic in Rust. Its using redbpf for converting ebpf Rust to bytecode. But we are facing below challanges:

Issue 1 LLVM compiling fails ------------------------- Compiling llvm-sys v110.0.1error: No suitable version of LLVM was found system-wide or pointedto by LLVM_SYS_110_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-sysllvmenv: https://crates.io/crates/llvmenv--> /home/raghud32/.cargo/registry/src/github.com-1ecc6299db9ec823/llvm-sys-110.0.1/src/lib.rs:486:1|486 | / std::compile_error!(concat!(487 | | "No suitable version of LLVM was found system-wide or pointed488 | | 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 errorwarning: build failed, waiting for other jobs to finish...error: build failed//

Issue 2 ---------------------------- Need to install a newer version of llvm, like llvm 12, for cargo-bpf to work. We purged installed llvm and tried installing llvm 12 using https://github.com/llvm/llvm-project. llvm 12 installation took very long time so we had to abort it. Please let me know if there is a proper way to install and use llvm 12 for redBPF.

Issue 3 ----------------------------- when llvm12 was not happening, I tried going back to Rust 1.46, as the latest version of Rust didnt support llvm10. But this error occured.

arayu05 avatar Oct 01 '21 10:10 arayu05

@Ayushri-wipro LLVM12 should be readily packaged in most modern distributions, and redBPF should work well with the latest Rust version. If you can share some more about your specific environment, we might be able to help you out with the setup.

rsdy avatar Oct 01 '21 15:10 rsdy

@rsdy we cloned redbpf from: https://github.com/foniod/redbpf while cloning the redbpf repo, bpf-sys folder had libbpf folder empty, hence we had to clone libbpf separately inside bpf-sys folder. lib-bpf git repo: https://github.com/sudipm-mukherjee/libbpf.git Rust version: 1.54 Kernel version: 5.11 Ubuntu 20LTS LLVM version: 10.0.0

below is what we found in llvm.rs file and then we changed the rust version to 1.46 since we were not able to setup llvm12.

cfg_if::cfg_if! { if #[cfg(feature = "llvm-sys-120")] { use llvm_sys_120 as llvm_sys; } else if #[cfg(feature = "llvm-sys-110")] { use llvm_sys_110 as llvm_sys; #[cfg(not(docsrs))] #[rustversion::since(1.52)] compile_error!("Can not use LLVM11 with Rust >= 1.52"); } else if #[cfg(feature = "llvm-sys-100")] { use llvm_sys_100 as llvm_sys; #[cfg(not(docsrs))] #[rustversion::since(1.47)] compile_error!("Can not use LLVM10 with Rust >= 1.47"); } else { compile_error!("At least one of llvm12, llvm11 and llvm10 features should be specified"); } }

arayu05 avatar Oct 04 '21 06:10 arayu05

The way we prefer to install LLVM12, as noted in the README.md, is through their official repositories at https://apt.llvm.org/ . You can scroll down and get to the relevant sources.list entries you need to add:

deb http://apt.llvm.org/focal/ llvm-toolchain-focal-12 main
deb-src http://apt.llvm.org/focal/ llvm-toolchain-focal-12 main

After that, the commands mentined in the README should work.

The bpf-sys/libbpf directory is maintained as a submodule. Please see the README.md for instructions to recursively check out all dependencies in the repo.

Note that you normally only need to use the git repo of redbpf if you want to develop on it. We generally recommend using the releases on crates.io as they tend to be easier to get started.

rsdy avatar Oct 04 '21 11:10 rsdy

We have checked the sources.list file. The deb entries are there. Followed the README.md too. Everything is good. But the llvm version it is using still seems like 10. Any way to check our version? llvm-config --version shows 10.0.0. But 10 is not enough. Any other way to make it use our llvm12? Please let me know.

This is the error. (Same error) ->

error: No suitable version of LLVM was found system-wide or pointed
       to by LLVM_SYS_110_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/raghud32/.cargo/registry/src/github.com-1ecc6299db9ec823/llvm-sys-110.0.1/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: build failed

raghu-d32 avatar Oct 04 '21 14:10 raghu-d32

Hello @raghu-d32 Your error message shows us the compilation failed because llvm 11 is not found. This can be inferred by reading LLVM_SYS_110_PREFIX and llvm-sys-110.0.1.

Did you specify some options when you executed cargo build ?

rhdxmr avatar Oct 05 '21 12:10 rhdxmr

@raghu-d32 I think you're going to need to install the llvm12 package as opposed to llvm, since the official repo doesn't conflict with the Ubuntu distribution repos. Please see how we set up our build env here

rsdy avatar Oct 05 '21 12:10 rsdy

Hello @rhdxmr Did you mean cargo build --no-default-features --features llvm12? I tried. But it didn't work.

@rsdy Tried purging current llvm and intalling it back using:

apt-get -y install curl wget lsb-release wget software-properties-common \
       debhelper cmake llvm libllvm12 llvm-12-dev libclang-12-dev 

LLVM version still shows 10.0.0.

raghu-d32 avatar Oct 05 '21 12:10 raghu-d32

@raghu-d32 1

Besides the llvm12 installation problem, It is strange that LLVM 11 is involved in compilation. The compilation works like --all-features option is given.


2

Did you run llvm-config that is installed in /usr/bin/llvm-config?

rhdxmr avatar Oct 05 '21 13:10 rhdxmr

@rhdxmr @rsdy Thanks for the inputs. LLVM works fine for now as I have upgraded the versions of all redbpf related dependencies to 2.0.2. Got new issues now.

Maybe redbpf probes and macros is giving me this error.

error: linking with `cc` failed: exit status: 1
  |
  = note: "cc" "-m64" "/home/raghud32/Desktop/ebpf_redbpf2/ebpf-proxy/target/debug/deps/probe-1b5d6f13db46446f.38ibrod2b5bc7yow.rcgu.o" "/home/raghud32/Desktop/ebpf_redbpf2/ebpf-proxy/target/debug/deps/probe-1b5d6f13db46446f.gslmii6jju814b.rcgu.o" "/home/raghud32/Desktop/ebpf_redbpf2/ebpf-proxy/target/debug/deps/probe-1b5d6f13db46446f.tzpka0aatkj4q8k.rcgu.o" "-Wl,--as-needed" "-L" "/home/raghud32/Desktop/ebpf_redbpf2/ebpf-proxy/target/debug/deps" "-L" "/home/raghud32/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-Wl,-Bstatic" "/home/raghud32/Desktop/ebpf_redbpf2/ebpf-proxy/target/debug/deps/libredbpf_probes-b9258303afbb987c.rlib" "/home/raghud32/Desktop/ebpf_redbpf2/ebpf-proxy/target/debug/deps/libufmt-6b1807b1e71ea24c.rlib" "/home/raghud32/Desktop/ebpf_redbpf2/ebpf-proxy/target/debug/deps/libufmt_write-b7cd01d93037b840.rlib" "/home/raghud32/Desktop/ebpf_redbpf2/ebpf-proxy/target/debug/deps/libcty-2ca64d94e3ea08eb.rlib" "/home/raghud32/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_std_workspace_core-557ba8776e04d182.rlib" "/home/raghud32/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcore-4beb03d03503c439.rlib" "/home/raghud32/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcompiler_builtins-dd7db1bec6909f24.rlib" "-Wl,-Bdynamic" "-Wl,--eh-frame-hdr" "-Wl,-znoexecstack" "-L" "/home/raghud32/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-o" "/home/raghud32/Desktop/ebpf_redbpf2/ebpf-proxy/target/debug/deps/probe-1b5d6f13db46446f" "-Wl,--gc-sections" "-pie" "-Wl,-zrelro" "-Wl,-znow" "-nodefaultlibs"
  = note: /usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/Scrt1.o: in function `_start':
          (.text+0x16): undefined reference to `__libc_csu_fini'
          /usr/bin/ld: (.text+0x1d): undefined reference to `__libc_csu_init'
          /usr/bin/ld: (.text+0x24): undefined reference to `main'
          /usr/bin/ld: (.text+0x2a): undefined reference to `__libc_start_main'
          collect2: error: ld returned 1 exit status
          
  = help: some `extern` functions couldn't be found; some native libraries may need to be installed or have their path specified
  = note: use the `-l` flag to specify native libraries to link
  = note: use the `cargo:rustc-link-lib` directive to specify the native libraries to link with Cargo (see https://doc.rust-lang.org/cargo/reference/build-scripts.html#cargorustc-link-libkindname)

error: could not compile `echo-probe` due to previous error
warning: build failed, waiting for other jobs to finish...
error: build failed

Tried adding the config file.

[target.x86_64-unknown-linux-gnu]
rustflags = [
  "-C", "link-arg=-undefined",
  "-C", "link-arg=dynamic_lookup",
]

But this didn't work. Got the same error.

raghu-d32 avatar Oct 06 '21 07:10 raghu-d32

@raghu-d32 I cloned the ebpf-proxy and modify a few lines and it is compiled successfully.

# cargo build
# ulimit -l unlimited
# cargo run --bin echo-ebpf
Server Listening on 127.0.0.1:10000

I am using fedora 34 and cargo 1.55

The attachment below is the output git diff. Most of the difference is Cargo.lock but I didn't modify it manually. It is modified by cargo itself.


diff --git a/Cargo.lock b/Cargo.lock
index 0fd97d3..c88bb06 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -1,5 +1,7 @@
 # This file is automatically @generated by Cargo.
 # It is not intended for manual editing.
+version = 3
+
 [[package]]
 name = "ahash"
 version = "0.5.10"
@@ -19,6 +21,15 @@ dependencies = [
  "memchr",
 ]
 
+[[package]]
+name = "ansi_term"
+version = "0.12.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2"
+dependencies = [
+ "winapi 0.3.9",
+]
+
 [[package]]
 name = "anyhow"
 version = "1.0.40"
@@ -39,13 +50,12 @@ checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a"
 
 [[package]]
 name = "bindgen"
-version = "0.55.1"
+version = "0.59.1"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "75b13ce559e6433d360c26305643803cb52cfbabbc2b9c47ce04a58493dfb443"
+checksum = "453c49e5950bb0eb63bb3df640e31618846c89d5b7faa54040d76e98e0134375"
 dependencies = [
  "bitflags",
  "cexpr",
- "cfg-if 0.1.10",
  "clang-sys",
  "lazy_static",
  "lazycell",
@@ -72,14 +82,29 @@ dependencies = [
  "typenum",
 ]
 
+[[package]]
+name = "bitvec"
+version = "0.19.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8942c8d352ae1838c9dda0b0ca2ab657696ef2232a20147cf1b30ae1a9cb4321"
+dependencies = [
+ "funty",
+ "radium",
+ "tap",
+ "wyz",
+]
+
 [[package]]
 name = "bpf-sys"
-version = "1.3.0"
+version = "2.0.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d6a94d0ff7a2b6e821a0e13b38bb8717c20e0f7f59a3ede1c60df9a036ce242c"
 dependencies = [
  "bindgen",
  "cc",
  "glob",
  "libc",
+ "regex",
  "zero",
 ]
 
@@ -103,17 +128,21 @@ checksum = "631ae5198c9be5e753e5cc215e1bd73c2b466a3565173db433f52bb9d3e66dba"
 
 [[package]]
 name = "cargo-bpf"
-version = "1.3.0"
+version = "2.0.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "dc2c300381cb23690689cd745d9b7d77323031bb483268614d7e00347542475b"
 dependencies = [
  "anyhow",
  "bindgen",
  "bpf-sys",
+ "cfg-if 1.0.0",
  "glob",
  "lazy_static",
  "libc",
  "llvm-sys",
  "proc-macro2",
  "quote",
+ "rustversion",
  "syn",
  "tempfile",
  "toml_edit",
@@ -127,9 +156,9 @@ checksum = "e3c69b077ad434294d3ce9f1f6143a2a4b89a8a2d54ef813d85003a4fd1137fd"
 
 [[package]]
 name = "cexpr"
-version = "0.4.0"
+version = "0.5.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "f4aedb84272dbe89af497cf81375129abda4fc0a9e7c5d317498c15cc30c0d27"
+checksum = "db507a7679252d2276ed0dd8113c6875ec56d3089f9225b2b42c30cc1f8e5c89"
 dependencies = [
  "nom",
 ]
@@ -240,20 +269,10 @@ dependencies = [
 ]
 
 [[package]]
-name = "fuchsia-zircon"
-version = "0.3.3"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82"
-dependencies = [
- "bitflags",
- "fuchsia-zircon-sys",
-]
-
-[[package]]
-name = "fuchsia-zircon-sys"
-version = "0.3.3"
+name = "funty"
+version = "1.1.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7"
+checksum = "fed34cd105917e91daa4da6b3728c47b068749d6a62c59811f06ed2ac71d9da7"
 
 [[package]]
 name = "futures"
@@ -413,9 +432,9 @@ dependencies = [
 
 [[package]]
 name = "goblin"
-version = "0.2.3"
+version = "0.4.3"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d20fd25aa456527ce4f544271ae4fea65d2eda4a6561ea56f39fb3ee4f7e3884"
+checksum = "32401e89c6446dcd28185931a01b1093726d0356820ac744023e6850689bf926"
 dependencies = [
  "log",
  "plain",
@@ -441,13 +460,10 @@ dependencies = [
 ]
 
 [[package]]
-name = "iovec"
-version = "0.1.4"
+name = "itoa"
+version = "0.4.8"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b2b3ea6ff95e175473f8ffe6a7eb7c00d054240321b84c57051175fe3c1e075e"
-dependencies = [
- "libc",
-]
+checksum = "b71991ff56294aa922b450139ee08b3bfc70982c6b2c7562771375cf73542dd4"
 
 [[package]]
 name = "kernel32-sys"
@@ -495,9 +511,9 @@ checksum = "7fb9b38af92608140b86b693604b9ffcc5824240a484d1ecd4795bacb2fe88f3"
 
 [[package]]
 name = "llvm-sys"
-version = "110.0.1"
+version = "120.2.1"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "21ede189444b8c78907e5d36da5dabcf153170fcff9c1dba48afc4b33c7e19f0"
+checksum = "b4a810627ac62b396f5fd2214ba9bbd8748d4d6efdc4d2c1c1303ea7a75763ce"
 dependencies = [
  "cc",
  "lazy_static",
@@ -524,6 +540,15 @@ dependencies = [
  "cfg-if 1.0.0",
 ]
 
+[[package]]
+name = "matchers"
+version = "0.0.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f099785f7595cc4b4553a174ce30dd7589ef93391ff414dbb67f62392b9e0ce1"
+dependencies = [
+ "regex-automata",
+]
+
 [[package]]
 name = "membarrier"
 version = "0.2.2"
@@ -551,25 +576,6 @@ dependencies = [
  "autocfg",
 ]
 
-[[package]]
-name = "mio"
-version = "0.6.23"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "4afd66f5b91bf2a3bc13fad0e21caedac168ca4c707504e75585648ae80e4cc4"
-dependencies = [
- "cfg-if 0.1.10",
- "fuchsia-zircon",
- "fuchsia-zircon-sys",
- "iovec",
- "kernel32-sys",
- "libc",
- "log",
- "miow 0.2.2",
- "net2",
- "slab",
- "winapi 0.2.8",
-]
-
 [[package]]
 name = "mio"
 version = "0.7.11"
@@ -578,23 +584,11 @@ checksum = "cf80d3e903b34e0bd7282b218398aec54e082c840d9baf8339e0080a0c542956"
 dependencies = [
  "libc",
  "log",
- "miow 0.3.7",
+ "miow",
  "ntapi",
  "winapi 0.3.9",
 ]
 
-[[package]]
-name = "miow"
-version = "0.2.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ebd808424166322d4a38da87083bfddd3ac4c131334ed55856112eb06d46944d"
-dependencies = [
- "kernel32-sys",
- "net2",
- "winapi 0.2.8",
- "ws2_32-sys",
-]
-
 [[package]]
 name = "miow"
 version = "0.3.7"
@@ -604,17 +598,6 @@ dependencies = [
  "winapi 0.3.9",
 ]
 
-[[package]]
-name = "net2"
-version = "0.2.37"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "391630d12b68002ae1e25e8f974306474966550ad82dac6886fb8910c19568ae"
-dependencies = [
- "cfg-if 0.1.10",
- "libc",
- "winapi 0.3.9",
-]
-
 [[package]]
 name = "nix"
 version = "0.19.1"
@@ -629,10 +612,12 @@ dependencies = [
 
 [[package]]
 name = "nom"
-version = "5.1.2"
+version = "6.1.2"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ffb4262d26ed83a1c0a33a38fe2bb15797329c85770da05e6b828ddb782627af"
+checksum = "e7413f999671bd4745a7b624bd370a569fb6bc574b23c83a3c5ed2e453f3d5e2"
 dependencies = [
+ "bitvec",
+ "funty",
  "memchr",
  "version_check",
 ]
@@ -758,6 +743,12 @@ dependencies = [
  "proc-macro2",
 ]
 
+[[package]]
+name = "radium"
+version = "0.5.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "941ba9d78d8e2f7ce474c015eea4d9c6d25b6a3327f9832ee29a4de27f91bbb8"
+
 [[package]]
 name = "rand"
 version = "0.8.3"
@@ -800,7 +791,9 @@ dependencies = [
 
 [[package]]
 name = "redbpf"
-version = "1.3.0"
+version = "2.0.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "63c518a658d7d6a4fde5b6a33f04dd85542d259c1138fb30d6940d9086707885"
 dependencies = [
  "bindgen",
  "bpf-sys",
@@ -809,7 +802,6 @@ dependencies = [
  "goblin",
  "lazy_static",
  "libc",
- "mio 0.6.23",
  "regex",
  "tokio",
  "tracing",
@@ -818,24 +810,34 @@ dependencies = [
 
 [[package]]
 name = "redbpf-macros"
-version = "1.3.0"
+version = "2.0.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "11595d72361c70b11a4437fe95316850c734c8e1a01c7e6e13e9e90971dcf68e"
 dependencies = [
  "proc-macro2",
  "quote",
  "rustc_version",
  "syn",
+ "uuid",
 ]
 
 [[package]]
 name = "redbpf-probes"
-version = "1.3.0"
+version = "2.0.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "18d0f5b4aa0c3618c00dc6f0c6b7ea40e506cd1ebb214643018c2e96f5eecbbe"
 dependencies = [
+ "anyhow",
+ "bindgen",
+ "bpf-sys",
  "cargo-bpf",
  "cty",
  "glob",
  "quote",
  "redbpf-macros",
  "syn",
+ "tracing",
+ "tracing-subscriber",
  "ufmt",
 ]
 
@@ -859,6 +861,15 @@ dependencies = [
  "regex-syntax",
 ]
 
+[[package]]
+name = "regex-automata"
+version = "0.1.10"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132"
+dependencies = [
+ "regex-syntax",
+]
+
 [[package]]
 name = "regex-syntax"
 version = "0.6.25"
@@ -899,6 +910,18 @@ dependencies = [
  "semver",
 ]
 
+[[package]]
+name = "rustversion"
+version = "1.0.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "61b3909d758bb75c79f23d4736fac9433868679d3ad2ea7a61e3c25cfda9a088"
+
+[[package]]
+name = "ryu"
+version = "1.0.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e"
+
 [[package]]
 name = "scoped-tls"
 version = "1.0.0"
@@ -949,11 +972,37 @@ dependencies = [
  "pest",
 ]
 
+[[package]]
+name = "serde"
+version = "1.0.130"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f12d06de37cf59146fbdecab66aa99f9fe4f78722e3607577a5375d66bd0c913"
+
+[[package]]
+name = "serde_json"
+version = "1.0.68"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0f690853975602e1bfe1ccbf50504d67174e3bcf340f23b5ea9992e0587a52d8"
+dependencies = [
+ "itoa",
+ "ryu",
+ "serde",
+]
+
+[[package]]
+name = "sharded-slab"
+version = "0.1.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "740223c51853f3145fe7c90360d2d4232f2b62e3449489c207eccde818979982"
+dependencies = [
+ "lazy_static",
+]
+
 [[package]]
 name = "shlex"
-version = "0.1.1"
+version = "1.1.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "7fdf1b9db47230893d76faad238fd6097fd6d6a9245cd7a4d90dbd639536bbd2"
+checksum = "43b2853a4d09f215c24cc5489c992ce46052d359b5109343cbafbf26bc62f8a3"
 
 [[package]]
 name = "signal-hook-registry"
@@ -998,6 +1047,12 @@ dependencies = [
  "unicode-xid",
 ]
 
+[[package]]
+name = "tap"
+version = "1.0.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369"
+
 [[package]]
 name = "tempfile"
 version = "3.2.0"
@@ -1012,6 +1067,15 @@ dependencies = [
  "winapi 0.3.9",
 ]
 
+[[package]]
+name = "thread_local"
+version = "1.1.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8018d24e04c95ac8790716a5987d0fec4f8b27249ffa0f7d33f1369bdfb88cbd"
+dependencies = [
+ "once_cell",
+]
+
 [[package]]
 name = "time"
 version = "0.1.43"
@@ -1030,7 +1094,7 @@ checksum = "bd3076b5c8cc18138b8f8814895c11eb4de37114a5d127bafdc5e55798ceef37"
 dependencies = [
  "autocfg",
  "libc",
- "mio 0.7.11",
+ "mio",
  "once_cell",
  "pin-project-lite 0.2.6",
  "signal-hook-registry",
@@ -1092,6 +1156,49 @@ dependencies = [
  "lazy_static",
 ]
 
+[[package]]
+name = "tracing-log"
+version = "0.1.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a6923477a48e41c1951f1999ef8bb5a3023eb723ceadafe78ffb65dc366761e3"
+dependencies = [
+ "lazy_static",
+ "log",
+ "tracing-core",
+]
+
+[[package]]
+name = "tracing-serde"
+version = "0.1.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "fb65ea441fbb84f9f6748fd496cf7f63ec9af5bca94dd86456978d055e8eb28b"
+dependencies = [
+ "serde",
+ "tracing-core",
+]
+
+[[package]]
+name = "tracing-subscriber"
+version = "0.2.20"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b9cbe87a2fa7e35900ce5de20220a582a9483a7063811defce79d7cbd59d4cfe"
+dependencies = [
+ "ansi_term",
+ "chrono",
+ "lazy_static",
+ "matchers",
+ "regex",
+ "serde",
+ "serde_json",
+ "sharded-slab",
+ "smallvec",
+ "thread_local",
+ "tracing",
+ "tracing-core",
+ "tracing-log",
+ "tracing-serde",
+]
+
 [[package]]
 name = "typenum"
 version = "1.13.0"
@@ -1148,6 +1255,15 @@ dependencies = [
  "void",
 ]
 
+[[package]]
+name = "uuid"
+version = "0.8.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "bc5cf98d8186244414c848017f0e2676b3fcb46807f6668a97dfe67359a3c4b7"
+dependencies = [
+ "getrandom",
+]
+
 [[package]]
 name = "version_check"
 version = "0.9.3"
@@ -1207,14 +1323,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
 
 [[package]]
-name = "ws2_32-sys"
-version = "0.2.1"
+name = "wyz"
+version = "0.2.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d59cefebd0c892fa2dd6de581e937301d8552cb44489cdff035c6187cb63fa5e"
-dependencies = [
- "winapi 0.2.8",
- "winapi-build",
-]
+checksum = "85e60b0d1b5f99db2556934e21937020776a5d31520bf169e851ac44e6420214"
 
 [[package]]
 name = "zero"
diff --git a/echo-probe/Cargo.toml b/echo-probe/Cargo.toml
index 427660b..3f51d3b 100644
--- a/echo-probe/Cargo.toml
+++ b/echo-probe/Cargo.toml
@@ -6,8 +6,8 @@ edition = '2018'
 
 [dependencies]
 cty = "0.2"
-redbpf-macros = {version = "1.3", path = "../../redbpf/redbpf-macros", optional = true }
-redbpf-probes = {version = "1.3", path = "../../redbpf/redbpf-probes", optional = true }
+redbpf-macros = {version = "2.0", optional = true }
+redbpf-probes = {version = "2.0", optional = true }
 
 [features]
 default = []
diff --git a/echo/Cargo.toml b/echo/Cargo.toml
index 81ec3b4..01cff0d 100644
--- a/echo/Cargo.toml
+++ b/echo/Cargo.toml
@@ -14,10 +14,10 @@ name = "echo-ebpf"
 path = "src/main_ebpf.rs"
 
 [build-dependencies]
-cargo-bpf = { version = "1.3", path = "../../redbpf/cargo-bpf", default-features = false, features = ["build"] }
+cargo-bpf = { version = "2.0", default-features = false, features = ["build", "llvm12"] }
 
 [dependencies]
 echo-probe = { path = "../echo-probe" }
-redbpf = {version = "1.3", path = "../../redbpf/redbpf", features = ["load"] }
+redbpf = {version = "2.0", features = ["load"] }
 glommio = "0.4.1"
-futures-lite = "1.11.1"
\ No newline at end of file
+futures-lite = "1.11.1"

I can't reproduce your problem in my machine.. But that problem seems not a redbpf related issue. Perhaps I had encountered a similar problem when I failed to upgrade my PopOS... Most of core libraries like libc package was being upgraded but the upgrade procedure aborted in the middle of process. After that I couldn't compile anything..

I am not sure my experience is the thing you have.. but I think your problem is related to low level packages. And for me it is hard to say what the root cause is.

rhdxmr avatar Oct 06 '21 13:10 rhdxmr

@rhdxmr @rsdy I have tried building with versions 2.0.

This is the error we got:

language item required, but not found: `eh_personality`

I have tried adding this to Cargo.toml:

[profile.dev]
panic = "abort" 
[profile.release]
panic = "abort" 

But this causes the "cc linkage error".

I have also tried changing stable build to nightly, so that I can use:

#![feature(lang_items)]

#[lang = "eh_personality"]
extern "C" fn eh_personality() {}

But this doesn't work either.

Using a target like this is in .cargo/config not helping either:

[build]
target = "x86_64-unknown-linux-gnu"

raghu-d32 avatar Oct 11 '21 16:10 raghu-d32

@raghu-d32 Hello

I am worrying that you feel exhausted to try building redbpf.

But I can not suggest what you may try for finding the cause of your problem. Normally redbpf can be compiled in Ubuntu 20 without tricky issue. But you are suffering from strange problems that I had not experienced before while developing redbpf.

So I am showing you the way of using the foniod-build docker image that is used to build redbpf. The image is equipped with rust toolchain, kernel headers and required system packages. So it is ready to build redbpf.

Inside a container, run cargo build command. You can follow the instruction below:

$ cd path/to/redbpf/
$ docker run --privileged -v $PWD:/build -w /build -it ghcr.io/foniod/foniod-build:latest-ubuntu-20.04 /bin/bash
root@c0df25435dbd:/build# ls
Cargo.lock  Cargo.toml  LICENSE-APACHE  LICENSE-MIT  PREAMBLE  README.md  TUTORIAL.md  bpf-sys  cargo-bpf  examples  execsnoop.log  lsp-target  redbpf  redbpf-macros  redbpf-probes  redbpf-tools  rustfmt.toml  scripts  target
root@c0df25435dbd:/build# cargo clean
root@c0df25435dbd:/build# KERNEL_SOURCE=/lib/modules/5.4.0-80-generic/ cargo build --examples

How about trying this? You may refer to scripts/build-test.sh if you want to use other distros.

rhdxmr avatar Oct 12 '21 13:10 rhdxmr

@raghu-d32 Did you solve your problem or find a workaround?

rhdxmr avatar Oct 17 '21 10:10 rhdxmr

I've stumbled across this issue trying to install cargo-bpf and I had the same issue about LLVM_SYS_110_PREFIX on Ubuntu 20.04.3.

I was a little bit concerned that docker container you referred to also installs llvm which looks like llvm 10.0 along with some other packages and this seems to be the reason for llvm-config --version to return version 10.

$ ls -la $(which llvm-config)
lrwxrwxrwx 1 root root 32 Oct 17 16:10 /usr/bin/llvm-config -> /usr/lib/llvm-10/bin/llvm-config

Unfortunately, I couldn't find option in update-alternatives to change default llvm version (I tried updating for llvm and llvm-config), so I changed symlink for llvm-config manually:

$ sudo ln -sf /usr/lib/llvm-12/bin/llvm-config /usr/bin/llvm-config

which resolved the issue for me.

yurykabanov avatar Oct 17 '21 11:10 yurykabanov