-
Notifications
You must be signed in to change notification settings - Fork 474
Possible regression causing linking of proc_macro #1374
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
Comments
I managed to create a simple repro. This is not related to |
Running against that branch I get
for a lot (not all) Rust targets when I apply repository_override to our project |
Thanks! That's the same error, just on macos this time, which is a reminder that we should apply the solution to all platforms. |
Tried this on Linux and there it seems to be no issues when running the branch, so sounds like this is the right fix and just needs to also be done for macos :) |
@scentini Were you able to make any progress with this issue? Thanks! |
Sorry for the delay; I managed to get CI green in the unpolished (and incorrectly named) #1411. I want to try one more approach before I mark it ready for review. The PR will most likely be ready on Monday, as I'm going to be OOO for the next few days. |
@scentini hey, any updates here? |
Hey folks, I have #1500 up for review. |
Fixes #1374 We skip adding `-Clink-arg=-l...` for libstd and libtest from the standard library, as these two libraries are present both as an `.rlib` and a `.so` format. On linux, Rustc adds a -Bdynamic to the linker command line before the libraries specified with `-Clink-arg`, which leads to us linking against the `.so`s but not putting the corresponding value to the runtime library search paths, which results in a "cannot open shared object file: No such file or directory" error at exectuion time. We can fix this by adding a `-Clink-arg=-Bstatic` on linux, but we don't have that option for macos. The proper solution for this issue would be to remove `libtest-{hash}.so` and `libstd-{hash}.so` from the toolchain. However, it is not enough to change the toolchain's `rust_std_{...}` filegroups here: https://github.com/bazelbuild/rules_rust/blob/a9d5d894ad801002d007b858efd154e503796b9f/rust/private/repository_utils.bzl#L144 because rustc manages to escape the sandbox and still finds them at linking time. We need to modify the repository rules to erase those files completely. This PR should be a good workaround until we get do to the proper thing though. This PR also fixes the following issues for Windows: * get_lib_name() didn't work properly on windows for `libc` * `-Clink-arg` should point to the library name with extension included for windows.
After applying this fix I'm still seeing
for one of our use cases on macos (linux is fine). Would you prefer me to open up a new issue to track this? |
We updated rules_rust from 0.4.0 to 28ac6b1 and ran into an issue where proc_macro is now statically linked into a test binary, causing
21eed19...28ac6b1
I made sure that this was not coming from the Rust version upgrade (tried bad sha + 1.60).
I don't have a simple reproducer, though I suspect it's coming from our usage of cxx, though we also make use of other proc_macro libraries such as tokio, thiserror, prost, etc.
The text was updated successfully, but these errors were encountered: