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

Bundled LLD is not found when sysroot is changed #48772

Closed
phil-opp opened this issue Mar 6, 2018 · 7 comments
Closed

Bundled LLD is not found when sysroot is changed #48772

phil-opp opened this issue Mar 6, 2018 · 7 comments
Labels
A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. C-bug Category: This is a bug.

Comments

@phil-opp
Copy link
Contributor

phil-opp commented Mar 6, 2018

Since #48125, a LLD binary is shipped with Rust. According to this comment, it can be used by specifying "linker-flavor": "ld.lld" in target specs. However, this fails when the sysroot is changed, for example when compiling for a custom target using xargo. The following error occurs:

error: linker `lld` not found
  |
  = note: No such file or directory (os error 2)

The problem is that the lld binary is part of the host sysroot (e.g. in .rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/bin on linux), so Rust does not find it when the sysroot is changed.

@alexcrichton
Copy link
Member

After some debugging with @steveklabnik I think this may be due to the use of xargo where the sysroot is changing so rustc's unable to find its original sysroot which contains lld

@phil-opp phil-opp changed the title Bundled LLD is not found on macOS Bundled LLD is not found on for changed sysroots Mar 6, 2018
@phil-opp phil-opp changed the title Bundled LLD is not found on for changed sysroots Bundled LLD is not found when sysroot is changed Mar 6, 2018
@phil-opp
Copy link
Contributor Author

phil-opp commented Mar 6, 2018

@alexcrichton Makes sense, thanks! I updated the issue title and description.

I wonder why lld is part of the sysroot in the first place. Is it target dependent somehow? Otherwise we could put it alongside the rustc and cargo executables, maybe as rust-lld (or alternatively in some subfolder not in PATH).

@alexcrichton
Copy link
Member

Ah yeah currently it is in the sysroot to mirror the placement of other items like codegen backends and gcc.exe on Windows. We don't want to place it alongside rustc/cargo as it would otherwise pollute PATH. Additionally we want to still maintain it as a bit of an internal dependency for now which may change (but placing it in PATH may make it much harder to change later).

One of two changes need to happen here I think:

  • Either xargo should be updated to symlink in the host target's directory into the custom sysroot it creates
  • Or rustc's own logic for adding items to PATH should always add the original sysroot, even if a custom one is specified.

@pietroalbini pietroalbini added A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. C-bug Category: This is a bug. labels Mar 6, 2018
@japaric
Copy link
Member

japaric commented Mar 7, 2018

Either xargo should be updated to symlink in the host target's directory into the custom sysroot it creates

We already do this in Xargo but we copy / hardlink / symlink only the lib directory, not the bin directory which is where lld is. I'd be happy to accept a PR that adds the bin directory to Xargo's copy of the host / original sysroot.

Or rustc's own logic for adding items to PATH should always add the original sysroot, even if a custom one is specified.

We'll probably have to do this if / when Xargo functionality gets added to Cargo since the last invocation will be rustc --target $T --sysroot $S and the plan I sketched in rust-lang/cargo#4959 is to not have a copy of the original sysroot in the target directory (we don't need the original sysroot when compiling build scripts, proc macros, compiler plugins, etc. for the host because we never pass --sysroot to rustc when compiling those).

@FenrirWolf
Copy link
Contributor

I made a PR to xargo that seems to do the trick

bors bot added a commit to japaric/xargo that referenced this issue Mar 9, 2018
200: Copy bin directory to host sysroot r=japaric a=FenrirWolf

Allows custom targets to use the copy of `lld` bundled with Rust.

cc rust-lang/rust#48772
@steveklabnik
Copy link
Member

So, now that new xargo is released, should we close this?

@phil-opp
Copy link
Contributor Author

The issue is resolved by the new xargo version, so I'm going to close this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. C-bug Category: This is a bug.
Projects
None yet
Development

No branches or pull requests

6 participants