Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

examples/rust: Store skeletons in $OUT_DIR #248

Merged
merged 2 commits into from
Jan 22, 2024

Conversation

danielocfb
Copy link

Store skeletons in $OUT_DIR as opposed to .output, which is kind of the proper thing to do (though it certainly doesn't help discoverability...) and it is more in line with how examples in libbpf-rs work. Also remove the "there is hope!" comments, because even with rust-lang/rust#83366 resolved we still cannot use the concat! macro in #[path = ...] attributes. All hope is lost.

Store skeletons in $OUT_DIR as opposed to .output, which is kind of the
proper thing to do (though it certainly doesn't help
discoverability...) and it is more in line with how examples in
libbpf-rs work. Also remove the "there is hope!" comments, because even
with rust-lang/rust#83366 resolved we still
cannot use the concat! macro in #[path = ...] attributes. All hope is
lost.

Signed-off-by: Daniel Müller <deso@posteo.net>
The example need to include the correct vmlinux.h header for the current
architecture if they aim to build on arches other than x86. Adjust the
logic accordingly.

Fixes: libbpf#247

Signed-off-by: Daniel Müller <deso@posteo.net>
Copy link
Member

@anakryiko anakryiko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think it's possible to support something like that in libbpf-cargo itself, so that users don't have to duplicate this logic all the time?

Either way, landing as it is an improvement that fixes a real problem, thanks!

@anakryiko anakryiko merged commit 37d0f37 into libbpf:master Jan 22, 2024
12 checks passed
@danielocfb danielocfb deleted the topic/out-dir branch January 22, 2024 20:01
@danielocfb
Copy link
Author

Do you think it's possible to support something like that in libbpf-cargo itself, so that users don't have to duplicate this logic all the time?

I thought about it, but it's not clear to me how that would be possible in a generic fashion. It would probably mean that we'd have to ship the headers ourselves, which is ugly. The cleanest solution would be to unconditionally extract the header from BTF, which has its own downsides. It's going to be a mess either way, it seems.

@anakryiko
Copy link
Member

I thought about it, but it's not clear to me how that would be possible in a generic fashion. It would probably mean that we'd have to ship the headers ourselves, which is ugly. The cleanest solution would be to unconditionally extract the header from BTF, which has its own downsides. It's going to be a mess either way, it seems.

All that seems like an overkill, agreed. I think for libbpf-bootstrap we should just create directory symlinks to match Rust's ARCH values, and avoid those matches.

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

Successfully merging this pull request may close these issues.

3 participants