Uh oh!
There was an error while loading. Please reload this page.
Allow use of AddressSanitizer on Windows by linking to existing libraries - #89369
Allow use of AddressSanitizer on Windows by linking to existing libraries#89369danielframpton wants to merge 1 commit into
Conversation
rust-highfive
commented
Sep 29, 2021
r? @estebank (rust-highfive has picked a reviewer for you, use r? to override) |
rust-highfive
commented
Sep 29, 2021
|
Re-assigning to myself per compiler team triage meeting. r? @wesleywiser |
bors
commented
Nov 7, 2021
☔ The latest upstream changes (presumably #90668) made this pull request unmergeable. Please resolve the merge conflicts. |
apiraino
commented
Dec 30, 2021
Reporting some sparse notes from the T-compiler discussion on Zulip of a while ago. Here a Windows / ASAN knowledgeable person would help with the review, possibly opening an MCP or similar. The general consensus was that the Windows / Microsoft people have better context here, perhaps drafting a writeup of the tradeoffs in the tracking issue. |
Dylan-DPC
commented
Apr 7, 2022
@danielframpton any updates on this? |
danielframpton
commented
Apr 7, 2022
I don't have an update, but I may get some more cycles to look at this soon. If anyone gets to it first, then I would be happy to discuss any details of this change or what we need to have things working on Windows. I think in addition to this change we may want to do the work to also build the runtimes for Windows (with correct dll names) and also make it possible to configure an override for the runtime libraries to use (to support hybrid Rust and C/C++ scenarios). |
JohnCSimon
commented
May 7, 2022
@danielframpton @rustbot label: +S-inactive |
Enable address sanitizer for MSVC targets using INFERASANLIBS linker flag This enables address sanitizer for x86_64-pc-windows-msvc and i686-pc-windows-msvc targets when linked with the MSVC linker (link.exe) by leveraging the `/INFERASANLIBS` option to automatically find and link in Microsoft's address sanitizer runtime: <https://learn.microsoft.com/en-us/cpp/sanitizers/asan-runtime?view=msvc-170> Implements rust-lang/compiler-team#702Fixesrust-lang#89339 (for MSVC targets using the MSVC linker only) Supercedes rust-lang#89369 Successful x86_64-msvc build showing the sanitizer tests working: https://github.com/rust-lang/rust/actions/runs/7228346880/job/19697628258?pr=118521
Enable address sanitizer for MSVC targets using INFERASANLIBS linker flag This enables address sanitizer for x86_64-pc-windows-msvc and i686-pc-windows-msvc targets when linked with the MSVC linker (link.exe) by leveraging the `/INFERASANLIBS` option to automatically find and link in Microsoft's address sanitizer runtime: <https://learn.microsoft.com/en-us/cpp/sanitizers/asan-runtime?view=msvc-170> Implements rust-lang/compiler-team#702Fixesrust-lang#89339 (for MSVC targets using the MSVC linker only) Supercedes rust-lang#89369 Successful x86_64-msvc build showing the sanitizer tests working: https://github.com/rust-lang/rust/actions/runs/7228346880/job/19697628258?pr=118521
Enable address sanitizer for MSVC targets using INFERASANLIBS linker flag This enables address sanitizer for x86_64-pc-windows-msvc and i686-pc-windows-msvc targets when linked with the MSVC linker (link.exe) by leveraging the `/INFERASANLIBS` option to automatically find and link in Microsoft's address sanitizer runtime: <https://learn.microsoft.com/en-us/cpp/sanitizers/asan-runtime?view=msvc-170> Implements rust-lang/compiler-team#702Fixesrust-lang#89339 (for MSVC targets using the MSVC linker only) Supercedes rust-lang#89369 Successful x86_64-msvc build showing the sanitizer tests working: https://github.com/rust-lang/rust/actions/runs/7228346880/job/19697628258?pr=118521
Rollup merge of rust-lang#118521 - dpaoliello:asan, r=wesleywiser Enable address sanitizer for MSVC targets using INFERASANLIBS linker flag This enables address sanitizer for x86_64-pc-windows-msvc and i686-pc-windows-msvc targets when linked with the MSVC linker (link.exe) by leveraging the `/INFERASANLIBS` option to automatically find and link in Microsoft's address sanitizer runtime: <https://learn.microsoft.com/en-us/cpp/sanitizers/asan-runtime?view=msvc-170> Implements rust-lang/compiler-team#702Fixesrust-lang#89339 (for MSVC targets using the MSVC linker only) Supercedes rust-lang#89369 Successful x86_64-msvc build showing the sanitizer tests working: https://github.com/rust-lang/rust/actions/runs/7228346880/job/19697628258?pr=118521
This change makes it possible to use address sanitizer on Windows by determining the right library name to use based on the way that the crt is being linked.
Currently, this change does not build the address sanitizer libraries (as we do for other platforms) so it is necessary to provide the libraries either from building those libraries from llvm or using other libraries from your C++ toolchain.
The current support for AddressSanitizer outside of windows involves renaming things compiled out of the llvm fork. I don't quite follow how this will work when sanitizing hybrid C/C++/Rust programs, and the approach causes additional problems on Windows because the renamed import library still references the dll with the original name.
I expect some of these questions will need to be resolved as part of stabilization (see #47174) but I wanted to make some progress on the Windows support as mentioned there and in other issues like #89339 so that we can see how this will all fit together.