-
-
Notifications
You must be signed in to change notification settings - Fork 31
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
krun-sys: find libkrun using pkg-config #147
Conversation
We should investigate whether we can just use https://docs.rs/system-deps/latest/system_deps/ (as seem from rust-lang/rust-project-goals#108 (comment)) |
Wonderful, our CI uses Ubuntu, and
We're going to start using |
println!("cargo::rerun-if-changed=wrapper.h"); | ||
println!("cargo::rustc-link-lib=krun"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm most likely asking out of ignorance here, but https://doc.rust-lang.org/cargo/reference/build-scripts.html#rustc-link-lib says this emits the -l
flag to the compiler.
With this gone, where / how does that happen then? Below we only emit -I
flags, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bindgen doesn't really need to link against the library, it just needs the headers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Uhh... But since this crate is krun-sys
(and specifically https://doc.rust-lang.org/cargo/reference/build-scripts.html#-sys-packages and https://doc.rust-lang.org/cargo/reference/manifest.html#the-links-field), I think it's expected that it'll actually link to libkrun...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But also, I'm confused where the linking to libkrun happens if not here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was also getting very confused by this, because I was seeing the library getting injected at build time. Turns out pkg_config::probe_library("libkrun")?;
also injects (by printing to stdout) parameters to the linker. The documentation of pkg-config
is sparse, at best.
We need this to be able to switch krun-sys to pkg-config. Signed-off-by: Sergio Lopez <slp@redhat.com>
6f2c672
to
471b12c
Compare
471b12c
to
95aaa18
Compare
crates/krun-sys/Cargo.toml
Outdated
@@ -10,6 +10,7 @@ links = "krun" | |||
|
|||
[build-dependencies] | |||
bindgen = { version = "0.69.4", default-features = false } | |||
pkg-config = { version = "0.3" } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should be explicit here and not use default features.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done, thanks.
This enables the use of non-system-wide installations of libkrun by exporting the right PKG_CONFIG_PATH. Signed-off-by: Sergio Lopez <slp@redhat.com>
95aaa18
to
fc82dcd
Compare
This enables the use of non-system-wide installations of libkrun by exporting the right PKG_CONFIG_PATH.