-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Use rust-lld on windows rustdoc in config_fast_builds.toml #13553
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
Use rust-lld on windows rustdoc in config_fast_builds.toml #13553
Conversation
.cargo/config_fast_builds.toml
Outdated
@@ -134,6 +134,7 @@ rustflags = [ | |||
# rustup component add llvm-tools | |||
# ``` | |||
linker = "rust-lld.exe" | |||
rustdocflags = ["-Crust-lld.exe"] |
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'm confused, doesn't -C
just mean a generic codegen option and not the linker specifically? Shouldn't this be something like -Clink-args=-fuse-ld=rust-lld.exe
?
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.
Oops I think I messed up when copying from my local config.toml
(which is probably why I didn't notice it being wrong). It was supposed to be -Clinker=rust-lld.exe
, but I'm not sure what the difference with -Clink-args=-fuse-ld=rust-lld.exe
would be.
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.
-Clink-args=-fuse-ld=rust-lld.exe
is likely a Clang / GCC-only command, so I would just focus on finding the Windows MSVS version.
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've fixed the typo to -Clinker=rust-lld.exe
. -Clink-args=-fuse-ld=rust-lld.exe
doesn't appear to work, maybe -fuse-ld
is an argument specific to GCC and Clang's linker? Here it would be passed to MSVC's linker which I guess doesn't understand it.
I tested using LLD on a MacOS M1 chip, and it was slower. This is due to Apple's default ld64 being faster. I still think it should be kept for Windows, though, due to the performance gains. If possible, could someone test on x86 MacOS and x86 Linux? I'd used: [target.x86_64-apple-darwin]
rustflags = [
# ...
]
rustdocflags = ["-Clink-arg=-fuse-ld=/usr/local/opt/llvm/bin/ld64.lld"]
[target.x86_64-unknown-linux-gnu]
linker = "clang"
rustflags = [
# ...
]
rustdocflags = ["-Clink-arg=-fuse-ld=lld"] # Also try testing the Mold linker, too! |
70985a0
to
67f03ed
Compare
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'm good with these changes, as long as we can test this on Linux and x86 MacOS too. :)
This file is here for Bevy users to set up their own projects, not really for Bevy contributors. Nowhere are they pointed to this file. This should go into the contributor guide rather than here. I doubt we will have a lot of tests available for x86 macs, I'm ok with not mentioning them |
Why does it have an alias for That said, would it make sense to split it into a config for contributors and one for users? |
Because I didn't saw the PR that added that and don't think it should have been merged. This file doesn't have the default name specifically to not be used by Bevy contributors automatically |
I added that feature because I thought |
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.
Even for end users this is a good default imo. At least plugin authors on Windows will be happy about this.
If we find speed improvements for other platforms, we can always add them in follow-up PRs.
@mockersf I agree with @janhohenheim: this is useful for Bevy users directly. Faster doc tests are valuable for library authors, especially since this is a super subtle footgun. |
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've tested this on Windows and I get the following when compiling with dynamic_linking
on 0.14.0-rc.4
:
Test executable failed (exit code: 0xc0000135).
My doctest is as simple as this:
/// ```
/// use bevy::prelude::*;
/// ```
struct Foo;
This error code means "dynamic library not found". I then ran my test again without dynamic_linking
and it runs. As such, introducing this config for Windows is a footgun.
Note that this issue does not pop up when using LLD or mold as a rustdoc linker on Linux and seems to be Windows-specific.
I'd be glad if someone else could check this on their machine as well. If this is also the case for others, I'd vote to only add this flag to non-Windows targets, which probably means closing this PR.
Edit: nvm, I get the same behavior whether or not I have the rustdocflags
on or not. My issue seems to not be related. Still, I'd be happy if someone else ran a doctest with the following config on Windows:
[target.x86_64-pc-windows-msvc]
linker = "rust-lld.exe"
rustdocflags = ["-Clinker=rust-lld.exe"]
rustflags = [
"-Zshare-generics=n",
"-Zthreads=0",
]
Marking this as "Needs Testing:" someone with an x86-64 Windows machine should test the configuration that @janhohenheim used. |
@janhohenheim which nightly version are you using (since you specified nightly-only flags)? Also, are you testing that doctest in isolation (i.e. in its own crate and workspace, without dependencies) or are you testing it from inside Bevy? It would be nice if this was reproducible with a small crate so the root cause can be more easily identified. |
@SkiFire13 nightly 0.18.0 @BD103 turns out my doctest does not run with dynamic linking even when my |
I'm not sure what you're talking about... Could you post the output of
On windows if you enable the |
@SkiFire13 sorry, I was typing Wait, so this snippet here is ignored by tests? # Enable a small amount of optimization in debug mode
[profile.dev]
opt-level = 1
# Enable high optimizations for dependencies (incl. Bevy), but not for our code:
[profile.dev.package."*"]
opt-level = 3 |
That's kinda old, so I guess this is not some new rustc bug.
That applies to the
|
@SkiFire13 that sounds very much like my issue then, thanks. I'll recompile everything with those settings and see if that fixes it. It will take a moment since I've disabled LLD, sccache, etc. for this. |
@SkiFire13 Here's a minimal repo of the issue. Could you confirm whether running |
@janhohenheim I can confirm that this results in the I've also managed to further minimize the issue to remove the dependency on Bevy. You only need a crate depending on a I've also found this rust issue which seems to fit the problem rust-lang/rust#39487. It has been closed in favour of rust-lang/rustup#893, where it's mentioned that the issue is with the stdilb dll not being added to the path when running the test. Indeed if I either add |
@SkiFire13 thanks for the investigation! I'll open a new issue later. We should probably add this info somewhere so that new users don't fall into this trap. Edit: opened up #14129 |
# Objective Running `cargo ci` on Fedora 40 causes a system crash due to many `ld` processes consuming all available memory when performing doc tests. ## Solution This PR extends #13553. - Add reference to #12207 in the CI sections of `CONTRIBUTING.md` and `config_fast_builds.toml`. - Add sample `rustdocflags` configurations for `lld` and `mold` to `config_fast_builds.toml` for Linux. ## Testing Crashing configuration - config.toml ``` [target.x86_64-unknown-linux-gnu] linker = "clang" rustflags = ["-Clink-arg=-fuse-ld=lld"] [alias] ci = "run --package ci --" ``` - Test command `cargo ci` Working configuration - config.toml ``` [target.x86_64-unknown-linux-gnu] linker = "clang" rustflags = ["-Clink-arg=-fuse-ld=lld"] rustdocflags = ["-Clink-arg=-fuse-ld=lld"] [alias] ci = "run --package ci --" ``` - Test command `cargo ci`
Objective
linker
settingSolution
Testing
Note: I avoided changing the settings on Linux and MacOS because I can't test on those platforms. It would be nice if someone could test similar changes there and report so they can be done on all major platforms.