rust icon indicating copy to clipboard operation
rust copied to clipboard

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

Open petrochenkov opened this issue 2 years ago • 5 comments

In https://github.com/rust-lang/rust/pull/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.

petrochenkov avatar Oct 15 '22 18:10 petrochenkov

r? @lcnr

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

rust-highfive avatar Oct 15 '22 18:10 rust-highfive

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

petrochenkov avatar Oct 15 '22 18:10 petrochenkov

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

luqmana avatar Oct 17 '22 03:10 luqmana

r? compiler

lcnr avatar Oct 17 '22 08:10 lcnr

they are on vacation rn

r? compiler

lcnr avatar Oct 17 '22 08:10 lcnr

@bors r+

wesleywiser avatar Oct 18 '22 14:10 wesleywiser

:pushpin: Commit acf51e13457c45b97cdfd551d85d3e75140e0ff7 has been approved by wesleywiser

It is now in the queue for this repository.

bors avatar Oct 18 '22 14:10 bors

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

petrochenkov avatar Oct 19 '22 11:10 petrochenkov

@bors p=1

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

wesleywiser avatar Oct 20 '22 14:10 wesleywiser

Beta backport accepted as per compiler team on Zulip

@rustbot label +beta-accepted

apiraino avatar Oct 20 '22 14:10 apiraino

:hourglass: Testing commit acf51e13457c45b97cdfd551d85d3e75140e0ff7 with merge 5ffa67d7309047ff47b9c624ba4061fb8c004c31...

bors avatar Oct 20 '22 16:10 bors

:sunny: Test successful - checks-actions Approved by: wesleywiser Pushing 5ffa67d7309047ff47b9c624ba4061fb8c004c31 to master...

bors avatar Oct 20 '22 19:10 bors

Finished benchmarking commit (5ffa67d7309047ff47b9c624ba4061fb8c004c31): 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.

mean[^1] range count[^2]
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.

[^1]: the arithmetic mean of the percent change [^2]: number of relevant changes

rust-timer avatar Oct 20 '22 21:10 rust-timer