Make no_mangle on foreign items explicit instead of implicit - #144678
Conversation
|
Some changes occurred in compiler/rustc_codegen_ssa |
|
Can you please squash the last two commits? |
This comment has been minimized.
This comment has been minimized.
|
Can do |
1790424 to
5240989
Compare
5240989 to
e75b93d
Compare
e75b93d to
9003a3b
Compare
| /// | ||
| /// Note that this returns true for foreign items. | ||
| /// However, in some places that care about `contains_extern_indicator`, foreign items | ||
| /// (in an `extern` block) should explicitly be ignored. |
There was a problem hiding this comment.
Is it possible to make this not return true for foreign items? Foreign items don't need to be exported and the point of this method is to check if an item needs to be exported.
There was a problem hiding this comment.
it's annoying since we don't have a did or TyCtxt here. We could, but that'd involve adding another flag in the codegen fn attributes. I decided against that but it's perfectly possible.
|
@bors r+ |
…jorn3 Make no_mangle on foreign items explicit instead of implicit for a followup PR I'm working on I need some foreign items to mangle. I could add a new attribute: `no_no_mangle` or something silly like that but by explicitly putting `no_mangle` in the codegen fn attrs of foreign items we can default it to `no_mangle` and then easily remove it when we don't want it. I guess you'd know about this r? `@bjorn3.` Shouldn't be too hard to review :) Builds on rust-lang#144655 which should merge first.
Rollup of 13 pull requests Successful merges: - #143857 (Port #[macro_export] to the new attribute parsing infrastructure) - #144070 (Implement `hash_map` macro ) - #144322 (Add lint against dangling pointers from local variables) - #144667 (`AlignmentEnum` should just be `repr(usize)` now) - #144678 (Make no_mangle on foreign items explicit instead of implicit) - #144790 (Multiple bounds checking elision failures) - #144794 (Port `#[coroutine]` to the new attribute system) - #144805 (compiletest: Preliminary cleanup of `ProcRes` printing/unwinding) - #144808 (`Interner` arg to `EarlyBinder` does not affect auto traits) - #144816 (Update E0562 to account for the new impl trait positions) - #144822 (Return a struct with named fields from `hash_owner_nodes`) - #144824 (Updated test links in compiler) - #144829 (Use full flag name in strip command for Darwin) r? `@ghost` `@rustbot` modify labels: rollup
|
Trying to diagnose rollup failure #144846 (comment) @bors try jobs=test-various |
Make no_mangle on foreign items explicit instead of implicit try-job: test-various
This comment has been minimized.
This comment has been minimized.
|
💔 Test failed (CI). Failed jobs:
|
|
@bors r- |
|
sigh, ye that's significant I'm afraid :/ |
| } | ||
|
|
||
| // Foreign items by default use no mangling for their symbol name. | ||
| if tcx.is_foreign_item(did) { |
There was a problem hiding this comment.
I suspect the extra query call here is the cause for the perf regression.
There was a problem hiding this comment.
Do we think #145429 will resolve that? I think it moved the call around maybe but didn't eliminate it? (I couldn't quite tell at a quick skim). Or do we need to wait for some future date where there's additional validation added at an earlier stage (attribute parsing)?
There was a problem hiding this comment.
#145429 doesn't move this call around, only the one in rustc_symbol_mangling which already existed. It also adds an extra call for #[link_name] that can be removed once extra validation is done during attribute parsing. I don't think that extra call in that PR would have much effect. Only a small fraction of all functions for which codegen_fn_attrs is called has a #[link_name] attribute.
tl;dr: #145429 has no effect on the regression in this PR.
There was a problem hiding this comment.
Mhm, I doubt it too. I just haven't quite worked out what to do about this since this really is the behavior I want but it's a perf problem it seems. We could revert but the alternative will be much less pretty. It'd involve having an extra flag in codegen fn attrs to explicitly not no-mangle foreign items.
…ts, r=jdonszelmann Couple of codegen_fn_attrs improvements As noted in rust-lang#144678 (comment) here is no need to keep link_name and export_name separate, which the third commit fixes by merging them. The second commit removes some dead code and the first commit merges two ifs with equivalent conditions. The last commit is an unrelated change which removes an unused `feature(autodiff)`.
…ts, r=jdonszelmann Couple of codegen_fn_attrs improvements As noted in rust-lang#144678 (comment) here is no need to keep link_name and export_name separate, which the third commit fixes by merging them. The second commit removes some dead code and the first commit merges two ifs with equivalent conditions. The last commit is an unrelated change which removes an unused `feature(autodiff)`.
…ts, r=jdonszelmann Couple of codegen_fn_attrs improvements As noted in rust-lang#144678 (comment) here is no need to keep link_name and export_name separate, which the third commit fixes by merging them. The second commit removes some dead code and the first commit merges two ifs with equivalent conditions. The last commit is an unrelated change which removes an unused `feature(autodiff)`.
…ts, r=jdonszelmann Couple of codegen_fn_attrs improvements As noted in rust-lang#144678 (comment) here is no need to keep link_name and export_name separate, which the third commit fixes by merging them. The second commit removes some dead code and the first commit merges two ifs with equivalent conditions. The last commit is an unrelated change which removes an unused `feature(autodiff)`.
…ts, r=jdonszelmann Couple of codegen_fn_attrs improvements As noted in rust-lang#144678 (comment) here is no need to keep link_name and export_name separate, which the third commit fixes by merging them. The second commit removes some dead code and the first commit merges two ifs with equivalent conditions. The last commit is an unrelated change which removes an unused `feature(autodiff)`.
…ts, r=jdonszelmann Couple of codegen_fn_attrs improvements As noted in rust-lang#144678 (comment) here is no need to keep link_name and export_name separate, which the third commit fixes by merging them. The second commit removes some dead code and the first commit merges two ifs with equivalent conditions. The last commit is an unrelated change which removes an unused `feature(autodiff)`.
…ts, r=jdonszelmann Couple of codegen_fn_attrs improvements As noted in rust-lang#144678 (comment) here is no need to keep link_name and export_name separate, which the third commit fixes by merging them. The second commit removes some dead code and the first commit merges two ifs with equivalent conditions. The last commit is an unrelated change which removes an unused `feature(autodiff)`.
…ts, r=jdonszelmann Couple of codegen_fn_attrs improvements As noted in rust-lang#144678 (comment) here is no need to keep link_name and export_name separate, which the third commit fixes by merging them. The second commit removes some dead code and the first commit merges two ifs with equivalent conditions. The last commit is an unrelated change which removes an unused `feature(autodiff)`.
Rollup merge of #145429 - bjorn3:codegen_fn_attrs_improvements, r=jdonszelmann Couple of codegen_fn_attrs improvements As noted in #144678 (comment) here is no need to keep link_name and export_name separate, which the third commit fixes by merging them. The second commit removes some dead code and the first commit merges two ifs with equivalent conditions. The last commit is an unrelated change which removes an unused `feature(autodiff)`.
…nszelmann Couple of codegen_fn_attrs improvements As noted in rust-lang/rust#144678 (comment) here is no need to keep link_name and export_name separate, which the third commit fixes by merging them. The second commit removes some dead code and the first commit merges two ifs with equivalent conditions. The last commit is an unrelated change which removes an unused `feature(autodiff)`.
Make no_mangle on foreign items explicit instead of implicit for a followup PR I'm working on I need some foreign items to mangle. I could add a new attribute: `no_no_mangle` or something silly like that but by explicitly putting `no_mangle` in the codegen fn attrs of foreign items we can default it to `no_mangle` and then easily remove it when we don't want it. I guess you'd know about this r? `@bjorn3.` Shouldn't be too hard to review :) Builds on rust-lang#144655 which should merge first.
…nszelmann Couple of codegen_fn_attrs improvements As noted in rust-lang/rust#144678 (comment) here is no need to keep link_name and export_name separate, which the third commit fixes by merging them. The second commit removes some dead code and the first commit merges two ifs with equivalent conditions. The last commit is an unrelated change which removes an unused `feature(autodiff)`.
|
ok, based on discussion above I wanted to go ahead with a revert, but when doing that I finally had an idea how to actually fix it so let's try that quickly in #145855 |
This commit fixes an accidental regression from rust-lang#144678 where wasm targets would now accidentally use the wrong import module map for a symbol causing a symbol to skip mangling. This can result in compilation failures when symbols are used in cross-crate situations. Closes rust-lang#148347
This commit fixes an accidental regression from rust-lang#144678 where wasm targets would now accidentally use the wrong import module map for a symbol causing a symbol to skip mangling. This can result in compilation failures when symbols are used in cross-crate situations. Closes 148347
…=jackh726 Fix `wasm_import_module` attribute cross-crate This commit fixes an accidental regression from rust-lang#144678 where wasm targets would now accidentally use the wrong import module map for a symbol causing a symbol to skip mangling. This can result in compilation failures when symbols are used in cross-crate situations. Closes rust-lang#148347
…=jackh726 Fix `wasm_import_module` attribute cross-crate This commit fixes an accidental regression from rust-lang#144678 where wasm targets would now accidentally use the wrong import module map for a symbol causing a symbol to skip mangling. This can result in compilation failures when symbols are used in cross-crate situations. Closes rust-lang#148347
Rollup merge of #148363 - alexcrichton:fix-wasm-link-name, r=jackh726 Fix `wasm_import_module` attribute cross-crate This commit fixes an accidental regression from #144678 where wasm targets would now accidentally use the wrong import module map for a symbol causing a symbol to skip mangling. This can result in compilation failures when symbols are used in cross-crate situations. Closes #148347
…est, r=petrochenkov Add test for parallel compiler reproducible build Adds a test for reproducible binaries when using parallel compiler. Confirmed with bisection and manual testing that rust-lang#144722 fixed rust-lang#140413, added test fails before commit (075ce31) from rust-lang#144722. ```rust ******************************************************************************** Regression in nightly-2025-08-14 ******************************************************************************** fetching https://static.rust-lang.org/dist/2025-08-13/channel-rust-nightly-git-commit-hash.txt nightly manifest 2025-08-13: 40 B / 40 B [============================================================================================================================================================================] 100.00 % 357.18 KB/s converted 2025-08-13 to 8e62bfd fetching https://static.rust-lang.org/dist/2025-08-14/channel-rust-nightly-git-commit-hash.txt nightly manifest 2025-08-14: 40 B / 40 B [============================================================================================================================================================================] 100.00 % 123.86 KB/s converted 2025-08-14 to 3672a55 looking for regression commit between 2025-08-13 and 2025-08-14 fetching (via remote github) commits from max(8e62bfd, 2025-08-11) to 3672a55 ending github query because we found starting sha: 8e62bfd get_commits_between returning commits, len: 7 commit[0] 2025-08-12: Auto merge of rust-lang#144678 - jdonszelmann:no-mangle-extern, r=bjorn3 commit[1] 2025-08-12: Auto merge of rust-lang#145295 - Kobzol:unify-stages, r=jieyouxu commit[2] 2025-08-13: Auto merge of rust-lang#145093 - nikic:dead-on-return, r=nnethercote commit[3] 2025-08-13: Auto merge of rust-lang#145334 - Kobzol:rollup-fs5a133, r=Kobzol commit[4] 2025-08-13: Auto merge of rust-lang#144722 - ywxt:parallel-reproducibile, r=SparrowLii commit[5] 2025-08-13: Auto merge of rust-lang#145298 - nikic:llvm21-rc3, r=cuviper commit[6] 2025-08-13: Auto merge of rust-lang#145366 - GuillaumeGomez:rollup-v0a6v3u, r=GuillaumeGomez ``` Fixes rust-lang#140413. r? @petrochenkov
…est, r=petrochenkov Add test for parallel compiler reproducible build Adds a test for reproducible binaries when using parallel compiler. Confirmed with bisection and manual testing that rust-lang#144722 fixed rust-lang#140413, added test fails before commit (075ce31) from rust-lang#144722. ```rust ******************************************************************************** Regression in nightly-2025-08-14 ******************************************************************************** fetching https://static.rust-lang.org/dist/2025-08-13/channel-rust-nightly-git-commit-hash.txt nightly manifest 2025-08-13: 40 B / 40 B [============================================================================================================================================================================] 100.00 % 357.18 KB/s converted 2025-08-13 to 8e62bfd fetching https://static.rust-lang.org/dist/2025-08-14/channel-rust-nightly-git-commit-hash.txt nightly manifest 2025-08-14: 40 B / 40 B [============================================================================================================================================================================] 100.00 % 123.86 KB/s converted 2025-08-14 to 3672a55 looking for regression commit between 2025-08-13 and 2025-08-14 fetching (via remote github) commits from max(8e62bfd, 2025-08-11) to 3672a55 ending github query because we found starting sha: 8e62bfd get_commits_between returning commits, len: 7 commit[0] 2025-08-12: Auto merge of rust-lang#144678 - jdonszelmann:no-mangle-extern, r=bjorn3 commit[1] 2025-08-12: Auto merge of rust-lang#145295 - Kobzol:unify-stages, r=jieyouxu commit[2] 2025-08-13: Auto merge of rust-lang#145093 - nikic:dead-on-return, r=nnethercote commit[3] 2025-08-13: Auto merge of rust-lang#145334 - Kobzol:rollup-fs5a133, r=Kobzol commit[4] 2025-08-13: Auto merge of rust-lang#144722 - ywxt:parallel-reproducibile, r=SparrowLii commit[5] 2025-08-13: Auto merge of rust-lang#145298 - nikic:llvm21-rc3, r=cuviper commit[6] 2025-08-13: Auto merge of rust-lang#145366 - GuillaumeGomez:rollup-v0a6v3u, r=GuillaumeGomez ``` Fixes rust-lang#140413. r? @petrochenkov
…est, r=petrochenkov Add test for parallel compiler reproducible build Adds a test for reproducible binaries when using parallel compiler. Confirmed with bisection and manual testing that rust-lang#144722 fixed rust-lang#140413, added test fails before commit (075ce31) from rust-lang#144722. ```rust ******************************************************************************** Regression in nightly-2025-08-14 ******************************************************************************** fetching https://static.rust-lang.org/dist/2025-08-13/channel-rust-nightly-git-commit-hash.txt nightly manifest 2025-08-13: 40 B / 40 B [============================================================================================================================================================================] 100.00 % 357.18 KB/s converted 2025-08-13 to 8e62bfd fetching https://static.rust-lang.org/dist/2025-08-14/channel-rust-nightly-git-commit-hash.txt nightly manifest 2025-08-14: 40 B / 40 B [============================================================================================================================================================================] 100.00 % 123.86 KB/s converted 2025-08-14 to 3672a55 looking for regression commit between 2025-08-13 and 2025-08-14 fetching (via remote github) commits from max(8e62bfd, 2025-08-11) to 3672a55 ending github query because we found starting sha: 8e62bfd get_commits_between returning commits, len: 7 commit[0] 2025-08-12: Auto merge of rust-lang#144678 - jdonszelmann:no-mangle-extern, r=bjorn3 commit[1] 2025-08-12: Auto merge of rust-lang#145295 - Kobzol:unify-stages, r=jieyouxu commit[2] 2025-08-13: Auto merge of rust-lang#145093 - nikic:dead-on-return, r=nnethercote commit[3] 2025-08-13: Auto merge of rust-lang#145334 - Kobzol:rollup-fs5a133, r=Kobzol commit[4] 2025-08-13: Auto merge of rust-lang#144722 - ywxt:parallel-reproducibile, r=SparrowLii commit[5] 2025-08-13: Auto merge of rust-lang#145298 - nikic:llvm21-rc3, r=cuviper commit[6] 2025-08-13: Auto merge of rust-lang#145366 - GuillaumeGomez:rollup-v0a6v3u, r=GuillaumeGomez ``` Fixes rust-lang#140413. r? @petrochenkov
…est, r=petrochenkov Add test for parallel compiler reproducible build Adds a test for reproducible binaries when using parallel compiler. Confirmed with bisection and manual testing that rust-lang#144722 fixed rust-lang#140413, added test fails before commit (075ce31) from rust-lang#144722. ```rust ******************************************************************************** Regression in nightly-2025-08-14 ******************************************************************************** fetching https://static.rust-lang.org/dist/2025-08-13/channel-rust-nightly-git-commit-hash.txt nightly manifest 2025-08-13: 40 B / 40 B [============================================================================================================================================================================] 100.00 % 357.18 KB/s converted 2025-08-13 to 8e62bfd fetching https://static.rust-lang.org/dist/2025-08-14/channel-rust-nightly-git-commit-hash.txt nightly manifest 2025-08-14: 40 B / 40 B [============================================================================================================================================================================] 100.00 % 123.86 KB/s converted 2025-08-14 to 3672a55 looking for regression commit between 2025-08-13 and 2025-08-14 fetching (via remote github) commits from max(8e62bfd, 2025-08-11) to 3672a55 ending github query because we found starting sha: 8e62bfd get_commits_between returning commits, len: 7 commit[0] 2025-08-12: Auto merge of rust-lang#144678 - jdonszelmann:no-mangle-extern, r=bjorn3 commit[1] 2025-08-12: Auto merge of rust-lang#145295 - Kobzol:unify-stages, r=jieyouxu commit[2] 2025-08-13: Auto merge of rust-lang#145093 - nikic:dead-on-return, r=nnethercote commit[3] 2025-08-13: Auto merge of rust-lang#145334 - Kobzol:rollup-fs5a133, r=Kobzol commit[4] 2025-08-13: Auto merge of rust-lang#144722 - ywxt:parallel-reproducibile, r=SparrowLii commit[5] 2025-08-13: Auto merge of rust-lang#145298 - nikic:llvm21-rc3, r=cuviper commit[6] 2025-08-13: Auto merge of rust-lang#145366 - GuillaumeGomez:rollup-v0a6v3u, r=GuillaumeGomez ``` Fixes rust-lang#140413. r? @petrochenkov
…est, r=petrochenkov Add test for parallel compiler reproducible build Adds a test for reproducible binaries when using parallel compiler. Confirmed with bisection and manual testing that rust-lang#144722 fixed rust-lang#140413, added test fails before commit (075ce31) from rust-lang#144722. ```rust ******************************************************************************** Regression in nightly-2025-08-14 ******************************************************************************** fetching https://static.rust-lang.org/dist/2025-08-13/channel-rust-nightly-git-commit-hash.txt nightly manifest 2025-08-13: 40 B / 40 B [============================================================================================================================================================================] 100.00 % 357.18 KB/s converted 2025-08-13 to 8e62bfd fetching https://static.rust-lang.org/dist/2025-08-14/channel-rust-nightly-git-commit-hash.txt nightly manifest 2025-08-14: 40 B / 40 B [============================================================================================================================================================================] 100.00 % 123.86 KB/s converted 2025-08-14 to 3672a55 looking for regression commit between 2025-08-13 and 2025-08-14 fetching (via remote github) commits from max(8e62bfd, 2025-08-11) to 3672a55 ending github query because we found starting sha: 8e62bfd get_commits_between returning commits, len: 7 commit[0] 2025-08-12: Auto merge of rust-lang#144678 - jdonszelmann:no-mangle-extern, r=bjorn3 commit[1] 2025-08-12: Auto merge of rust-lang#145295 - Kobzol:unify-stages, r=jieyouxu commit[2] 2025-08-13: Auto merge of rust-lang#145093 - nikic:dead-on-return, r=nnethercote commit[3] 2025-08-13: Auto merge of rust-lang#145334 - Kobzol:rollup-fs5a133, r=Kobzol commit[4] 2025-08-13: Auto merge of rust-lang#144722 - ywxt:parallel-reproducibile, r=SparrowLii commit[5] 2025-08-13: Auto merge of rust-lang#145298 - nikic:llvm21-rc3, r=cuviper commit[6] 2025-08-13: Auto merge of rust-lang#145366 - GuillaumeGomez:rollup-v0a6v3u, r=GuillaumeGomez ``` Fixes rust-lang#140413. r? @petrochenkov
for a followup PR I'm working on I need some foreign items to mangle. I could add a new attribute:
no_no_mangleor something silly like that but by explicitly puttingno_manglein the codegen fn attrs of foreign items we can default it tono_mangleand then easily remove it when we don't want it.I guess you'd know about this r? @bjorn3. Shouldn't be too hard to review :)
Builds on #144655 which should merge first.