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

linker: Fix weak lang item linking with combination windows-gnu + LLD + LTO #103092

Merged
merged 1 commit into from
Oct 20, 2022

Conversation

petrochenkov
Copy link
Contributor

@petrochenkov petrochenkov commented Oct 15, 2022

In #100404 this logic was originally disabled for MSVC due to issues with LTO, but the same issues appear on windows-gnu with LLD because that LLD uses the same underlying logic as MSVC LLD, just with re-syntaxed command line options.

So this PR just disables it for LTO builds in general.

@rustbot rustbot added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Oct 15, 2022
@rust-highfive
Copy link
Collaborator

r? @lcnr

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Oct 15, 2022
@petrochenkov
Copy link
Contributor Author

@belovdv you originally suggested this alternative, and you were right, this solution is probably the least bad.

// If global LTO is enabled then almost everything (*) is glued into a single object file,
// so this logic is not necessary and can cause issues on some targets (due to weak lang
// item symbols being "privatized" to that object file), so we disable it.
// (*) Native libs, and `#[compiler_builtins]` and `#[no_builtins]` crates are not glued,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#![no_builtins] is stable. Lang items are not, so that is probably not an issue.

@luqmana
Copy link
Member

luqmana commented Oct 17, 2022

Sweet, I think this should also fix the issue I've been seeing on illumos lately with LTO.

e.g. trying to build bat:

error: linking with `gcc` failed: exit status: 1                                                                                                                                                         
  |                                                                                                                                                                                                      
  = note: "gcc" "-m64" "-std=c99" "/tmp/rustcsVN1FO/symbols.o" "/tmp/bat/target/release/deps/bat-e4fceccbe6e2b327.bat.7aa865dd-cgu.0.rcgu.o" "-Wl,-z,ignore" "-L" "/tmp/bat/targe
t/release/deps" "-L" "/tmp/bat/target/release/build/libgit2-sys-b78d3b7d704ff41e/out/build" "-L" "/usr/lib/amd64" "-L" "/tmp/bat/target/release/build/onig_sys-159ec9d31ec0a92a/o
ut" "-L" "/home/luqman/.rustup/toolchains/nightly-x86_64-unknown-illumos/lib/rustlib/x86_64-unknown-illumos/lib" "-Wl,-Bstatic" "/tmp/rustcsVN1FO/liblibgit2_sys-e95cd72243699990.rlib" "/tmp/rustcsVN1FO
/libonig_sys-8c63ac69bc862d8b.rlib" "/home/luqman/.rustup/toolchains/nightly-x86_64-unknown-illumos/lib/rustlib/x86_64-unknown-illumos/lib/libcompiler_builtins-5843a5198c157050.rlib" "-Wl,-Bdynamic" "-
lkstat" "-lz" "-lsendfile" "-llgrp" "-lsocket" "-lposix4" "-lpthread" "-lresolv" "-lnsl" "-lumem" "-lgcc_s" "-lm" "-lrt" "-lpthread" "-lsendfile" "-llgrp" "-lc" "-lssp" "-L" "/home/luqman/.rustup/toolc
hains/nightly-x86_64-unknown-illumos/lib/rustlib/x86_64-unknown-illumos/lib" "-o" "/tmp/bat/target/release/deps/bat-e4fceccbe6e2b327" "-nodefaultlibs"                                       
  = note: Undefined                     first referenced                                                                                                                                                 
           symbol                           in file                                                                                                                                                      
          rust_begin_unwind                   /tmp/rustcsVN1FO/symbols.o                                                                                                                                 
          rust_oom                            /tmp/rustcsVN1FO/symbols.o                                                                                                                                 
          ld: fatal: symbol referencing errors. No output written to /tmp/bat/target/release/deps/bat-e4fceccbe6e2b327                                                                       
          collect2: error: ld returned 1 exit status                                                                                                                                                     
                                                                                                                                                                                                         
                                                                                                                                                                                                         
error: could not compile `bat` due to previous error

@lcnr
Copy link
Contributor

lcnr commented Oct 17, 2022

r? compiler

@rust-highfive rust-highfive assigned fee1-dead and unassigned lcnr Oct 17, 2022
@lcnr
Copy link
Contributor

lcnr commented Oct 17, 2022

they are on vacation rn

r? compiler

@wesleywiser
Copy link
Member

@bors r+

@bors
Copy link
Contributor

bors commented Oct 18, 2022

📌 Commit acf51e1 has been approved by wesleywiser

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 Oct 18, 2022
@petrochenkov
Copy link
Contributor Author

Beta-nominating as a regression fix (the regression has also first landed on beta).

@petrochenkov petrochenkov added the beta-nominated Nominated for backporting to the compiler in the beta channel. label Oct 19, 2022
@wesleywiser
Copy link
Member

@bors p=1

Fixes beta regression and we'd like to see this land on nightly before it's backported

@apiraino
Copy link
Contributor

Beta backport accepted as per compiler team on Zulip

@rustbot label +beta-accepted

@rustbot rustbot added the beta-accepted Accepted for backporting to the compiler in the beta channel. label Oct 20, 2022
@bors
Copy link
Contributor

bors commented Oct 20, 2022

⌛ Testing commit acf51e1 with merge 5ffa67d...

@bors
Copy link
Contributor

bors commented Oct 20, 2022

☀️ Test successful - checks-actions
Approved by: wesleywiser
Pushing 5ffa67d to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Oct 20, 2022
@bors bors merged commit 5ffa67d into rust-lang:master Oct 20, 2022
@rustbot rustbot added this to the 1.66.0 milestone Oct 20, 2022
@cuviper cuviper mentioned this pull request Oct 20, 2022
@cuviper cuviper modified the milestones: 1.66.0, 1.65.0 Oct 20, 2022
@cuviper cuviper removed the beta-nominated Nominated for backporting to the compiler in the beta channel. label Oct 20, 2022
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (5ffa67d): comparison URL.

Overall result: no relevant changes - no action needed

@rustbot label: -perf-regression

Instruction count

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

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.

mean1 range count2
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
2.1% [2.1%, 2.1%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) - - 0

Cycles

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

Footnotes

  1. the arithmetic mean of the percent change

  2. number of relevant changes

bors added a commit to rust-lang-ci/rust that referenced this pull request Oct 21, 2022
[beta] backports

- Use rebind instead of dummy binder in `SameTypeModuloInfer` relation rust-lang#102059
- Add missing space between notable trait tooltip and where clause rust-lang#102107
- Avoid repeated re-initialization of the BufReader buffer rust-lang#102760
- Ensure enum cast moves rust-lang#103016
- Fix `TyKind::is_simple_path` rust-lang#103176
- Do anonymous lifetimes remapping correctly for nested rpits rust-lang#103205
- [beta] Cargo backport 1.65.0 rust-lang#103303
- linker: Fix weak lang item linking with combination windows-gnu + LLD + LTO rust-lang#103092

r? `@ghost`
Aaron1011 pushed a commit to Aaron1011/rust that referenced this pull request Jan 6, 2023
linker: Fix weak lang item linking with combination windows-gnu + LLD + LTO

In rust-lang#100404 this logic was originally disabled for MSVC due to issues with LTO, but the same issues appear on windows-gnu with LLD because that LLD uses the same underlying logic as MSVC LLD, just with re-syntaxed command line options.

So this PR just disables it for LTO builds in general.
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.