-
Notifications
You must be signed in to change notification settings - Fork 13.3k
rustc: Globally lock link.exe on 32-bit MSVC #33155
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
Conversation
Looks like `link.exe` can't be called in parallel when it is targeting 32-bit. There's some weird complications with `mspdbsrv.exe` which can't seem to be worked around. Instead, let's just globally lock all invocations of the linker to ensure there's only one linker running at a time. For more detail, see the comments in the commit itself. Closes rust-lang#33145
r? @jroesch (rust_highfive has picked a reviewer for you, use r? to override) |
r? @brson |
@bors r+ p=2 |
📌 Commit 95cc51d has been approved by |
⌛ Testing commit 95cc51d with merge 8fd45ae... |
💔 Test failed - auto-win-msvc-32-opt |
Well that answers the question of "does this fix the problem" |
So if the issue isn't parallel linker invocations, then what the heck is it? |
Are we sure that So perhaps then the problem is |
Can |
Yeah this is my suspicion now as well. With locking I was able to reproduce the RPC error locally with the same test script above. It was quite sporadic, though, so hard to see. I remember that Cargo has run into bugs like this as well (weird issues with mspdbsrv.exe). Specifically after link.exe has finished it looked like sometimes mspdbsrv.exe remains alive and keeps files open (e.g. preventing deletion of them). The next thing to try would be job objects (kill link.exe and its entire process tree when link.exe exits), but unfortunately our bots aren't on a version of Windows that supports nested job objects and the entire build is already in a job object. That and job objects are also complicated. |
What happens if you set Alternatively, and this really isn't optimal, but perhaps adding a 1 second sleep after we acquire the lock but before we execute link? |
Attempting again I cannot reproduce the error with locking added. After thousands of runs no linker invocation failed with the same PDB error (now I'm second guessing whether I could reproduce it before). I've been testing with a custom linker, however, which has the locking injected, so I'm now trying to build this branch from source and I'll run tests using that to see what happens. I haven't tested the msbuild env var yet (as I haven't reproduced with locking), but I'd be very surprised if it worked as we're not using msbuild at all... |
Turns out concurrency was a red herring (full explanation), so closing. |
Looks like
link.exe
can't be called in parallel when it is targeting 32-bit.There's some weird complications with
mspdbsrv.exe
which can't seem to beworked around. Instead, let's just globally lock all invocations of the linker
to ensure there's only one linker running at a time.
For more detail, see the comments in the commit itself.
Closes #33145