Skip to content

bootstrap: always build llvm's dylib when linking to it - #160597

Open
xSetech wants to merge 1 commit into
rust-lang:mainfrom
xSetech:bootstrap/build_llvm_shared
Open

bootstrap: always build llvm's dylib when linking to it#160597
xSetech wants to merge 1 commit into
rust-lang:mainfrom
xSetech:bootstrap/build_llvm_shared

Conversation

@xSetech

@xSetech xSetech commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

The bootstrap example says that LLVM's dynamic library will be built when llvm.link-shared is true. It actually only set the flag that enables linking against the library (LLVM_LINK_LLVM_DYLIB). It should also set LLVM_BUILD_LLVM_DYLIB.

On clean builds, LLVM's configuration helpfully sets the BUILD flag to true if the LINK flag is true. If a dev toggles link-shared from false to true after an initial build, LINK will be "ON" (given by bootstrap) and BUILD will be "OFF" (from the cmake cache). The library to link will not be built, causing the build to fail at link time.

With this change, the library is always built when it's to be linked. Conversely, it is not built if it is not to be linked.

  • I did not use an LLM to create a change in this PR.
  • I used an LLM to create a change in this PR, and I have explained below how it was used.

The bootstrap example says that LLVM's dynamic library will be built
when llvm.link-shared is true. It actually only set the flag that enables
linking against the library (LLVM_LINK_LLVM_DYLIB). It should also set
LLVM_BUILD_LLVM_DYLIB.

On clean builds, LLVM's configuration helpfully sets the BUILD flag to
true if the LINK flag is true. If a dev toggles link-shared from false
to true after an initial build, LINK will be "ON" (given by bootstrap)
and BUILD will be "OFF" (from the cmake cache). The library to link will
not be built, causing the build to fail at link time.

With this change, the library is always built when it's to be linked.
Conversely, it is not built if it is not to be linked.
@rustbot

rustbot commented Aug 6, 2026

Copy link
Copy Markdown
Collaborator

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

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) labels Aug 6, 2026
@rustbot

rustbot commented Aug 6, 2026

Copy link
Copy Markdown
Collaborator

r? @clubby789

rustbot has assigned @clubby789.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

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

@xSetech

xSetech commented Aug 6, 2026

Copy link
Copy Markdown
Contributor Author

@nikic I moved LLVM_VERSIONED_DYLIB_NAME_ON_DARWIN=OFF out of the block so it's always off. Seems like that was your intent from #158734, but let me know if it actually depends on llvm_link_shared()

@Kobzol

Kobzol commented Aug 6, 2026

Copy link
Copy Markdown
Member

On clean builds, LLVM's configuration helpfully sets the BUILD flag to true if the LINK flag is true. If a dev toggles link-shared from false to true after an initial build, LINK will be "ON" (given by bootstrap) and BUILD will be "OFF" (from the cmake cache). The library to link will not be built, causing the build to fail at link time.

I wonder how does that show up? Because if LLVM was already built locally, and you modify the LLVM bootstrap settings, CMake won't be involved at all, because bootstrap currently caches the whole build and doesn't examine whether the settings changed or not.

@xSetech

xSetech commented Aug 6, 2026

Copy link
Copy Markdown
Contributor Author

On clean builds, LLVM's configuration helpfully sets the BUILD flag to true if the LINK flag is true. If a dev toggles link-shared from false to true after an initial build, LINK will be "ON" (given by bootstrap) and BUILD will be "OFF" (from the cmake cache). The library to link will not be built, causing the build to fail at link time.

I wonder how does that show up? Because if LLVM was already built locally, and you modify the LLVM bootstrap settings, CMake won't be involved at all, because bootstrap currently caches the whole build and doesn't examine whether the settings changed or not.

That's right. LLVM configuration can be rerun by removing .llvm-stamp. See the following quote.

By default, the Rust build system does not check for changes to the LLVM source code or its build configuration settings. So, if you need to rebuild the LLVM that is linked into rustc, first delete the file .llvm-stamp, which should be located in build/host/llvm/.

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

Labels

S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. 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.

4 participants