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

Building rustc-1.84.0 tarball fails when using system LLVM #135356

Closed
debohman opened this issue Jan 11, 2025 · 18 comments
Closed

Building rustc-1.84.0 tarball fails when using system LLVM #135356

debohman opened this issue Jan 11, 2025 · 18 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. O-apple Operating system: Apple (macOS, iOS, tvOS, visionOS, watchOS) O-macos Operating system: macOS T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)
Milestone

Comments

@debohman
Copy link

I have LLVM 19.1.6 installed on my system, and when building, I encounter the following:

Dist rust-std-1.84.0-x86_64-apple-darwin
	finished in 0.534 seconds
Installing stage2 std (x86_64-apple-darwin)
install: creating uninstall script at /tmp/dst.rustc/usr/local/lib/rustlib/uninstall.sh
install: installing component 'rust-std-x86_64-apple-darwin'

    rust std installed.

thread 'main' panicked at src/lib.rs:1708:24:
src.symlink_metadata() failed with No such file or directory (os error 2) ("src = /tera/tera/debo/Projects/rustc/rustc-1.84.0-src/build/x86_64-apple-darwin/stage2/lib/rustlib/x86_64-apple-darwin/bin/llvm-objcopy")
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Build completed unsuccessfully in 0:29:14

It appears that it is trying to invoke a built copy of llvm-objcopy, when it should be using the installed version.

This is a regression.

@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Jan 11, 2025
@workingjubilee workingjubilee added A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. O-macos Operating system: macOS O-apple Operating system: Apple (macOS, iOS, tvOS, visionOS, watchOS) labels Jan 11, 2025
@lqd lqd added T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) and removed A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. labels Jan 11, 2025
@jieyouxu jieyouxu added C-bug Category: This is a bug. A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Jan 11, 2025
@debohman
Copy link
Author

The commit that is causing the build to blow up is d8ab230e731ea0bcaf299b86e82558f354f8e2b0:

commit d8ab230e731ea0bcaf299b86e82558f354f8e2b0
Author: David Wood <[email protected]>
Date:   Tue Oct 8 15:19:37 2024 +0100

    bootstrap: include `llvm-objcopy` in dist

There seems to be other work involved in this that I have not identified yet. This scheme needs to be conditional based on whether we are building and also installing the llvm tools.

Note that I have the following in my config.toml:

llvm-tools = false

@jieyouxu
Copy link
Member

jieyouxu commented Jan 12, 2025

The problem is that the compiler unconditionally expects llvm-tools to be available (specifically llvm-objcopy to workaround some nasty macOS strip problems). I gated this on (1) llvm being enabled and (2) llvm-tools being enabled in #132720, but we expect this to be available in both dist and compile flows as implemented in #131405.

When you disable llvm-tools in config.toml, we probably need to require that system llvm-tools could be found and a system llvm-objcopy is copied instead, probably by querying system llvm-config.

@debohman
Copy link
Author

Okay, but if we are not building LLVM and hence not installing the llvm-tools, then it seems to me that we should be creating a symlink from the installed llvm-objcopy to rust-objcopy for the compiler.

@onur-ozkan
Copy link
Member

#134240 fixes that, but it's not on stable yet.

@debohman
Copy link
Author

I made an error in my previous comment. The correct behavior is to copy the system llvm-objcopy to rust-objcopy in the destination root.

@debohman
Copy link
Author

#134240 fixes that, but it's not on stable yet.

Yes, that will fix this problem, but you still end up with a broken toolchain due to the missing rust-objcopy.

@debohman
Copy link
Author

% cargo build --release                                                
   Compiling sieve v0.1.0 (/tera/tera/debo/Projects/misc/sieve/rustsieve)
error: unable to run `rust-objcopy`: No such file or directory (os error 2)

error: could not compile `sieve` (bin "sieve") due to 1 previous error
% rustc --version
rustc 1.84.0

@debohman
Copy link
Author

% sudo cp /usr/local/bin/llvm-objcopy /usr/local/bin/rust-objcopy
% cargo build --release                                          
   Compiling sieve v0.1.0 (/tera/tera/debo/Projects/misc/sieve/rustsieve)
    Finished `release` profile [optimized] target(s) in 0.60s

@onur-ozkan
Copy link
Member

onur-ozkan commented Jan 14, 2025

