-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
rust: Use --print native-static-libs
to collect dependencies of staticlib library targets
#11789
Comments
I'm wondering if we could get away with doing that only once when doing rustc sanity checks with an empty lib.rs. Other than the few libs needed for Rust std, Meson already knows all dependencies. |
I don't think so. Theoretically this should be based on what is actually used by the code, but that doesn't seem to be the case right now. So for example if you had #[no_mangle]
pub extern "C" fn my_staticlib_add(left: i32, right: i32) -> i32 {
unsafe {
g_free(0 as _);
}
left + right
}
#[link(name = "glib-2.0")]
extern "C" {
fn g_free(p: *mut ());
} then it should print |
@sdroege but to compile that code you have to do |
@xclaesse Maybe a bad example. Instead of GLib, think of some Windows system library in that place. You wouldn't have a meson dependency for that as it's always available anyway. |
As discussed on IRC the main problem here is that meson requires this information at configure time, but printing this information happens as part of actually building the target. So the best way forward here for now would be
|
Is this not solved by #11790? |
Not fully. That PR only adds the libraries used by the rust standard library, not those depended on using |
Hmm. Wouldn't that be equally well handled by moving build configuration out of source code pragmas (MSVC says hi!) and into |
There are cases wher rustc needs |
Currently meson requires listing dependencies of staticlib library targets manually, which is error prone at best. The correct way would be to let
rustc
provide these dependencies via the--print native-static-libs
commandline parameter.Unfortunately this requires putting a wrapper around
rustc
for this case and parsing something fromstdout
. Also unfortunately it's placed in between any other output.The output is for example
The text was updated successfully, but these errors were encountered: