Skip to content

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

Closed
@wesleywiser

Description

@wesleywiser
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

Activity

added
needs-triageThis issue may need triage. Remove it if it has been sufficiently triaged.
on Nov 19, 2024
self-assigned this
on Nov 19, 2024
added
T-bootstrapRelevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)
and removed
needs-triageThis issue may need triage. Remove it if it has been sufficiently triaged.
on Nov 19, 2024
jieyouxu

jieyouxu commented on Nov 19, 2024

@jieyouxu
Member

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

jieyouxu commented on Nov 19, 2024

@jieyouxu
Member

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

jieyouxu commented on Nov 19, 2024

@jieyouxu
Member

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

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

jieyouxu

jieyouxu commented on Nov 19, 2024

@jieyouxu
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

added a commit that references this issue on Nov 19, 2024

Rollup merge of rust-lang#133207 - jieyouxu:macos-objcopy, r=Kobzol,b…

49aec06
added a commit that references this issue on Nov 20, 2024
166cf0a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

C-bugCategory: This is a bug.T-bootstrapRelevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

    Participants

    @wesleywiser@jieyouxu@rustbot

    Issue actions

      Bootstrap without creating a config.toml fails with missing rust-objcopy · Issue #133195 · rust-lang/rust