-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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 lld by default on x64 msvc windows #71520
Comments
This comment has been minimized.
This comment has been minimized.
This ought to be a bit more straightforward than using lld with gcc since with MSVC you do conventionally invoke the linker directly, and lld has an Note that you still need a Visual C++ install (they have a smaller "Build Tools for Visual Studio" install that doesn't include the IDE) or maybe just a Windows SDK in order to have the system .lib files it wants to link to. |
Yes, as noted in the main comment (which I update to track current status) the infra is already hooked up here for invoking it. It's just a bit buggy, and requires a more thorough investigation of failure-modes and how we can smooth them over, e.g.:
Once someone's done a quick audit of basic failure modes, we should do some community outreach asking people to test Definitely looking for someone to champion this effort, since my primary goal was just creating more focused initiatives / clarifying the status confusion in the main lld bug. |
Ah, apologies, I did read that comment but must have missed that.
This is a good question but I think the better question is "if you try to use lld-link but don't have Visual C++ installed is it any worse than what happens in the default case without Visual C++ installed?" Currently rustc does try to locate MSVC but will apparently just try its best if it can't find it: rust/src/librustc_codegen_ssa/back/link.rs Line 164 in f8d394e
|
IIRC lld-link errors listing all Windows SDK libraries it cannot find.
You cannot cross-compile to MSVC from other OSes unless you find a way to extract Windows SDK and feed it to the LLD. AFAIK MinGW with |
Cross-compiling to Windows is not much different than any other OS these days now that LLVM has good support for generating Windows binaries. You do need all the import libs from MSVC at the very least, and probably a Windows SDK for anything non-trivial, but you can absolutely do it: Given that requirement it's probably not worth really worrying about as long as it doesn't error in a way that's any more confusing than trying to cross-compile to Windows without specifying an alternate linker. That fails like this for me on Linux with Rust 1.42.0:
Once #58713 is fixed it is probably worth revisiting that topic since it'll become feasible to write pure-Rust descriptions of Windows import libraries and generate working binaries without having MSVC or a Windows SDK. |
If Rust is already shipping an
This definitely bears some investigation but I suspect it's not a terribly big deal in practice. The LLVM docs about building clang for use in Visual Studio say "Any system that can adequately run Visual Studio 2017 is fine". The Visual Studio 2017 System Requirements documentation says it supports Windows 7 SP1 or newer.
Given that both Firefox and Chrome use |
The issue says "To test using rust-lld for msvc targets, use -C linker=lld". Shouldn't it be
|
|
It looks like all the known issues with lld for this target have been fixed! 🎉 Shall we look into flipping it on by default? |
FWIW, lld-link has problems running on Windows 7. https://bugzilla.mozilla.org/show_bug.cgi?id=1699228 |
@glandium Apparently only for some build jobs or maybe for some versions of LLD? I'm using it on Windows 7 without running into that issue. |
Yeah, apparently the problem is not happening with the build from llvm.org. |
@glandium I'm using the build that rustup installs. |
Chromium had the same issue on Windows 7 as Firefox, and their answer was that building requires Windows 10. I don't want to be harsh on people with older hardware, but mainstream support for Windows 7 ended before Rust 1.0 even released, and extended support ended over a year ago... I suspect that LLVM itself will stop supporting Windows 7 within the next year, if their deprecation timeline of Windows XP was any indication. |
The firefox lld-link problems mentioned in the comment above (#71520 (comment)) sound extremely similar to those we've had in rust in #81051. I don't have the time to test it right now, but if - as per @AndreKR - things are working currently, then i'm cautiously optimistic that they would keep working in the short-medium term as well. |
Well, there is another one last time I tried:
Looks like |
#85642 is now resolved in nightly (Rust 1.60.0). |
Visited during T-compiler backlog bonanza. The work that @lqd is doing for rust-lang/compiler-team#510 are partly blocking this, but I am also not sure whether there are other blocking issues. (It sounds like #81408 may be a blocking issue, for example.) (Furthermore, we are not certain we even will want lld to be the default on x64 msvc windows.) @rustbot label: S-tracking-needs-summary |
link.exe performance seems to have improved a lot in VS2019 and VS2022. in some unscientific testing, i'm not seeing gains from switching to rust-lld.exe. |
What are the arguments against having lld as default on windows? To me just the better cross compilation support and getting rid of the need to manually install the MSVC toolchain just for the linker seem like they make lld the preferred choice. |
Not only install, but also buy because MSVC toolchain isn't free under certain circumstances. Is |
MSVC provides more than the linker and Windows SDK. It also provides the C runtime (e.g. startup code), core functions such as memcpy, memcmp, etc as well as the panic handling runtime. Perhaps these all could be replaced but as it stands simply switching out the linker doesn't remove the dependency on MSVC. |
I'm on Windows 10 x64 with: If I open a Rust project and change a simple char in code (eg: a variable value from 1 to 2) it re-builds the project (using watchexec) in 12 seconds. I installed
After a So no change with or without LLD. Can you confirm or am I wrong? How to get faster incremental (development) builds? |
It might be better to test this using larger projects like RustPython or even Servo? |
I found a new STATUS_ACCESS_VIOLATION with MSVC+LLD+thinLTO (in both debug and release builds of rend3), haven't tried to narrow the scope down yet. (on both 1.69 stable and 1.71 nightly) |
If I understand correctly from the discussion above, using lld by default is close to being the reality and now it's a question of stability checks and some polishing.
|
Create a In case of Windows it's:
|
With #111480 fixed, it looks like all the blocking issues are now fixed. Unless anyone knows of other issues that are not tracked here. |
This is a metabug, constraining the unbound scope of #39915.
What is lld
A linker that's part of the llvm project, which is desirable for two reasons:
Rust currently ships its own copy of lld which it calls rust-lld. This is used by default to link bare-metal targets and wasm.
Goal
The goal of this metabug is to use rust-lld by default when targeting x64 msvc windows (as opposed to e.g. mingw windows). It's possible this will incidentally get other windows targets working, but I'm constraining scope for the sake of focusing efforts.
This configuration is already in a decent state, with backend support already implemented. It's just a matter of making that configuration stable enough to use by default.
To test using rust-lld for msvc targets, use
-C linker=lld
Blocking Issues
lld on windows status page
rust-lld
does not support the MSVCmanifestdependency
.drectve
#85642 - Windows rust-lld does not support the MSVC manifestdependency .drectveThe text was updated successfully, but these errors were encountered: