Skip to content

Commit 0679ba4

Browse files
authored
Rollup merge of #160597 - xSetech:bootstrap/build_llvm_shared, r=clubby789
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.
2 parents cf33c38 + a8d5c6c commit 0679ba4

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

  • src/bootstrap/src/core/build_steps

‎src/bootstrap/src/core/build_steps/llvm.rs‎

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -557,11 +557,14 @@ impl CommandLineStep for Llvm {
557557
// which saves both memory during parallel links and overall disk space
558558
// for the tools. We don't do this on every platform as it doesn't work
559559
// equally well everywhere.
560-
if link_shared {
561-
cfg.define("LLVM_LINK_LLVM_DYLIB", "ON");
562-
// Keep the pre-LLVM23 behavior for now.
563-
cfg.define("LLVM_VERSIONED_DYLIB_NAME_ON_DARWIN", "OFF");
564-
}
560+
//
561+
// Under normal circumstances, the dylib LINK and BUILD vars below should
562+
// be set to the same value. See #160597
563+
let llvm_dylib = if link_shared { "ON" } else { "OFF" };
564+
cfg.define("LLVM_LINK_LLVM_DYLIB", llvm_dylib);
565+
cfg.define("LLVM_BUILD_LLVM_DYLIB", llvm_dylib);
566+
// Keep the pre-LLVM23 behavior for now.
567+
cfg.define("LLVM_VERSIONED_DYLIB_NAME_ON_DARWIN", "OFF");
565568

566569
if (target.starts_with("csky")
567570
|| target.starts_with("riscv")

0 commit comments

Comments
 (0)