Skip to content

bootstrap: add an rpath to LLVM library for LLVM tools - #164134

Merged
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
danieljhkim:fix-rust-objcopy-rpath
Oct 13, 2026
Merged

rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
danieljhkim:fix-rust-objcopy-rpath

Conversation

@danieljhkim

@danieljhkim danieljhkim commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

Closes #164063 by adding rpath to the LLVM tool executables on both Linux and macOS, using the same approach as Lld::run.

This PR is now written by a human, resubmitting #164064 which was diagnosed and written by Claude.

Validation:

macOS

❯ otool -l ~/workspace/repos/rust/build/aarch64-apple-darwin/llvm/bin/llvm-objcopy | grep -A2 LC_RPATH
          cmd LC_RPATH
      cmdsize 40
         path @loader_path/../../../ (offset 12)
--
          cmd LC_RPATH
      cmdsize 32
         path @loader_path/../lib (offset 12)

❯ otool -L build/aarch64-apple-darwin/llvm/lib/libLLVM.dylib
build/aarch64-apple-darwin/llvm/lib/libLLVM.dylib:
        @rpath/libLLVM.dylib (compatibility version 1.0.0, current version 23.1.3)
        /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1359.0.0)
        /usr/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.12)
        /usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 2200.27.0)

linux

readelf -d build/x86_64-unknown-linux-gnu/llvm/bin/llvm-objcopy | grep RUNPATH
 0x000000000000001d (RUNPATH)            Library runpath: [$ORIGIN/../../../:$ORIGIN/../lib:$ORIGIN/../lib/x86_64-unknown-linux-gnu]

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) labels Oct 11, 2026
@danieljhkim
danieljhkim marked this pull request as ready for review October 11, 2026 03:38
@rustbot

rustbot commented Oct 11, 2026

Copy link
Copy Markdown
Collaborator

This PR changes how LLVM is built. Consider updating src/bootstrap/download-ci-llvm-stamp.

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Oct 11, 2026
@rustbot rustbot removed the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Oct 11, 2026
@rustbot

rustbot commented Oct 11, 2026

Copy link
Copy Markdown
Collaborator

Thanks for the pull request, and welcome! The Rust Project has assigned @Mark-Simulacrum (or someone else) to review your changes, you should hear from them (or someone else) within the next two weeks.

Please see the contribution instructions and our LLM policy for more information.

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: bootstrap
  • bootstrap expanded to 6 candidates
  • Random selection from Mark-Simulacrum, clubby789, jieyouxu

@danieljhkim
danieljhkim force-pushed the fix-rust-objcopy-rpath branch from cc8d7a0 to ec60f65 Compare October 11, 2026 03:40
@Kobzol

Kobzol commented Oct 11, 2026

Copy link
Copy Markdown
Member

r? kobzol

Thanks for the PR. Two remarks:

  • We now have the same logic duplicated on three places (OmpOffload, Lld and Llvm). Could you please extract it to a shared function that takes a builderand atarget`? The function should only be called if we link LLVM dynamically.
  • Won't the linker flags be also applied to libLLVM.so itself? Have you tried building it on Linux and running lld on it - if yes, what does it print?

@rustbot rustbot assigned Kobzol and unassigned Mark-Simulacrum Oct 11, 2026
@danieljhkim
danieljhkim force-pushed the fix-rust-objcopy-rpath branch from d548031 to b2d5f18 Compare October 11, 2026 23:08
@danieljhkim

danieljhkim commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor Author

r? kobzol

Thanks for the PR. Two remarks:

  • We now have the same logic duplicated on three places (OmpOffload, Lld and Llvm). Could you please extract it to a shared function that takes a builderand atarget`? The function should only be called if we link LLVM dynamically.
  • Won't the linker flags be also applied to libLLVM.so itself? Have you tried building it on Linux and running lld on it - if yes, what does it print?

@Kobzol thanks for the review.

I have updated the PR to use a common helper (llvm_lib_rpath) as requested.

The fix pushes rpath into ldflags.exe, which only applies when linking executables, and libLLVM.so is linked with the shared-library flags. Below are verifications I ran on linux.

$ readelf -d build/x86_64-unknown-linux-gnu/llvm/bin/llvm-objcopy | grep RUNPATH
 0x000000000000001d (RUNPATH)            Library runpath: [$ORIGIN/../../../:$ORIGIN/../lib:$ORIGIN/../lib/x86_64-unknown-linux-gnu]
$ readelf -d build/x86_64-unknown-linux-gnu/llvm/lib/libLLVM.so | grep RUNPATH
 0x000000000000001d (RUNPATH)            Library runpath: [$ORIGIN/../lib:$ORIGIN/../lib/x86_64-unknown-linux-gnu]
