Repository: rust
Issue: `tests/ui/asan-odr-win/asan_odr_windows.rs` fails on native `x86_64-pc-windows-msvc` with `lld = true` + `use-lld = true`
Labels: A-linkage,A-testsuite,T-compiler,O-windows-msvc,T-bootstrap,A-sanitizers,C-bug

On:

- Native `x86_64-pc-windows-msvc`
- Latest master at the time of writing, commit hash c528b8c6789

The test [`tests/ui/asan-odr-win/asan_odr_windows.rs`](https://github.com/rust-lang/rust/blob/c528b8c67895bfe7fdcdfeb56ec5bf6ef928dcd7/tests/ui/asan-odr-win/asan_odr_windows.rs) fails for me locally if I set `rust.lld = true` and `rust.use-lld = true` 


```rs
[rust]
lld = true
use-lld = true
```

due to


```
note: lld: error: could not open 'X:\repos\rust\build\x86_64-pc-windows-msvc\stage1\lib\rustlib\x86_64-pc-windows-msvc\lib\librustc-dev_rt.asan.a': no such file or directory
```

Full test failure output:

<details>
<summary>Full test failure</summary>

```
---- [ui] tests\ui\asan-odr-win\asan_odr_windows.rs stdout ----

error: test compilation failed although it shouldn't!
status: exit code: 1
command: PATH="X:\repos\rust\build\x86_64-pc-windows-msvc\stage1\bin;C:\Program Files (x86)\Windows Kits\10\bin\x64;C:\Program Files (x86)\Windows Kits\10\bin\10.0.26100.0\x64;C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.43.34604\bin\HostX64\x64;C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.43.34604\bin\HostX64\x64;X:\repos\rust\build\x86_64-pc-windows-msvc\stage0-bootstrap-tools\x86_64-pc-windows-msvc\release\deps;X:\repos\rust\build\x86_64-pc-windows-msvc\stage0\bin;C:\Program Files\PowerShell\7;C:\Users\Administrator\AppData\Local\Programs\Python\Python312\Scripts\;C:\Users\Administrator\AppData\Local\Programs\Python\Python312\;C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.41.34120\bin\Hostx64\x64\;C:\Program Files\Alacritty\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\dotnet\;C:\Program Files\Meld\;C:\Program Files (x86)\Lua\5.1;C:\Program Files (x86)\Lua\5.1\clibs;C:\Program Files\clang+llvm-18.1.6-x86_64-pc-windows-msvc\bin;C:\Program Files\WireGuard\;C:\Program Files\Mullvad VPN\resources;C:\Program Files\Graphviz\bin;C:\ProgramData\chocolatey\bin;C:\Program Files\Docker\Docker\resources\bin;C:\Program Files\GitHub CLI\;C:\Program Files\Neovim\bin;C:\Program Files\NVIDIA Corporation\NVIDIA app\NvDLISR;C:\Program Files\WezTerm;C:\Program Files\Microsoft VS Code\bin;C:\Program Files\Git\cmd;C:\Program Files\PowerShell\7\;C:\Program Files (x86)\Windows Kits\10\Windows Performance Toolkit\;C:\Users\Administrator\.cargo\bin;C:\Users\Administrator\AppData\Local\Programs\Python\Launcher\;C:\Users\Administrator\AppData\Local\Programs\Python\Python310\Scripts\;C:\Users\Administrator\AppData\Local\Programs\Python\Python310\;C:\Users\Administrator\AppData\Local\Programs\Python\Python312\Scripts\;C:\Users\Administrator\AppData\Local\Programs\Python\Python312\;C:\Users\Administrator\scoop\shims;C:\Users\Administrator\AppData\Local\Microsoft\WindowsApps;C:\Users\Administrator\AppData\Local\GitHubDesktop\bin;C:\Users\Administrator\AppData\Local\Microsoft\WinGet\Packages\ajeetdsouza.zoxide_Microsoft.Winget.Source_8wekyb3d8bbwe;C:\Users\Administrator\AppData\Local\Microsoft\WinGet\Packages\junegunn.fzf_Microsoft.Winget.Source_8wekyb3d8bbwe;C:\Program Files\Neovim\bin;C:\Users\Administrator\AppData\Local\Microsoft\WinGet\Packages\BurntSushi.ripgrep.MSVC_Microsoft.Winget.Source_8wekyb3d8bbwe\ripgrep-14.1.0-x86_64-pc-windows-msvc;C:\Program Files (x86)\Lua\5.1;C:\Program Files (x86)\LuaRocks;C:\Program Files (x86)\Lua\5.1\systree\bin;C:\Users\Administrator\AppData\Local\LuaRocks\bin;C:\Program Files\clang+llvm-18.1.6-x86_64-pc-windows-msvc\bin;C:\Users\Administrator\AppData\Local\Microsoft\WinGet\Links;C:\Program Files\JetBrains\RustRover 2024.2\bin;;C:\Program Files\Git;C:\Program Files (x86)\Windows Kits\10\Debuggers\x64;C:\Users\Administrator\bin" "X:\\repos\\rust\\build\\x86_64-pc-windows-msvc\\stage1\\bin\\rustc.exe" "X:\\repos\\rust\\tests\\ui\\asan-odr-win\\asan_odr_windows.rs" "-Zthreads=1" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "-Z" "ignore-directory-in-diagnostics-source-blocks=C:\\Users\\Administrator\\.cargo" "-Z" "ignore-directory-in-diagnostics-source-blocks=X:\\repos\\rust\\vendor" "--sysroot" "X:\\repos\\rust\\build\\x86_64-pc-windows-msvc\\stage1" "--target=x86_64-pc-windows-msvc" "--check-cfg" "cfg(FALSE)" "-O" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zwrite-long-types-to-disk=no" "-Cstrip=debuginfo" "-C" "prefer-dynamic" "-o" "X:\\repos\\rust\\build\\x86_64-pc-windows-msvc\\test\\ui\\asan-odr-win\\asan_odr_windows\\a.exe" "-A" "internal_features" "-Crpath" "-Cdebuginfo=0" "-Lnative=X:\\repos\\rust\\build\\x86_64-pc-windows-msvc\\native\\rust-test-helpers" "-Clinker=lld" "-L" "X:\\repos\\rust\\build\\x86_64-pc-windows-msvc\\test\\ui\\asan-odr-win\\asan_odr_windows\\auxiliary" "-Zsanitizer=address"
stdout: none
--- stderr -------------------------------
error: linking with `lld` failed: exit code: 1
   |
   = note: "lld" "-flavor" "link" "/NOLOGO" "C:\\Users\\ADMINI~1\\AppData\\Local\\Temp\\rustcEwtKzP\\symbols.o" "/WHOLEARCHIVE:X:\\repos\\rust\\build\\x86_64-pc-windows-msvc\\stage1\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\librustc-dev_rt.asan.a" "<1 object files omitted>" "X:\\repos\\rust\\build\\x86_64-pc-windows-msvc\\test\\ui\\asan-odr-win\\asan_odr_windows\\auxiliary/{libothercrate.rlib}" "X:\\repos\\rust\\build\\x86_64-pc-windows-msvc\\stage1\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\std-972c03a8627cad3b.dll.lib" "X:\\repos\\rust\\build\\x86_64-pc-windows-msvc\\stage1\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib/{libcompiler_builtins-5ad709b9972a6089.rlib}" "kernel32.lib" "kernel32.lib" "advapi32.lib" "ntdll.lib" "userenv.lib" "ws2_32.lib" "dbghelp.lib" "/defaultlib:msvcrt" "C:\\Users\\ADMINI~1\\AppData\\Local\\Temp\\rustcEwtKzP\\api-ms-win-core-synch-l1-2-0.dll_imports_indirect.lib" "C:\\Users\\ADMINI~1\\AppData\\Local\\Temp\\rustcEwtKzP\\bcryptprimitives.dll_imports_indirect.lib" "/NXCOMPAT" "/LIBPATH:X:\\repos\\rust\\build\\x86_64-pc-windows-msvc\\native\\rust-test-helpers" "/LIBPATH:X:\\repos\\rust\\build\\x86_64-pc-windows-msvc\\test\\ui\\asan-odr-win\\asan_odr_windows\\auxiliary" "/OUT:X:\\repos\\rust\\build\\x86_64-pc-windows-msvc\\test\\ui\\asan-odr-win\\asan_odr_windows\\a.exe" "/OPT:REF,ICF" "/DEBUG" "/PDBALTPATH:%_PDB%"
   = note: some arguments are omitted. use `--verbose` to show all linker arguments
   = note: lld: error: could not open 'X:\repos\rust\build\x86_64-pc-windows-msvc\stage1\lib\rustlib\x86_64-pc-windows-msvc\lib\librustc-dev_rt.asan.a': no such file or directory␍


error: aborting due to 1 previous error
------------------------------------------



failures:
    [ui] tests\ui\asan-odr-win\asan_odr_windows.rs
```
</details>

Full `config.toml`:

<details>
<summary>Full `config.toml`</summary>

```
profile = "compiler"
change-id = 999999

[llvm]
#assertions = true
download-ci-llvm = true

[build]
build = "x86_64-pc-windows-msvc"
#profiler = true

[rust]
use-lld = true
lld = true

download-rustc = false
codegen-backends = ["llvm"]
deny-warnings = true
debug = false
debuginfo-level = 1
debug-logging = true
debug-assertions = true
debug-assertions-std = true
```
</details>