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

lld-wrapper failed on Darwin #97755

Closed
tschuett opened this issue Jun 5, 2022 · 11 comments · Fixed by #100200
Closed

lld-wrapper failed on Darwin #97755

tschuett opened this issue Jun 5, 2022 · 11 comments · Fixed by #100200
Assignees
Labels
C-bug Category: This is a bug.

Comments

@tschuett
Copy link

tschuett commented Jun 5, 2022

lld-wrapper is unhappy.

I tried this code:

 RUSTFLAGS='-Z gcc-ld=lld -C target-cpu=native' cargo +nightly run --release

Instead, this happened:

 = note: lld-wrapper: -rustc-lld-flavor=<flavor> is not passed
          clang: error: linker command failed with exit code 1 (use -v to see invocation)
... x86_64-apple-darwin/bin/gcc-ld" "-Wl,-rustc-lld-flavor=darwin ...

Meta

rustc --version --verbose:

rustc +nightly --version --verbose
rustc 1.63.0-nightly (e71440575 2022-06-02)
binary: rustc
commit-hash: e71440575c930dcecac288b7c3536410d688b351
commit-date: 2022-06-02
host: x86_64-apple-darwin
release: 1.63.0-nightly
LLVM version: 14.0.4
Backtrace

<backtrace>

Note that this worked for months. This is a regression for me.

@tschuett tschuett added the C-bug Category: This is a bug. label Jun 5, 2022
@lqd
Copy link
Member

lqd commented Jun 6, 2022

Is this issue related to #97375 ?

@tschuett
Copy link
Author

tschuett commented Jun 6, 2022

I found no traces of the last working nightly.

@petrochenkov
Copy link
Contributor

Is this issue related to #97375?

It's certainly somehow related because -rustc-lld-flavor didn't exist before that, but I don't know how it can happen, -Wl,-rustc-lld-flavor=darwin is in fact passed as snipped posted in the original message shows.

@tschuett
Copy link
Author

tschuett commented Jun 6, 2022

"-B/Users/awesome/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/bin/gcc-ld" "-Wl,-rustc-lld-flavor=darwin"  "-L" "/Users/awsome/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib"
  = note: lld-wrapper: -rustc-lld-flavor=<flavor> is not passed
          clang: error: linker command failed with exit code 1 (use -v to see invocation)
 cc --version
Apple clang version 13.1.6 (clang-1316.0.21.2.5)
Target: x86_64-apple-darwin21.4.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

Do you need more information?

@petrochenkov
Copy link
Contributor

Do you need more information?

Yes, output of lld-wrapper with dbg!(arg) inserted here https://github.com/rust-lang/rust/blob/master/src/tools/lld-wrapper/src/main.rs#L67

(You don't need whole compiler build to rebuild lld-wrapper, it's a single-file standalone program, it can be built with rustc directly or with cargo build, and then temporarily put into the gcc-ld directory.)

@tschuett
Copy link
Author

tschuett commented Jun 6, 2022

  = note: [src/tools/lld-wrapper/src/main.rs:73] arg = "@/var/folders/y0/n29lr9g94s12d892pb6yg3l40000gn/T/response-c2238e.txt"
          lld-wrapper: -rustc-lld-flavor=<flavor> is not passed
          clang: error: linker command failed with exit code 1 (use -v to see invocation)
    let args = env::args_os()
        .skip(1)
        .filter(|arg| match arg.to_str().and_then(|s| s.strip_prefix("-rustc-lld-flavor=")) {
            Some(suffix) => {
                dbg!(arg);
                flavor = Some(suffix.to_string());
                return false
            }
            None => {dbg!(arg); return true},
        })
        .collect::<Vec<_>>();

@tschuett
Copy link
Author

tschuett commented Jun 6, 2022

Note that main:rs73 is the failure case.

@petrochenkov
Copy link
Contributor

I see.
The command line is to long so it's moved to a temporary file and passed with @.
Neither lld-wrapper nor original (flavorless) lld support specifying the flavor inside the @ file.

Due to the way in which fn exec_linker and Command::command work -flavor for naked LLD never gets into the @ file, we should do something similar with -rustc-lld-flavor=<flavor> too.

@petrochenkov petrochenkov self-assigned this Jun 6, 2022
@tschuett
Copy link
Author

