From a6bcbeb36e2a2e87a815a829f5e87a01be9aa667 Mon Sep 17 00:00:00 2001 From: Seth Junot Date: Wed, 5 Aug 2026 18:08:34 -0700 Subject: [PATCH 1/2] bootstrap: always build llvm's dylib when linking to it 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. --- src/bootstrap/src/core/build_steps/llvm.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/bootstrap/src/core/build_steps/llvm.rs b/src/bootstrap/src/core/build_steps/llvm.rs index 4ac0f6ea85679..6a7760eba693a 100644 --- a/src/bootstrap/src/core/build_steps/llvm.rs +++ b/src/bootstrap/src/core/build_steps/llvm.rs @@ -557,11 +557,11 @@ impl CommandLineStep for Llvm { // which saves both memory during parallel links and overall disk space // for the tools. We don't do this on every platform as it doesn't work // equally well everywhere. - if link_shared { - cfg.define("LLVM_LINK_LLVM_DYLIB", "ON"); - // Keep the pre-LLVM23 behavior for now. - cfg.define("LLVM_VERSIONED_DYLIB_NAME_ON_DARWIN", "OFF"); - } + let llvm_dylib = if link_shared { "ON" } else { "OFF" }; + cfg.define("LLVM_LINK_LLVM_DYLIB", llvm_dylib); + cfg.define("LLVM_BUILD_LLVM_DYLIB", llvm_dylib); + // Keep the pre-LLVM23 behavior for now. + cfg.define("LLVM_VERSIONED_DYLIB_NAME_ON_DARWIN", "OFF"); if (target.starts_with("csky") || target.starts_with("riscv") From a8d5c6ca9e674c9e573e9a150d96dc3622ce362c Mon Sep 17 00:00:00 2001 From: Seth Junot Date: Sun, 11 Oct 2026 13:18:30 -0700 Subject: [PATCH 2/2] minor: note dylib link and build vars are ideally equal --- src/bootstrap/src/core/build_steps/llvm.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/bootstrap/src/core/build_steps/llvm.rs b/src/bootstrap/src/core/build_steps/llvm.rs index 6a7760eba693a..8885a7bd89afb 100644 --- a/src/bootstrap/src/core/build_steps/llvm.rs +++ b/src/bootstrap/src/core/build_steps/llvm.rs @@ -557,6 +557,9 @@ impl CommandLineStep for Llvm { // which saves both memory during parallel links and overall disk space // for the tools. We don't do this on every platform as it doesn't work // equally well everywhere. + // + // Under normal circumstances, the dylib LINK and BUILD vars below should + // be set to the same value. See #160597 let llvm_dylib = if link_shared { "ON" } else { "OFF" }; cfg.define("LLVM_LINK_LLVM_DYLIB", llvm_dylib); cfg.define("LLVM_BUILD_LLVM_DYLIB", llvm_dylib);