Enforce the compiler-builtins partitioning scheme #135395
Draft
+39
−35
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In progress still, I want to at least add a test that checks that we get the partitioning right when using -Zbuild-std. And add/improve comments.
compiler-builtins needs every intrinsic in its own CGU. Currently, the compiler-builtins crate puts every intrinsic in its own inline module then
library/Cargo.toml
uses a profile override so that when we build the sysroot, compiler-builtins is built with morecodegen-units
than we have intrinsics, and partitioning never merges two intrinsics together. This approach does not work with-Zbuild-std
because the profile override gets ignored. And it's kludgey anyway, our own standard library should not be fighting with our own compiler in an attempt to override its behavior. We should change the behavior to do the right thing in the first place.So that's what this PR does. There's some light refactoring of the CGU partitioning code, then in 3 places I've added a check for
is_compiler_builtins
:cross_crate_inlinable
; every function in compiler-builtins that is not#[no_mangle]
is made cross-crate-inlinable, which ensures we do not run into problems inlining helpers into intrinsics such as compiler-builtins: Int trait functions are not inlined on wasm #73135That should ensure that we have one object file per intrinsic, and if optimizations are enabled, there should be no extra extra CGUs full of helper functions (which is what currently happens in the precompiled standard library we distribute).
r? ghost