#134240 fixes that, but it's not on stable yet.

Yes, that will fix this problem, but you still end up with a broken toolchain due to the missing rust-objcopy.

Created a separate issue for that

@onur-ozkan
Copy link
Member

I made an error in my previous comment. The correct behavior is to copy the system llvm-objcopy to rust-objcopy in the destination root.

Seems like we are already doing that

let llvm_bin_dir =
command(llvm_config).arg("--bindir").run_capture_stdout(builder).stdout();
let llvm_bin_dir = Path::new(llvm_bin_dir.trim());
// Since we've already built the LLVM tools, install them to the sysroot.
// This is the equivalent of installing the `llvm-tools-preview` component via
// rustup, and lets developers use a locally built toolchain to
// build projects that expect llvm tools to be present in the sysroot
// (e.g. the `bootimage` crate).
for tool in LLVM_TOOLS {

but you have to set llvm-tools=true to be able to do that.

@bryteise
Copy link

I made an error in my previous comment. The correct behavior is to copy the system llvm-objcopy to rust-objcopy in the destination root.

Seems like we are already doing that

Could this be the cause of my issue with the following?

thread 'main' panicked at src/utils/tarball.rs:397:21: generated a symlink in a tarball: /builddir/build/BUILD/rustc-1.84.0-src/build/tmp/tarball/rustc/x86_64-unknown-linux-gnu/rustc-1.84.0-x86_64-unknown-linux-gnu/rustc/lib/rustlib/x86_64-unknown-linux-gnu/bin/rust-objcopy

@onur-ozkan
Copy link
Member

I made an error in my previous comment. The correct behavior is to copy the system llvm-objcopy to rust-objcopy in the destination root.

Seems like we are already doing that

Could this be the cause of my issue with the following?

thread 'main' panicked at src/utils/tarball.rs:397:21: generated a symlink in a tarball: /builddir/build/BUILD/rustc-1.84.0-src/build/tmp/tarball/rustc/x86_64-unknown-linux-gnu/rustc-1.84.0-x86_64-unknown-linux-gnu/rustc/lib/rustlib/x86_64-unknown-linux-gnu/bin/rust-objcopy

That seems like a different problem... Can you file an issue with more details?

@debohman
Copy link
Author

I made an error in my previous comment. The correct behavior is to copy the system llvm-objcopy to rust-objcopy in the destination root.

Seems like we are already doing that

rust/src/bootstrap/src/core/build_steps/compile.rs

Lines 1765 to 1774 in 00ded39

let llvm_bin_dir =
command(llvm_config).arg("--bindir").run_capture_stdout(builder).stdout();
let llvm_bin_dir = Path::new(llvm_bin_dir.trim());

// Since we've already built the LLVM tools, install them to the sysroot.
// This is the equivalent of installing the llvm-tools-preview component via
// rustup, and lets developers use a locally built toolchain to
// build projects that expect llvm tools to be present in the sysroot
// (e.g. the bootimage crate).
for tool in LLVM_TOOLS {
but you have to set llvm-tools=true to be able to do that.

Isn't llvm-tools relevant only if you are building LLVM as part of rust?

@debohman
Copy link
Author

I set llvm-tools=true and the build did not install rust-objcopy into the destination root.

@onur-ozkan
Copy link
Member

I set llvm-tools=true and the build did not install rust-objcopy into the destination root.

#135472 (comment)

@debohman
Copy link
Author

debohman commented Jan 17, 2025

I can verify that setting llvm-tools=true in the configuration does install rust-objcopy into the destination root. Sorry, I was looking for it in the wrong location yesterday.

I have tested both version 1.84.0 and the current beta branch and verified that both generate operable destination roots. I did need to patch 1.84.0 with the change from #134240 in order to get it to build. I suggest that this PR covers getting #134240 into a 1.84 patch release.

@cuviper
Copy link
Member

cuviper commented Jan 30, 2025

Should be fixed now in 1.84.1.

@cuviper cuviper closed this as completed Jan 30, 2025
@cuviper cuviper added this to the 1.84.1 milestone Jan 30, 2025
@debohman
Copy link
Author

Verified in 1.84.1.

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. O-apple Operating system: Apple (macOS, iOS, tvOS, visionOS, watchOS) O-macos Operating system: macOS T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)
Projects
None yet
Development

No branches or pull requests

8 participants