Skip to content

Bootstrap without creating a config.toml fails with missing rust-objcopy #133195

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

Closed
wesleywiser opened this issue Nov 19, 2024 · 4 comments · Fixed by #133207
Closed

Bootstrap without creating a config.toml fails with missing rust-objcopy #133195

wesleywiser opened this issue Nov 19, 2024 · 4 comments · Fixed by #133207
Assignees
Labels
C-bug Category: This is a bug. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)

Comments

@wesleywiser
Copy link
Member

After cloning, I expected python3 x.py test --stage 1 tests/ui to succeed but instead I got many test failures like this one:

---- [ui] tests/ui/async-await/track-caller/panic-track-caller.rs#afn stdout ----

error in revision `afn`: test compilation failed although it shouldn't!
status: exit status: 1
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/Users/wesley/Code/rust/build/aarch64-apple-darwin/stage1/bin/rustc" "/Users/wesley/Code/rust/tests/ui/async-await/track-caller/panic-track-caller.rs" "-Zthreads=1" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "-Z" "ignore-directory-in-diagnostics-source-blocks=/Users/wesley/.cargo" "-Z" "ignore-directory-in-diagnostics-source-blocks=/Users/wesley/Code/rust/vendor" "--sysroot" "/Users/wesley/Code/rust/build/aarch64-apple-darwin/stage1" "--target=aarch64-apple-darwin" "--cfg" "afn" "--check-cfg" "cfg(FALSE,afn,cls,nofeat)" "-O" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zwrite-long-types-to-disk=no" "-Cstrip=debuginfo" "-C" "prefer-dynamic" "-o" "/Users/wesley/Code/rust/build/aarch64-apple-darwin/test/ui/async-await/track-caller/panic-track-caller.afn/a" "-A" "internal_features" "-Crpath" "-Cdebuginfo=0" "-Lnative=/Users/wesley/Code/rust/build/aarch64-apple-darwin/native/rust-test-helpers" "--edition=2021"
stdout: none
--- stderr -------------------------------
error: unable to run `rust-objcopy`: No such file or directory (os error 2)

error: aborting due to 1 previous error
------------------------------------------

However, if I create a config.toml by cp config.example.toml config.toml, then the problem goes away.

I instrumented the code here with a println!() and I can see that when config.toml exists, this block runs but when config.toml does not exist, it does not run:

// `llvm-strip` is used by rustc, which is actually just a symlink to `llvm-objcopy`, so
// copy and rename `llvm-objcopy`.
//
// But only do so if llvm-tools are enabled, as bootstrap compiler might not contain any
// LLVM tools, e.g. for cg_clif.
// See <https://github.com./rust-lang/rust/issues/132719>.
let src_exe = exe("llvm-objcopy", target_compiler.host);
let dst_exe = exe("rust-objcopy", target_compiler.host);
builder.copy_link(&libdir_bin.join(src_exe), &libdir_bin.join(dst_exe));

Possibly related to #132720 cc @jieyouxu

Meta

Cloned rust-lang/rust at b71fb5e

Host is aarch64-apple-darwin

@wesleywiser wesleywiser added the C-bug Category: This is a bug. label Nov 19, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Nov 19, 2024
@jieyouxu jieyouxu self-assigned this Nov 19, 2024
@jieyouxu jieyouxu added T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Nov 19, 2024
@jieyouxu
Copy link
Member

jieyouxu commented Nov 19, 2024

Only copy, rename and link llvm-objcopy if llvm tools are enabled #132720 fixes Shipping llvm-strip w/ a symlink breaks when bootstrap compiler doesn't contain any LLVM tools #132719 because cg_clif doesn't have llvm bin tools in the bootstrap compiler.

That was because bootstrap/codegen_ssa: ship llvm-strip and use it for -Cstrip #131405 was introduced to fix Hard-coded strip path breaks Linux -> Darwin builds #131206.

And strip was hard-coded before by Fix up setting strip = true in Cargo.toml makes build scripts fail in… #130781 because using a random strip from PATH on macOS can mean using a broken homebrew strip1 as reported in Setting strip = true in Cargo.toml makes build scripts fail in release mode on MacOS #110536.

If you are using binutils strip to strip arm64 macOS binaries, it does not work fine. It produces broken binaries with invalid code signature. On arm64 macOS mandates the use of code signatures, so "unsigned" binaries use an ad-hoc code signature, but binutils seems to forget to update the ad-hoc code signature when modifying binaries. This is exactly the problem #130781 fixed by forcing XCode's strip to be used instead.
-- #131206 (comment)

Footnotes

  1. AFAIK it's still broken

@jieyouxu
Copy link
Member

jieyouxu commented Nov 19, 2024

I'm not very sure what's the proper fix here... Default config.toml-less macOS builds to acquire CI llvm and llvm bin tools?
Zulip thread: https://rust-lang.zulipchat.com/#narrow/channel/326414-t-infra.2Fbootstrap/topic/Bootstrap.20w.2Fout.20config.2Etoml.20fails.20with.20missing.20rust-objcopy

@jieyouxu
Copy link
Member

Right... because we hard code this to rust-objcopy in cg_ssa:

if sess.target.is_like_osx {
let stripcmd = "rust-objcopy";

@jieyouxu
Copy link
Member

I instrumented the code here with a println!() and I can see that when config.toml exists, this block runs but when config.toml does not exist, it does not run

Apparently without a config.toml llvm_tools_enabled is false by default

@bors bors closed this as completed in 49aec06 Nov 20, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Nov 20, 2024
Rollup merge of rust-lang#133207 - jieyouxu:macos-objcopy, r=Kobzol,bjorn3

Default-enable `llvm_tools_enabled` when no `config.toml` is present

Fixes rust-lang#133195. cc `@wesleywiser` could you double check if with this patch and no `config.toml` that you can run `./x test tests/ui --stage 1`?

`llvm-objcopy` is usually required by cg_ssa on macOS to workaround bad `strip`s.

cc `@bjorn3` I hope this doesn't break cg_clif...

r? bootstrap
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. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants