Skip to content

rust-objcopy on aarch64-apple-darwin cannot load libLLVM.dylib (rpath @loader_path/../lib); not covered by #163954 #164063

Description

@danieljhkim

On aarch64-apple-darwin, rust-objcopy (shipped in the rustc component) has the same broken rpath as rust-lld in #163947, but #163954 doesn't fix it. That PR only changes the rpath flags in the Lld bootstrap step. rust-objcopy is a renamed copy of llvm-objcopy from the main LLVM build (compile.rs, "copying llvm-objcopy as rust-objcopy"), so it keeps LLVM's default @loader_path/../lib.

Since #157205 (first stable: 1.98.0), rust-objcopy links libLLVM.dylib dynamically:

$ B="$(rustc +1.98.1 --print sysroot)/lib/rustlib/aarch64-apple-darwin/bin"
$ otool -L "$B/rust-objcopy"
	@rpath/libLLVM.dylib (compatibility version 1.0.0, current version 22.1.8)
	/usr/lib/libc++.1.dylib (...)
	/usr/lib/libSystem.B.dylib (...)
$ otool -l "$B/rust-objcopy" | grep -A2 LC_RPATH
         path @loader_path/../lib (offset 12)

@loader_path/../lib resolves to lib/rustlib/aarch64-apple-darwin/lib/. The rustc component ships the dylib only at lib/libLLVM.dylib, per manifest-rustc-aarch64-apple-darwin. On 1.97.0, rust-objcopy doesn't link libLLVM at all.

Impact

rustc runs rust-objcopy to strip debuginfo (the default for release profiles on macOS). When it runs without rustup's DYLD_FALLBACK_LIBRARY_PATH shim, dyld aborts it with Library not loaded: @rpath/libLLVM.dylib (SIGABRT). rustc reports that as a warning only, so the build succeeds but the binary keeps its debuginfo. For example, one of our release binaries came out at 57 MB instead of being stripped. This is easy to miss in CI and packaging.

Workaround

Same as #163947:

ln -s ../../../libLLVM.dylib "$(rustc +1.98.1 --print sysroot)/lib/rustlib/aarch64-apple-darwin/lib/libLLVM.dylib"

Suggested fix

Add @loader_path/../../../ to the rpath of the LLVM tools copied into lib/rustlib/<host>/bin, the same way #163954 does for LLD. That could go in the LLVM cmake step's ldflags, or come from an install_name_tool -add_rpath when rust-objcopy is copied. I haven't checked whether Linux rust-objcopy has a matching $ORIGIN/../../../ entry.

Meta

rustc 1.98.1 (48a229cea 2026-09-01)
host: aarch64-apple-darwin
LLVM version: 22.1.8

I've only tested 1.98.1. I expect 1.99.0 to behave the same, because #163954 doesn't touch this path.

Disclosure: diagnosis and draft were produced with an LLM (Claude) and checked by me against the toolchain on my machine.

Activity

  1. added
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on Oct 10, 2026
  2. danieljhkim commented on Oct 10, 2026

    @danieljhkim
    Author

    Update: Linux is affected as well, not just darwin. On x86_64-unknown-linux-gnu, rust-objcopy only carries RUNPATH [$ORIGIN/../lib] (checked 1.89.0, 1.96.0, 1.98.1), so outside rustup's LD_LIBRARY_PATH it fails with libLLVM.so.22.1-rust-1.98.1-stable: cannot open shared object file. Unlike darwin this isn't a recent regression. Proposed fix for both platforms: #164064.

  3. added
    O-macosOperating system: macOS
    regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.
    T-bootstrapRelevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)
    O-AArch64Armv8-A or later processors in AArch64 mode
    A-llvm-bintoolsArea: LLVM bintools (`llvm-nm` et.). Note that `llvm-tools{,-preview` has no stability guarantees.
    on Oct 10, 2026
  4. added
    I-prioritizeIssue needs a team member to assess the impact. Will be replaced by P-{low,medium,high,critical}
    on Oct 10, 2026
  5. added
    C-bugCategory: This is a bug.
    O-macosOperating system: macOS
    regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.
    O-AArch64Armv8-A or later processors in AArch64 mode
    A-llvm-bintoolsArea: LLVM bintools (`llvm-nm` et.). Note that `llvm-tools{,-preview` has no stability guarantees.
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    and removed
    O-macosOperating system: macOS
    regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.
    O-AArch64Armv8-A or later processors in AArch64 mode
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    A-llvm-bintoolsArea: LLVM bintools (`llvm-nm` et.). Note that `llvm-tools{,-preview` has no stability guarantees.
    on Oct 10, 2026
  6. removed
    I-prioritizeIssue needs a team member to assess the impact. Will be replaced by P-{low,medium,high,critical}
    on Oct 10, 2026
  7. rustbot commented on Oct 10, 2026

    @rustbot
    Collaborator

    Assigning P-high (discussion on Zulip).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-llvm-bintoolsArea: LLVM bintools (`llvm-nm` et.). Note that `llvm-tools{,-preview` has no stability guarantees.C-bugCategory: This is a bug.O-AArch64Armv8-A or later processors in AArch64 modeO-macosOperating system: macOSP-highHigh priorityT-bootstrapRelevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions