-
Notifications
You must be signed in to change notification settings - Fork 460
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
linking a rust_binary
that depends on two cc_libraries
with the same name fails
#840
Comments
We've got some issues with the approach from #841, rooted in that the relative order of linker args derived from Longer term we hope that the native_link_modifiers rustc RFC rust-lang/rust#81490 will give us the necessary options to preserve the relative order. For now the plan is to logically revert #841, so rules_rust goes back to use |
This reverts rules_rust to use `-Lnative/-lstatic` instead of library paths per bazelbuild#840 (comment).
Add examples for bazelbuild#840.
Depends on bazelbuild#1147. This addresses bazelbuild#840 by creating symlinks to ambiguous native dependencies of a rust_binary that would otherwise cause the link to fail, as in the examples added.
[Linking a rust_binary that depends on two cc_libraries with the same name fails](bazelbuild/rules_rust#840). This bug is breaking cross-compiles of the `enso-cloud` crates. Cause: 1. The `enso-cloud-deploy` crate depends on the `ide-ci` crate. 2. The `ide-ci` crate shares a workspace with `enso-build`. 3. Both `ide-ci` and `enso-build` depend on `octocrab` (this crate). 4. `octocrab` uses `reqwest` with default features enabled. 5. `reqwest`'s default features provide TLS through the `native-tls` crate. 6. The `native-tls` crate depends on `openssl`, which depends on the `libcrypto` and `libssl` native libraries. 7. Depending on `libcrypto`/`libssl` twice breaks the build. This PR switches `octocrab` to using `reqwest` with `rustls` instead of `native-tls`. This removes the `openssl` dependency entirely. Closes https://www.pivotaltracker.com/story/show/182135510.
This depends on #825. In particular, trying out this example without #825 will run into the linker errors described there and this example assumes using at least the beta
rustc
. I'm using Linux with ld.Consider a case where a
rust_binary
(transitively) depends on twocc_library
es that have the same name. In the wild targets with common names likeutils
, orstatus
could occur in unrelated packages.Like in this example where
//same_names:rbin
depends on//same_names/x:exc
and//same_names/y:exc
:Running
bazel build //same_names:rbin
fails with a linker error like:The problem is that the way we construct linker command line arguments for native dependencies doesn't work when they have the same name. For each transitive native dependency, we pass its package directory as
-Lnative=
and its name as-lstatic=
torustc
. These get translated to-Lpackage
and-lname
linker arguments. In the example above, therustc
arguments are like:and get translated as linker arguments like:
Now the problem is that the linker always picks up the first
libexc.a
library that it finds on the path, in this casesame_names/x/libexc.a
, and hence the undefined reference errors for the symbol defined insame_names/y/libexc.a
.The way cc rules deal with this is that they just pass the full path to the library to the linker, AFAIK. I think this is a good way to address this and potentially some other naming incompatibilities across cc and rust rules.
Under the native-link-modifiers RFC, the relative order of
-l
and-Clink-arg(s)
is preserved, so it should be OK to replace the current linker args pattern:with something like:
The text was updated successfully, but these errors were encountered: