-
Notifications
You must be signed in to change notification settings - Fork 72
Description
Proposal
In the efforts of the Rust goal Rust Stabilization of MemorySanitizer and ThreadSanitizer Support, we are looking for a solution to distribute prebuilt sanitizer instrumented standard libraries. This was requested by previous reviews, in order to stabilize sanitizers that require all code to be instrumented since otherwise they generate false positives (like the MemorySanitizer and ThreadSanitizer). Currently the only way to realistically use those is with -Z build-std, but if we stabilize the sanitizers, it is odd to still be dependent on another unstable flag.
We should therefore have an easier way to use stabilized sanitizers with sanitizer instrumented standard libraries without build-std by providing the instrumented standard library artifacts through e.g. rustup. I've originally approached the infra team but was directed to first addressing the necessary compiler changes before looking into distributing the artifacts (#t-infra/bootstrap > 2025H2 Goal Review @ 💬).
Together with some of the code that eholk provided me, I made a prototype in a local branch with 2 commits.
- Use lib-asan sysroot when ASAN is enabled with the compiler change
- Generate ASAN-enabled sysroot with a protoype of the bootstrap changes to actually test the compiler changes
The high-level design proposal looks like this:
Currently rustc has a single --sysroot that allows to set the entire sysroot but there is no way to toggle between different standard library variants there.
We could have a structure inside that looks something like this:
.../lib/rustlib/
└── x86_64-unknown-linux-gnu/
├── lib/ # The default standard library
├── lib-asan/ # The variant built with AddressSanitizer
└── lib-msan/ # The variant built with MemorySanitizer
In order to do so, we would need: A) compiler support to enable the variant required and B) bootstrap support in order to provide the variants through rustup.
In order to allow build-std to use -Zsanitizer=address without using the prebuilt artifacts, I introduced the rustc flag -Zsanitizer-use-prebuilt-library, which once the artifacts are shipped should default to yes and set to no by cargo when using build-std.
Some more context can also be found here.
Mentors or Reviewers
Mentor/Reviewer: rcvalle
Process
The main points of the Major Change Process are as follows:
- File an issue describing the proposal.
- A compiler team member who is knowledgeable in the area can second by writing
@rustbot secondor kickoff a team FCP with@rfcbot fcp $RESOLUTION.- Refer to Proposals, Approvals and Stabilization docs for when a second is sufficient, or when a full team FCP is required.
- Once an MCP is seconded, the Final Comment Period begins.
- Final Comment Period lasts for 10 days after all outstanding concerns are solved.
- Outstanding concerns will block the Final Comment Period from finishing. Once all concerns are resolved, the 10 day countdown is restarted.
- If no concerns are raised after 10 days since the resolution of the last outstanding concern, the MCP is considered approved.
You can read more about Major Change Proposals on forge.