Skip to content
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

Don't copy symbols from dylibs with -Zdylib-lto #105800

Merged
merged 2 commits into from
Dec 17, 2022
Merged

Conversation

lqd
Copy link
Member

@lqd lqd commented Dec 16, 2022

When rustc_driver started being built with -Zdylib-lto -Clto=thin, some libstd symbols were copied by the LTO process into the dylib. That causes duplicate local symbols that are not present otherwise.

Depending on the situation (lib loading order apparently), the duplicated symbols could cause issues: rustc_driver overrode the panic hook, but it didn't apply to rustc main's hook (the default from libstd). This is the cause of #105637, in some situations the panic hook installed by rustc_driver isn't executed, and only libstd's backtrace is shown (and a double panic). The query stack, as well as the various notes to open a GH about the ICE, don't appear.

It's not clear exactly what is needed to trigger the issue, but I have simulated a reproducer here with cargo involved, the incorrect panic hook is executed on my machine. It is hard to reproduce in a unit test: cargo run + rustup involves LD_LIBRARY_PATH, which is not the case for compiletest. cargo also adds unconditional flags that are then overridden in bootstrap when building rustc with rust.lto = thin as done on CI).

All this to say the compilation and execution environment in bootstrap leading to the bug building rustc_driver is different from our UI tests, and I believe one of the reasons it's hard to make an exact reproducer test. Thankfully there's still a difference in the behavior though: although in the unit test the correct panic hook seems to be executed compared to my repro and the current nightly, only the fix removes the double panic here.

The 7e8277aefa12f1469fb1df01418ff5846a7854a9 try build:

While I believe this technically fixes the P-critical issue #105637, I would not want to close it yet as we may want to backport to beta/stable (if a point release happens, it would fix the ICEs reported on 1.66.0, which is built with ThinLTO on linux). Once this PR lands, I'll also open another PR to re-enable ThinLTO on x64 darwin's dist builder.

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Dec 16, 2022
@lqd
Copy link
Member Author

lqd commented Dec 16, 2022

@bors try

@bors
Copy link
Contributor

bors commented Dec 16, 2022

⌛ Trying commit be5685b with merge 7e8277aefa12f1469fb1df01418ff5846a7854a9...

@bors
Copy link
Contributor

bors commented Dec 17, 2022

☀️ Try build successful - checks-actions
Build commit: 7e8277aefa12f1469fb1df01418ff5846a7854a9 (7e8277aefa12f1469fb1df01418ff5846a7854a9)

@lqd lqd marked this pull request as ready for review December 17, 2022 01:15
@lqd
Copy link
Member Author

lqd commented Dec 17, 2022

Since we discussed this fix together, r? @bjorn3

@bjorn3
Copy link
Member

bjorn3 commented Dec 17, 2022

@bors r+ p=1 fixes a P-critical issue

@bors
Copy link
Contributor

bors commented Dec 17, 2022

📌 Commit be5685b has been approved by bjorn3

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Dec 17, 2022
@bors
Copy link
Contributor

bors commented Dec 17, 2022

⌛ Testing commit be5685b with merge 65c53c3...

@bors
Copy link
Contributor

bors commented Dec 17, 2022

☀️ Test successful - checks-actions
Approved by: bjorn3
Pushing 65c53c3 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Dec 17, 2022
@bors bors merged commit 65c53c3 into rust-lang:master Dec 17, 2022
@rustbot rustbot added this to the 1.68.0 milestone Dec 17, 2022
@lqd lqd deleted the dylib-thinlto branch December 17, 2022 18:12
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (65c53c3): comparison URL.

Overall result: ❌✅ regressions and improvements - no action needed

@rustbot label: -perf-regression

Instruction count

This is a highly reliable metric that was used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
0.4% [0.4%, 0.4%] 1
Regressions ❌
(secondary)
0.3% [0.3%, 0.3%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-1.1% [-1.1%, -1.1%] 1
All ❌✅ (primary) 0.4% [0.4%, 0.4%] 1

Max RSS (memory usage)

Results

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.

mean range count
Regressions ❌
(primary)
2.6% [1.6%, 3.7%] 2
Regressions ❌
(secondary)
0.9% [0.9%, 0.9%] 2
Improvements ✅
(primary)
-2.2% [-2.3%, -2.0%] 3
Improvements ✅
(secondary)
-2.2% [-4.2%, -1.2%] 24
All ❌✅ (primary) -0.2% [-2.3%, 3.7%] 5

Cycles

This benchmark run did not return any relevant results for this metric.

@lqd
Copy link
Member Author

lqd commented Dec 17, 2022

The artifacts from the merged commit 65c53c3 also fix the message for issue #105777 on x64 msvc, so I think we're good here. It should be fixed on windows and linux in the next nightly.

@lqd
Copy link
Member Author

lqd commented Dec 17, 2022

Since it fixes a P-critical issue and it's a trivial change, we could discuss backporting to beta/stable to have better quality bug reports for ICEs: @rustbot label: +beta-nominated +stable-nominated

@rustbot rustbot added beta-nominated Nominated for backporting to the compiler in the beta channel. stable-nominated Nominated for backporting to the compiler in the stable channel. labels Dec 17, 2022
bors added a commit to rust-lang-ci/rust that referenced this pull request Dec 19, 2022
…mulacrum

Re-enable ThinLTO for rustc on `x86_64-apple-darwin`

ThinLTO was disabled on x64 mac in rust-lang#105646 because of the rust-lang#105637 regression.

It was later discovered that the issue was present on other targets as well, as the mac revert was already landing. The linux/win reverts, however, did not land before the root cause was identified.

rust-lang#105800 fixed the underlying issue in `-Zdylib-lto` handling, and the x64 msvc and linux targets are now fixed, ICEs are using the correct `rustc_driver` panic hook.

This PR re-enables ThinLTO on mac for improved perf now that the issue should be fixed everywhere.
@apiraino
Copy link
Contributor

Beta backport accepted as per compiler team on Zulip

Stable backport on hold, will be revisited in a little bit.

@rustbot label +beta-accepted

@rustbot rustbot added the beta-accepted Accepted for backporting to the compiler in the beta channel. label Dec 22, 2022
@Mark-Simulacrum Mark-Simulacrum modified the milestones: 1.68.0, 1.67.0 Dec 26, 2022
@Mark-Simulacrum Mark-Simulacrum removed the beta-nominated Nominated for backporting to the compiler in the beta channel. label Dec 26, 2022
bors added a commit to rust-lang-ci/rust that referenced this pull request Dec 27, 2022
…mulacrum

[beta] backport rollup

* Revert "Replace usage of ResumeTy in async lowering with Context" rust-lang#105915
*  Don't copy symbols from dylibs with -Zdylib-lto rust-lang#105800
*  rustdoc: Only hide lines starting with # in rust code blocks rust-lang#105539
*  Mangle "main" as "__main_void" on wasm32-wasi rust-lang#105468

r? `@ghost`
@apiraino
Copy link
Contributor

apiraino commented Jan 5, 2023

Stable backport declined as per compiler team on Zulip. We will let this ride the trains (next stable release is on Jan, 26th).

@rustbot label -stable-nominated

@rustbot rustbot removed the stable-nominated Nominated for backporting to the compiler in the stable channel. label Jan 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
beta-accepted Accepted for backporting to the compiler in the beta channel. merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants