Fix linking statics on Arm64EC#140176
Conversation
|
r? @Nadrieril rustbot has assigned @Nadrieril. Use |
|
Some changes occurred in compiler/rustc_codegen_ssa |
##
|
r? @wesleywiser |
|
@rustbot author |
|
Reminder, once the PR becomes ready for a review, use |
|
This PR modifies cc @jieyouxu |
Good call, found another bug: we need to correctly export variables as @rustbot ready |
#
This comment has been minimized.
This comment has been minimized.
|
Thanks @dpaoliello! @bors r+ rollup Also nominating for potential beta backport as this fixes a serious issue for the Tier 2 |
|
☀️ Test successful - checks-actions |
What is this?This is an experimental post-merge analysis report that shows differences in test outcomes between the merged PR and its parent PR.Comparing 667247d (parent) -> c8b7f32 (this PR) Test differencesShow 3 test diffsStage 1
Stage 2
Job group index
Test dashboardRun cargo run --manifest-path src/ci/citool/Cargo.toml -- \
test-dashboard c8b7f32434c0306db5c1b974ee43443746098a92 --output-dir test-dashboardAnd then open Job duration changes
How to interpret the job duration changes?Job durations can vary a lot, based on the actual runner instance |
|
Finished benchmarking commit (c8b7f32): comparison URL. Overall result: no relevant changes - no action needed@rustbot label: -perf-regression Instruction countThis benchmark run did not return any relevant results for this metric. Max RSS (memory usage)Results (primary 0.1%, secondary 0.2%)This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
CyclesResults (primary 0.1%, secondary -2.8%)This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 771.655s -> 771.811s (0.02%) |
|
We're hitting lld errors when building cargo after this change: It sounds like something is applying dllimport to __rust_no_alloc_shim_is_unstable even though it's part of the same image. Actually, I see you're hitting the same thing in this test: https://github.com/rust-lang/rust/pull/140176/files#diff-f31e13197ab771a198513dbb749c33ae9195b4814c5a358deca1294a112adbc1 Is this intentional? And if so, do the build files need to be updated to ignore the warning? (Our reference: https://crbug.com/417168093) |
Yes, this warning is expected: The correct fix would be for It's interesting that MSVC's linker reported this as warning 4286 whereas lld is reporting it as 4217. I'll submit a change to ignore 4217 as well. |
|
Hmm, while that fixes our build of cargo, we're now hitting the same warning when linking Chromium, and we definitely don't want to disable this warning globally. This seems like a regression. |
|
@bjorn3 is this something you can help with? There are two ways that this could be fixed without needing a warning suppression for the linker:
I don't know enough about the architecture of the compiler to know which of these approaches is plausible, though I would argue that the second is more "correct" (i.e., we are no longer lying to the compiler and telling it that |
|
If it takes a while to figure out a good way forward, would it be possible to revert to green in the meantime? |
|
We're also running into this issue on Fuchsia trying to build our stage0 windows rustc. If we do a revert, could we also cut a new stage0 as well? |
|
The beta backport nomination was rejected in the compiler async backport thread. @rustbot label: -beta-nominated |
|
The timing here is a bit unfortunate because most team members are N/A this week due to RustWeek / All Hands. I think it's safer to attempt a revert at this time, before we figure out a better solution for EDIT: revert PR is #141024. |
Unfortunately, multiple people are reporting linker warnings related to `__rust_no_alloc_shim_is_unstable` after this change. The solution isn't quite clear yet, let's revert to green for now, and try a reland with a determined solution for `__rust_no_alloc_shim_is_unstable`. This reverts commit c8b7f32, reversing changes made to 667247d.
Revert "Fix linking statics on Arm64EC rust-lang#140176" This reverts PR rust-lang#140176. Unfortunately, this will reopen rust-lang#138541 (re-breaking the `arm64ec-pc-windows-msvc` target). Unfortunately, multiple people are [reporting linker warnings related to `__rust_no_alloc_shim_is_unstable`](rust-lang#140176 (comment)) after this change in `x86_64-pc-windows-msvc` as well. The solution isn't quite clear yet, let's revert to avoid the linker warnings on the Tier 1 MSVC target for now[^timing], and try a reland with a determined solution for `__rust_no_alloc_shim_is_unstable`. Judging from [people reporting that they are observing this also when bootstrapping w/ stage0 rustc](rust-lang#140176 (comment)), we may have to cut a new beta and then repoint stage0 against that newer beta? cc `@dpaoliello` `@wesleywiser` r? `@wesleywiser` (or compiler) [^timing]: Note that it's still RustWeek this week, so most team members are N/A.
Revert "Fix linking statics on Arm64EC #140176" This reverts PR #140176. Unfortunately, this will reopen rust-lang/rust#138541 (re-breaking the `arm64ec-pc-windows-msvc` target). Unfortunately, multiple people are [reporting linker warnings related to `__rust_no_alloc_shim_is_unstable`](rust-lang/rust#140176 (comment)) after this change in `x86_64-pc-windows-msvc` as well. The solution isn't quite clear yet, let's revert to avoid the linker warnings on the Tier 1 MSVC target for now[^timing], and try a reland with a determined solution for `__rust_no_alloc_shim_is_unstable`. Judging from [people reporting that they are observing this also when bootstrapping w/ stage0 rustc](rust-lang/rust#140176 (comment)), we may have to cut a new beta and then repoint stage0 against that newer beta? cc `@dpaoliello` `@wesleywiser` r? `@wesleywiser` (or compiler) [^timing]: Note that it's still RustWeek this week, so most team members are N/A.
Unfortunately, multiple people are reporting linker warnings related to `__rust_no_alloc_shim_is_unstable` after this change. The solution isn't quite clear yet, let's revert to green for now, and try a reland with a determined solution for `__rust_no_alloc_shim_is_unstable`. This reverts commit c8b7f32, reversing changes made to 667247d. (cherry picked from commit 734a5b1)
[beta] backports and stage0 bump - bump stage0 - Update the edition guide for let chains rust-lang#140852 - Fix download of GCC from CI on non-nightly channels rust-lang#140901 - Revert "Fix linking statics on Arm64EC rust-lang#140176" rust-lang#141024 - [win][arm64] Remove 'Arm64 Hazard' undocumented MSVC option and instead disable problematic test rust-lang#141045 - Do not call name() on rpitit assoc_item rust-lang#141308 r? cuviper
Arm64EC builds recently started to fail due to the linker not finding a symbol:
It turns out that
EMPTY_PANICis a new static variable that was being exported then imported from the standard library, but when exporting LLVM didn't prepend the name with#(as only functions are prefixed with this character), whereas Rust was prefixing with#when attempting to import it.The fix is to have Rust not prefix statics with
#when importing.Adding tests discovered another issue: we need to correctly mark static exported from dylibs with
DATA, otherwise MSVC's linker assumes they are functions and complains that there is no exit thunk for them.CI found another bug: we only apply
DllImportto non-local statics that aren't foreign items (i.e., in anexternblock), that is we want to useDllImportfor statics coming from other Rust crates. However,__rust_no_alloc_shim_is_unstableis a static generated by the Rust compiler if required, but downstream crates consider it a foreign item since it is declared in anextern "Rust"block, thus they do not applyDllImportto it and so fails to link if it is exported by the previous crate asDATA. The fix is to applyDllImportto foreign items that are marked with therustc_std_internal_symbolattribute (i.e., we assume they aren't actually foreign and will be in some Rust crate).Fixes #138541
try-job: dist-aarch64-msvc
try-job: dist-x86_64-msvc
try-job: x86_64-msvc-1
try-job: x86_64-msvc-2