-
Notifications
You must be signed in to change notification settings - Fork 406
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
rustc-link-search parameters are not propagated to dependent crates #859
Comments
This is not an area I know well, so I can only guess here - but maybe rustc-link-search should be propagated transitively, but not rustc-link-lib? If that is the case, it will be a little tricky, as currently cargo_build_script_runner lumps them all in together into link_flags. https://doc.rust-lang.org/cargo/reference/build-scripts.html#cargorustc-link-libkindname |
Here's an example with the sentry crate https://github.com/djmarcin/sentry-repro. It could probably be reduced more, but I'm not certain why other sys crates don't seem to be showing the same issue. The example also builds with cargo, and when building with I suspect there may be something amiss with how the sentry-contrib-native crate is being compiled / linked against the sentry-contrib-native-sys crate, since the missing symbols seem to come from sentry-contrib-native code. |
I was able to get this to succeed by patching the My uninformed guess is that the rlib has some embedded info that it needs the "sentry" library to be linked and cargo passes along the link path so when rustc attempts to link "sentry" it finds it on the propagated link path, whereas because bazel is not propagating the link path, it's not found. Does this sound right? |
Adds a new `link_search_paths: File` field to `BuildInfo` provider. Resolves #859 I use native Windows bindings through [windows-rs](https://github.com/microsoft/windows-rs) crate and it fails to link without propagating the link search path to a platform-dependent native library. The bindings call for a native library via `#[link(name = "windows")]` and propagate search path by a buildscript from a dependency (i.e. a transitive dependency for a root crate). Propagating link search paths seems to be what is cargo doing.
I'm trying to use the https://crates.io/crates/sentry-contrib-native crate which in turn depends on https://crates.io/crates/sentry-contrib-native-sys which has a build.rs that adds a rustc-link-search param. This parameter is correctly present in
bazel-out/k8-fastbuild/bin/external/raze__sentry_contrib_native_sys__0_3_1/sentry_contrib_native_sys_build_script.linkflags
but compilation eventually fails because therust_binary
that transitively depends onsentry-contrib-native-sys
does not pick up the flag-L=${pwd}/bazel-out/k8-fastbuild/bin/external/raze__sentry_contrib_native_sys__0_3_1/sentry_contrib_native_sys_build_script.out_dir/lib
, but it does seem to pick up the-lsentry
,-lcrashpad_client
, etc which can't be founds with out the-L
flag.It seems like this flag needs to be propagated up through transitive dependencies to the target that gets linked.
The text was updated successfully, but these errors were encountered: