Skip to content
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

tests/ui/asan-odr-win/asan_odr_windows.rs fails on native x86_64-pc-windows-msvc with lld = true + use-lld = true #135013

Open
jieyouxu opened this issue Jan 2, 2025 · 12 comments
Labels
A-linkage Area: linking into static, shared libraries and binaries A-sanitizers Area: Sanitizers for correctness and code quality A-testsuite Area: The testsuite used to check the correctness of rustc C-bug Category: This is a bug. O-windows-msvc Toolchain: MSVC, Operating system: Windows T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@jieyouxu
Copy link
Member

jieyouxu commented Jan 2, 2025

On:

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

The test tests/ui/asan-odr-win/asan_odr_windows.rs fails for me locally if I set rust.lld = true and rust.use-lld = true

[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:

Full test failure
---- [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

Full config.toml:

Full `config.toml`
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
@jieyouxu jieyouxu added A-linkage Area: linking into static, shared libraries and binaries A-sanitizers Area: Sanitizers for correctness and code quality A-testsuite Area: The testsuite used to check the correctness of rustc C-bug Category: This is a bug. O-windows-msvc Toolchain: MSVC, Operating system: Windows T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jan 2, 2025
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Jan 2, 2025
@jieyouxu jieyouxu removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Jan 2, 2025
@Kobzol
Copy link
Contributor

Kobzol commented Jan 3, 2025

Does it work if you enable profiler and sanitizers in the build section?

@jieyouxu
Copy link
Member Author

jieyouxu commented Jan 3, 2025

It does not. Without setting the lld flags, I didn't even set profiler or sanitizers flags in [build] and the test passes. FTR, this is what I am using

profile = "compiler"
change-id = 999999

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

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

[rust]
lld = true
use-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

@jieyouxu
Copy link
Member Author

jieyouxu commented Jan 3, 2025

(Only this one UI test seems to fail, all other ui tests that are not ignored passes)

@jieyouxu
Copy link
Member Author

jieyouxu commented Jan 3, 2025

Oh wait, it's looking for

X:\repos\rust\build\x86_64-pc-windows-msvc\stage1\lib\rustlib\x86_64-pc-windows-msvc\lib\librustc-dev_rt.asan.a

but I only have

    Directory: X:\repos\rust\build\x86_64-pc-windows-msvc\stage1\lib\rustlib\x86_64-pc-windows-msvc\lib

Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
d----          2025-01-03    19:32                self-contained
-a---          2025-01-03    01:39        6828882 liballoc-20968203328d1704.rlib
-a---          2025-01-03    01:39          11888 libcfg_if-01a7c284795f8145.rlib
-a---          2025-01-03    01:39        5284166 libcompiler_builtins-4cd15aec64fa8431.rlib
-a---          2025-01-03    01:39       55622808 libcore-380cd1c16ba01c76.rlib
-a---          2025-01-03    01:39        1152084 libgetopts-0ac5d39dfab69402.rlib
-a---          2025-01-03    01:39        1613718 libhashbrown-12b5c59a4886a3e9.rlib
-a---          2025-01-03    01:39          13486 libpanic_abort-a8e9f56fab38501d.rlib
-a---          2025-01-03    01:39          61308 libpanic_unwind-62fdbdab8edfd04d.rlib
-a---          2025-01-03    01:39        5205508 libproc_macro-9975228316ccd304.rlib
-a---          2025-01-03    01:39         389674 librustc_demangle-ed30e0527d068991.rlib
-a---          2025-01-03    01:39           7548 librustc_std_workspace_alloc-c645cdeb55906113.rlib
-a---          2025-01-03    01:39          10522 librustc_std_workspace_core-966a566fca5c8080.rlib
-a---          2025-01-03    01:39          12006 librustc_std_workspace_std-02740d92432969e8.rlib
-a---          2025-01-03    01:39         535298 libstd_detect-b601c00978df310b.rlib
-a---          2025-01-03    01:39       16876160 libstd-cc2542fc5ed34eb4.rlib
-a---          2025-01-03    01:39           8250 libsysroot-c9df1b806092c41d.rlib
-a---          2025-01-03    01:39        8907020 libtest-4569dbf46342a795.rlib
-a---          2025-01-03    01:39         879598 libunicode_width-9cf3e22f337fab67.rlib
-a---          2025-01-03    01:39          13330 libunwind-848f770520458b32.rlib
-a---          2025-01-03    01:38           7680 libwindows_targets-981f3ae07d300caf.rlib
-a---          2025-01-03    01:39        9838080 std-cc2542fc5ed34eb4.dll
-a---          2025-01-03    01:39         923840 std-cc2542fc5ed34eb4.dll.lib
-a---          2025-01-03    01:39        7376896 std-cc2542fc5ed34eb4.pdb

@jieyouxu
Copy link
Member Author

jieyouxu commented Jan 3, 2025

Actually, I think this test just never works or something... e.g. https://rust-lang.zulipchat.com/#narrow/channel/182449-t-compiler.2Fhelp/topic/rustc.20asan/near/237867547

Bootstrap is not building ASAN runtime on Windows currently. Take a look at supported_sanitizers in src/bootstrap/native.rs if you would like to change that.

But that message was from May 2021, not sure if still true.

@jieyouxu
Copy link
Member Author

jieyouxu commented Jan 3, 2025

There's something in bootstrap which seems to address this

// Special setup to enable running with sanitizers on MSVC.
if !builder.config.dry_run()
&& target.contains("msvc")
&& builder.config.sanitizers_enabled(target)
{

@jieyouxu

This comment has been minimized.

@jieyouxu

This comment has been minimized.

@Kobzol
Copy link
Contributor

Kobzol commented Jan 3, 2025

I don't think that builder.cc should be overwritten based on the lld config value. I guess that you could print the cc path before this line to see where it points to.

@jieyouxu
Copy link
Member Author

jieyouxu commented Jan 3, 2025

(I'll probably revisit this in a few days as I'm working on other things, this is not a major blocker since this requires lld + use-lld on msvc, only wanted to note that this is a thing)

@jieyouxu
Copy link
Member Author

jieyouxu commented Jan 3, 2025

I don't think that builder.cc should be overwritten based on the lld config value. I guess that you could print the cc path before this line to see where it points to.

You're right, it's indeed still cl.exe:

before asan_runtime_path: builder.cc = "C:\\Program Files (x86)\\Microsoft Visual Studio\\2022\\BuildTools\\VC\\Tools\\MSVC\\14.43.34604\\bin\\HostX64\\x64\\cl.exe"

@jieyouxu
Copy link
Member Author

jieyouxu commented Jan 3, 2025

Hmm, based on librustc-dev_rt.asan.a, isn't that a static library name on linux? Windows static libs have .lib ext, e.g. the clang ASAN rt shipped next to cl.exe is

-a---          2024-11-17    00:01        1247288 clang_rt.asan_dbg_dynamic-x86_64.dll
-a---          2024-11-17    00:01        5296128 clang_rt.asan_dbg_dynamic-x86_64.pdb
-a---          2024-11-17    00:01        1179192 clang_rt.asan_dynamic-x86_64.dll
-a---          2024-11-17    00:01        4771840 clang_rt.asan_dynamic-x86_64.pdb

a bit curious indeed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-linkage Area: linking into static, shared libraries and binaries A-sanitizers Area: Sanitizers for correctness and code quality A-testsuite Area: The testsuite used to check the correctness of rustc C-bug Category: This is a bug. O-windows-msvc Toolchain: MSVC, Operating system: Windows T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

3 participants