$ ldd build/x86_64-unknown-linux-gnu/llvm/lib/libLLVM.so
        linux-vdso.so.1 (0x000072d83e4ea000)
        libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x000072d834200000)
        libm.so.6 => /usr/lib/x86_64-linux-gnu/libm.so.6 (0x000072d8344da000)
        libgcc_s.so.1 => /usr/lib/x86_64-linux-gnu/libgcc_s.so.1 (0x000072d8344ac000)
        libc.so.6 => /usr/lib/x86_64-linux-gnu/libc.so.6 (0x000072d833e00000)
        /lib64/ld-linux-x86-64.so.2 (0x000072d83e4ec000)

@danieljhkim
danieljhkim force-pushed the fix-rust-objcopy-rpath branch from b2d5f18 to 8a83fe8 Compare October 12, 2026 06:37
@rust-bors

This comment has been minimized.

@danieljhkim
danieljhkim force-pushed the fix-rust-objcopy-rpath branch from 8a83fe8 to badf2aa Compare October 12, 2026 07:46
@rustbot

rustbot commented Oct 12, 2026

Copy link
Copy Markdown
Collaborator

This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

Comment thread src/bootstrap/src/core/build_steps/llvm.rs Outdated
Comment thread src/bootstrap/src/core/build_steps/llvm.rs
@danieljhkim
danieljhkim requested a review from Kobzol October 12, 2026 16:32
Extract the rpath logic shared by `Llvm`, `Lld` and `OmpOffload` into `llvm_lib_rpath`.
@danieljhkim
danieljhkim force-pushed the fix-rust-objcopy-rpath branch from dffd58f to 46395c5 Compare October 12, 2026 16:37
@Kobzol

Kobzol commented Oct 12, 2026

Copy link
Copy Markdown
Member

Thanks!

@bors r+

@rust-bors

rust-bors Bot commented Oct 12, 2026

Copy link
Copy Markdown
Contributor

📌 Commit 46395c5 has been approved by Kobzol

It is now in the queue for this repository.

@rust-bors rust-bors Bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Oct 12, 2026
rust-bors Bot pushed a commit that referenced this pull request Oct 12, 2026
Rollup of 7 pull requests

Successful merges:

 - #163798 (validate generic parameter remapping in delegation)
 - #164134 (bootstrap: add an rpath to LLVM library for LLVM tools)
 - #164190 (Tweak wording of "expected/found signature" errors)
 - #163578 (Add internal #[rustc_assert_variance] attribute for use in std)
 - #164126 (tests: Ignore dynamic-loading-cdylib on musl hosts)
 - #164171 (More `tests/rustdoc-html` cleanups)
 - #164221 (tests: cover `dead_code_pub_in_binary` expectations with `--test`)
@rust-bors
rust-bors Bot merged commit 58c344e into rust-lang:main Oct 13, 2026
14 checks passed
@rustbot rustbot added this to the 1.101.0 milestone Oct 13, 2026
rust-bors Bot pushed a commit that referenced this pull request Oct 13, 2026
Rollup merge of #164134 - danieljhkim:fix-rust-objcopy-rpath, r=Kobzol

bootstrap: add an rpath to LLVM library for LLVM tools

Closes [#164063](#164063) by adding rpath to the LLVM tool executables on both Linux and macOS, using the same approach as Lld::run.

This PR is now written by a human, resubmitting [#164064](#164064) which was diagnosed and written by Claude.

**Validation:**

macOS
```bash
❯ otool -l ~/workspace/repos/rust/build/aarch64-apple-darwin/llvm/bin/llvm-objcopy | grep -A2 LC_RPATH
          cmd LC_RPATH
      cmdsize 40
         path @loader_path/../../../ (offset 12)
--
          cmd LC_RPATH
      cmdsize 32
         path @loader_path/../lib (offset 12)

❯ otool -L build/aarch64-apple-darwin/llvm/lib/libLLVM.dylib
build/aarch64-apple-darwin/llvm/lib/libLLVM.dylib:
        @rpath/libLLVM.dylib (compatibility version 1.0.0, current version 23.1.3)
        /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1359.0.0)
        /usr/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.12)
        /usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 2200.27.0)
```

linux
```bash
readelf -d build/x86_64-unknown-linux-gnu/llvm/bin/llvm-objcopy | grep RUNPATH
 0x000000000000001d (RUNPATH)            Library runpath: [$ORIGIN/../../../:$ORIGIN/../lib:$ORIGIN/../lib/x86_64-unknown-linux-gnu]
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

4 participants