-
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
Do not pass native libraries to rlib compilations #576
Conversation
483943f
to
5671cd4
Compare
When creating an rlib artifact, rustc will open every native static library and "copy" its contents into the rlib. This results in a quadratic disk usage growth and that's not necessary for rules_rust because we track native dependencies are we can safely pass them to the final linking actions. This fixes the build failure when a native dep is actually a linker script. Rustc will try to open the linker script as if it was a static archive, and then fail the build. Creating shared library artifacts (dylib, cdylib) and binaries is not affected, for those rustc uses the linker, and linker will consume the linker script just fine. Rustc won't try to open/interpret the linker script itself. This also unblocks bazelbuild#562.
5671cd4
to
757510f
Compare
CC @UebelAndre @dfreese feel free to add yourselves as reviewers :) |
if ctx.attr.crate: | ||
# Target is building the crate in `test` config | ||
# Build the test binary using the dependency's srcs. | ||
crate = ctx.attr.crate[rust_common.crate_info] | ||
target = rust_common.crate_info( | ||
name = crate_name, | ||
type = crate.type, | ||
type = crate_type, |
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.
Should this assert that crate.type == "bin"
?
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 don't think so? Crate under test can be a rust_library with crate type rlib or pretty much any other, it's only the test that will be "bin" in any case.
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.
This seems good to me but only have the bandwidth right now for a high level review. 😅
Oki, will merge now, feel free to review afterwards, I'm happy to address any feedback you might have. 🙇 |
When creating an rlib artifact, rustc will open every
native static library and "copy" its contents into the rlib. This
results in a quadratic disk usage growth and that's not necessary for
rules_rust because we track native dependencies and therefore we can pass
them to the final linking actions.
This fixes the build failure when a native dep is actually a linker
script. Rustc will try to open the linker script as if it was a static
archive, and then fail the build.
Creating shared library artifacts (dylib, cdylib) and binaries is not
affected, for those rustc uses the linker, and linker will consume the
linker script just fine. Rustc won't try to open/interpret the linker
script itself.
This also unblocks #562.