tschuett commented Jun 6, 2022

I don't know whether rustc has utilities for handling response files

@petrochenkov
Copy link
Contributor

petrochenkov commented Jun 7, 2022

Ok, it's actually clang that packs the command line into a @file, not rustc, so we cannot control or predict when it happens.
That's pretty bad.
I guess we'll have to partially revert #97375 and use something based on file names, like #97402 (comment).

@petrochenkov
Copy link
Contributor

Fixed in #100200.

Sorry for the delay, I should have fixed this two months ago.
@tschuett could you test the fix on Darwin?

matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Sep 1, 2022
…imulacrum

Change implementation of `-Z gcc-ld` and `lld-wrapper` again

This PR partially reverts rust-lang#97375 and uses the strategy described in rust-lang#97402 (comment) instead, thus fixes rust-lang#97755.
Dylan-DPC added a commit to Dylan-DPC/rust that referenced this issue Sep 1, 2022
…imulacrum

Change implementation of `-Z gcc-ld` and `lld-wrapper` again

This PR partially reverts rust-lang#97375 and uses the strategy described in rust-lang#97402 (comment) instead, thus fixes rust-lang#97755.
Dylan-DPC added a commit to Dylan-DPC/rust that referenced this issue Sep 1, 2022
…imulacrum

Change implementation of `-Z gcc-ld` and `lld-wrapper` again

This PR partially reverts rust-lang#97375 and uses the strategy described in rust-lang#97402 (comment) instead, thus fixes rust-lang#97755.
Dylan-DPC added a commit to Dylan-DPC/rust that referenced this issue Sep 1, 2022
…imulacrum

Change implementation of `-Z gcc-ld` and `lld-wrapper` again

This PR partially reverts rust-lang#97375 and uses the strategy described in rust-lang#97402 (comment) instead, thus fixes rust-lang#97755.
Dylan-DPC added a commit to Dylan-DPC/rust that referenced this issue Sep 2, 2022
…imulacrum

Change implementation of `-Z gcc-ld` and `lld-wrapper` again

This PR partially reverts rust-lang#97375 and uses the strategy described in rust-lang#97402 (comment) instead, thus fixes rust-lang#97755.
Dylan-DPC added a commit to Dylan-DPC/rust that referenced this issue Sep 2, 2022
…imulacrum

Change implementation of `-Z gcc-ld` and `lld-wrapper` again

This PR partially reverts rust-lang#97375 and uses the strategy described in rust-lang#97402 (comment) instead, thus fixes rust-lang#97755.
Dylan-DPC added a commit to Dylan-DPC/rust that referenced this issue Sep 2, 2022
…imulacrum

Change implementation of `-Z gcc-ld` and `lld-wrapper` again

This PR partially reverts rust-lang#97375 and uses the strategy described in rust-lang#97402 (comment) instead, thus fixes rust-lang#97755.
Dylan-DPC added a commit to Dylan-DPC/rust that referenced this issue Sep 2, 2022
…imulacrum

Change implementation of `-Z gcc-ld` and `lld-wrapper` again

This PR partially reverts rust-lang#97375 and uses the strategy described in rust-lang#97402 (comment) instead, thus fixes rust-lang#97755.
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Sep 2, 2022
…imulacrum

Change implementation of `-Z gcc-ld` and `lld-wrapper` again

This PR partially reverts rust-lang#97375 and uses the strategy described in rust-lang#97402 (comment) instead, thus fixes rust-lang#97755.
Dylan-DPC added a commit to Dylan-DPC/rust that referenced this issue Sep 2, 2022
…imulacrum

Change implementation of `-Z gcc-ld` and `lld-wrapper` again

This PR partially reverts rust-lang#97375 and uses the strategy described in rust-lang#97402 (comment) instead, thus fixes rust-lang#97755.
Dylan-DPC added a commit to Dylan-DPC/rust that referenced this issue Sep 2, 2022
…imulacrum

Change implementation of `-Z gcc-ld` and `lld-wrapper` again

This PR partially reverts rust-lang#97375 and uses the strategy described in rust-lang#97402 (comment) instead, thus fixes rust-lang#97755.
@bors bors closed this as completed in ed37111 Sep 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants