foniod / redbpf

Rust library for building and running BPF/eBPF modules
Apache License 2.0
1.71k stars 136 forks source link

nix: Various improvements. #321

Closed jsoo1 closed 2 years ago

jsoo1 commented 2 years ago

To fix flake setups in settings where the nixpkgs revision has not been fetched yet.

jsoo1 commented 2 years ago

There is another issue I've run into which I think could be a bug (?). nix build -L in this project gets:

cargo-bpf> building
cargo-bpf> cargo build $cargo_release -j "$NIX_BUILD_CORES" --message-format=$cargo_message_format
cargo-bpf>    Compiling getrandom v0.2.6
cargo-bpf>    Compiling cargo-bpf v2.3.0 (/build/d9gsyrv5np02k6103xap0hvf29m0ph39-source/cargo-bpf)
cargo-bpf>    Compiling redbpf-macros v2.3.0 (/build/d9gsyrv5np02k6103xap0hvf29m0ph39-source/redbpf-macros)
cargo-bpf>    Compiling bpf-sys v2.3.0 (/build/d9gsyrv5np02k6103xap0hvf29m0ph39-source/bpf-sys)
cargo-bpf>    Compiling uuid v0.8.2
cargo-bpf> error: failed to run custom build command for `bpf-sys v2.3.0 (/build/d9gsyrv5np02k6103xap0hvf29m0ph39-source/bpf-sys)`
cargo-bpf> Caused by:
cargo-bpf>   process didn't exit successfully: `/build/d9gsyrv5np02k6103xap0hvf29m0ph39-source/target/release/build/bpf-sys-9bbf30d6f29dde00/build-script-build` (exit status: 101)
cargo-bpf>   --- stderr
cargo-bpf>   bindings.h:1:10: fatal error: 'btf.h' file not found
cargo-bpf>   bindings.h:1:10: fatal error: 'btf.h' file not found, err: true
cargo-bpf>   thread 'main' panicked at 'Unable to generate bindings: ()', bpf-sys/build.rs:23:10
cargo-bpf>   note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
cargo-bpf> warning: build failed, waiting for other jobs to finish...
cargo-bpf> error: build failed
cargo-bpf> [naersk] cargo returned with exit code 101, exiting
error: builder for '/nix/store/n6rpv034w12q2zaqpbrb436fldfz1azr-cargo-bpf-3.0.0.drv' failed with exit code 101;
       last 10 log lines:
       > Caused by:
       >   process didn't exit successfully: `/build/d9gsyrv5np02k6103xap0hvf29m0ph39-source/target/release/build/bpf-sys-9bbf30d6f29dde00/build-script-build` (exit status: 101)
       >   --- stderr
       >   bindings.h:1:10: fatal error: 'btf.h' file not found
       >   bindings.h:1:10: fatal error: 'btf.h' file not found, err: true
       >   thread 'main' panicked at 'Unable to generate bindings: ()', bpf-sys/build.rs:23:10
       >   note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
       > warning: build failed, waiting for other jobs to finish...
       > error: build failed
       > [naersk] cargo returned with exit code 101, exiting
jsoo1 commented 2 years ago
$ nix --version
nix (Nix) 2.5.1
jsoo1 commented 2 years ago

Also:

$ nix build github:foniod/redbpf#defaultPackage.x86_64-linux
error: builder for '/nix/store/7q9jl4j6rc8a2l91pl9rqrqxbd6zx5mq-cargo-bpf-3.0.0.drv' failed with exit code 101;
       last 10 log lines:
       > Caused by:
       >   process didn't exit successfully: `/build/zphbmp0mmg457hnwij8iff3d93w26z4z-source/target/release/build/bpf-sys-c6e91f54233b0c77/build-script-build` (exit status: 101)
       >   --- stderr
       >   bindings.h:1:10: fatal error: 'btf.h' file not found
       >   bindings.h:1:10: fatal error: 'btf.h' file not found, err: true
       >   thread 'main' panicked at 'Unable to generate bindings: ()', bpf-sys/build.rs:23:10
       >   note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
       > warning: build failed, waiting for other jobs to finish...
       > error: build failed
       > [naersk] cargo returned with exit code 101, exiting
       For full logs, run 'nix log /nix/store/7q9jl4j6rc8a2l91pl9rqrqxbd6zx5mq-cargo-bpf-3.0.0.drv'.
jsoo1 commented 2 years ago

I think the btf.h failure is https://github.com/nix-community/naersk/issues/230

rsdy commented 2 years ago

@jsoo1 Yes, btf.h is due to submodule pain. I have not really found a way to resolve that one, therefore CI handles recursive checkout independently.

rsdy commented 2 years ago

@jsoo1 In order to be able to merge this, I'm going to need you to adhere to our DCO policy. Please force-push signed-off commits to this branch, otherwise all this is ready to go. Thanks so much!

jsoo1 commented 2 years ago

Ok, done. Thank you!

rsdy commented 2 years ago

@jsoo1 your latest push seems to have removed the flake.nix changes, causing the nix builds to fail completely.

jsoo1 commented 2 years ago

Oops, sorry!

jsoo1 commented 2 years ago

(The sign-offs are for the same person, just work vs home person)