Skip to content

failure linking module perf_event template in bpf-linker #217

@kzall0c

Description

@kzall0c

Following the README guide, you need to install bpf-linker on the aarch64 environment as follows.

Right, I've been tested aya-rs on my Apple M2 VMware Fusion Eenvironment with Fedora 40.

$ uname -a
Linux fedora 6.11.0-0.rc1.20240729gitdc1c8034e31b.16.fc41.aarch64+debug #1 SMP PREEMPT_DYNAMIC Tue Jul 30 05:03:16 KST 2024 aarch64 GNU/Linux

I have confirmed that this works well with the XDP template.

If your target is aarch64-unknown-linux-gnu (i.e. Linux on Apple Silicon) you will have to use the external LLVM method.

So, I build with external LLVM method option.

$ cargo install bpf-linker --no-default-features

But, there seems to be error: failure linking module /home/paran/perf-aya-rs/perf-aya-rs-ebpf/../target/bpfel-unknown-none/debug/deps/perf_aya_rs-58caae9717f08677.perf_aya_rs.4b0d608d0cf878c2-cgu.0.rcgu.o

This is my log when linking failed.

$ cargo generate https://github.com/aya-rs/aya-template
⚠️   Favorite `https://github.com/aya-rs/aya-template` not found in config, using it as a git repository: https://github.com/aya-rs/aya-template
🤷   Project Name: perf-aya-rs
🔧   Destination: /home/paran/perf-aya-rs ...
🔧   project-name: perf-aya-rs ...
🔧   Generating template ...
✔ 🤷   Which type of eBPF program? · perf_event
🔧   Moving generated files into: `/home/paran/perf-aya-rs`...
🔧   Initializing a fresh Git repository
✨   Done! New project created /home/paran/perf-aya-rs

$ cd perf-aya-rs/
$ cargo xtask build-ebpf
   ...
   Compiling xtask v0.1.0 (/home/paran/perf-aya-rs/xtask)
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 45.50s
     Running `target/debug/xtask build-ebpf`
   ...
   Compiling core v0.0.0 (/home/paran/.rustup/toolchains/nightly-aarch64-unknown-linux-gnu/lib/rustlib/src/rust/library/core)
   ...
   Compiling rustc-std-workspace-core v1.99.0 (/home/paran/.rustup/toolchains/nightly-aarch64-unknown-linux-gnu/lib/rustlib/src/rust/library/rustc-std-workspace-core)
   ...
   Compiling perf-aya-rs-common v0.1.0 (/home/paran/perf-aya-rs/perf-aya-rs-common)
   Compiling aya-log-ebpf v0.1.0
   Compiling perf-aya-rs-ebpf v0.1.0 (/home/paran/perf-aya-rs/perf-aya-rs-ebpf)
error: linking with `bpf-linker` failed: exit status: 2
  |
  = note: LC_ALL="C" PATH="/home/paran/.rustup/toolchains/nightly-aarch64-unknown-linux-gnu/lib/rustlib/aarch64-unknown-linux-gnu/bin:/home/paran/.rustup/toolchains/nightly-aarch64-unknown-linux-gnu/lib/rustlib/aarch64-unknown-linux-gnu/bin:/home/paran/.rustup/toolchains/nightly-aarch64-unknown-linux-gnu/lib/rustlib/aarch64-unknown-linux-gnu/bin:/home/paran/.cargo/bin:/home/paran/.local/bin:/home/paran/bin:/usr/lib64/ccache:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/home/paran/bin:/home/paran/usr/bin:/home/paran/bin:/home/paran/usr/bin" VSLANG="1033" "bpf-linker" "--export-symbols" "/tmp/rustcW2rljA/symbols" "/tmp/rustcW2rljA/symbols.o" "/home/paran/perf-aya-rs/perf-aya-rs-ebpf/../target/bpfel-unknown-none/debug/deps/perf_aya_rs-58caae9717f08677.perf_aya_rs.4b0d608d0cf878c2-cgu.0.rcgu.o" "--cpu" "generic" "-o" "/home/paran/perf-aya-rs/perf-aya-rs-ebpf/../target/bpfel-unknown-none/debug/deps/perf_aya_rs-58caae9717f08677" "-O3" "--debug"
  = note: error: failure linking module /home/paran/perf-aya-rs/perf-aya-rs-ebpf/../target/bpfel-unknown-none/debug/deps/perf_aya_rs-58caae9717f08677.perf_aya_rs.4b0d608d0cf878c2-cgu.0.rcgu.o

error: could not compile `perf-aya-rs-ebpf` (bin "perf-aya-rs") due to 1 previous error
thread 'main' panicked at xtask/src/build_ebpf.rs:65:5:
assertion failed: status.success()
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Do you know anyone who could help with this, or could you provide some hints for debugging it myself?

I think it would be great if I could looking into it and contribute to this issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions