-
Notifications
You must be signed in to change notification settings - Fork 13.7k
Update to ar_archive_writer 0.5 #145721
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update to ar_archive_writer 0.5 #145721
Conversation
Some changes occurred in compiler/rustc_codegen_ssa
These commits modify the Cargo.lock
file. Unintentional changes to Cargo.lock
can be introduced when switching branches and rebasing PRs.
If this was unintentional then you should revert the changes before this PR is merged.
Otherwise, you can ignore this comment.
This comment has been minimized.
This comment has been minimized.
0e3d395
to
bcf96fe
Compare
For the Rust project, this means that anyone using the raw-dylib feature will need to provide the Arm64EC mangled name for any C++ function when targeting Arm64EC
How would that actually work? If you just do #[link_name = "..."]
it would be provided to both LLVM (which mangles it) and ar_archive_writer (which doesn't mangle it) To disable the name mangling on the LLVM side you have to use \x01
, but ar_archive_writer doesn't handle that and it is an LLVM implementation detail that may not work with other backends anyway.
For the Rust project, this means that anyone using the raw-dylib feature will need to provide the Arm64EC mangled name for any C++ function when targeting Arm64EC
How would that actually work? If you just do
#[link_name = "..."]
it would be provided to both LLVM (which mangles it) and ar_archive_writer (which doesn't mangle it) To disable the name mangling on the LLVM side you have to use\x01
, but ar_archive_writer doesn't handle that and it is an LLVM implementation detail that may not work with other backends anyway.
Let's take the example from the LLVM bug I posted above: int Wrapper<X>::GetValue(void) const
For most arches this is mangled as ?GetValue@?$Wrapper@UA@@@@QEBAHXZ
But, for Arm64EC it is mangled as ?GetValue@?$Wrapper@UA@@@@$$hQEBAHXZ
So, with ar_archive_writer
0.4.2 writing #[link_name = "?GetValue@?$Wrapper@UA@@@@QEBAHXZ"]
would generate an incorrect Arm64EC mangled name and so linking would fail. With 0.5.0, ar_archive_writer
recognizes that it is not an Arm64EC mangled name and so raises an error.
There are cases where 0.4.2 got the Arm64EC mangling correct, and those will now raise an error.
If you do #[link_name = "?GetValue@?$Wrapper@UA@@@@$$hQEBAHXZ"]
as already mangled name, then LLVM would mangle it again when it codegens a call to this function, right? Or actually it turns out LLVM literally crashes when you try that currently: https://rust.godbolt.org/z/Y6aj635qc
But if you use a simpler name where the old 0.4.2 algorithm happened to be correct, then it compiles correctly: https://rust.godbolt.org/z/dnhn64sqM but with 0.5.0 this will now raise an error.
So basically before this PR there were cases where the name mangling was wrong for C++ on arm64ec when using raw-dylib and in those cases there was no workaround. And with this PR you simply can't correctly use C++ symbols with raw-dylib at all.
Actually, the example that you provided works fine if you use raw-dylib
: https://rust.godbolt.org/z/fofzhfs5G
I did some experiments with 0.4.2, and it did work correctly even with the incorrect Arm64EC mangling: turns out that we don't need the mangled name since the EXPORT_AS
gets set to the unmangled name anyway. I'm going to make a slight change to ar_archive_writer
that will allow us to avoid this error and continue to link against C++ mangled names.
Ok, workaround in ar_archive_writer
: rust-lang/ar_archive_writer#26
☔ The latest upstream changes (presumably #145923) made this pull request unmergeable. Please resolve the merge conflicts.
bcf96fe
to
4daae65
Compare
This PR was rebased onto a different master commit. Here's a range-diff highlighting what actually changed.
Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.
@bjorn3 I've updated with the workaround I added in ar_archive_writer
, and verified via our internal build pipeline that the workaround works.
@bors r+
☀️ Test successful - checks-actions
Approved by: bjorn3
Pushing 7aef4be to master...
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 154037f (parent) -> 7aef4be (this PR)
Test differences
Show 2 test diffs
2 doctest diffs were found. These are ignored, as they are noisy.
Test dashboard
Run
cargo run --manifest-path src/ci/citool/Cargo.toml -- \ test-dashboard 7aef4bec4bec16cb6204d51eb633873e23b18771 --output-dir test-dashboard
And then open test-dashboard/index.html
in your browser to see an overview of all executed tests.
Job duration changes
- dist-x86_64-apple: 5796.5s -> 7384.2s (27.4%)
- aarch64-apple: 5868.5s -> 7320.6s (24.7%)
- dist-arm-linux-gnueabi: 4930.1s -> 5505.5s (11.7%)
- dist-i586-gnu-i586-i686-musl: 5882.8s -> 5344.6s (-9.1%)
- x86_64-gnu-stable: 7490.7s -> 6980.0s (-6.8%)
- x86_64-gnu-llvm-19-1: 3595.9s -> 3365.6s (-6.4%)
- dist-aarch64-msvc: 6022.0s -> 5668.6s (-5.9%)
- dist-various-2: 2173.7s -> 2055.1s (-5.5%)
- x86_64-gnu-llvm-20-1: 3485.4s -> 3309.7s (-5.0%)
- aarch64-gnu: 7284.9s -> 6925.5s (-4.9%)
How to interpret the job duration changes?
Job durations can vary a lot, based on the actual runner instance
that executed the job, system noise, invalidated caches, etc. The table above is provided
mostly for t-infra members, for simpler debugging of potential CI slow-downs.
Finished benchmarking commit (7aef4be): 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 -3.5%)A less reliable metric. May be of interest, but not used to determine the overall result above.
CyclesThis benchmark run did not return any relevant results for this metric. Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 467.56s -> 469.026s (0.31%) |
Uh oh!
There was an error while loading. Please reload this page.
This updates
ar_archive_writer
to 0.5, which in turn was updated to match LLVM 20.1.8: rust-lang/ar_archive_writer#24As part of this, I refactored part of
SymbolWrapper.cpp
to pull common code that I was about to duplicate again into a new function.NOTE:
ar_archive_writer
does include a breaking change where it no longer supports mangling C++ mangled names for Arm64EC. Since we don't need the mangled name (it's not the "exported name" which we're trying to load from the external dll), I'm setting theimport_name
when building for Arm64EC to prevent error when failing to mangle.r? @bjorn3