Skip to content

link Enzyme and the offload with in-tree lld if possible - #162824

Open
ZuseZ4 wants to merge 1 commit into
rust-lang:mainfrom
ZuseZ4:use-lld-more
Open

ZuseZ4 wants to merge 1 commit into
rust-lang:mainfrom
ZuseZ4:use-lld-more

Conversation

@ZuseZ4

@ZuseZ4 ZuseZ4 commented Sep 15, 2026

Copy link
Copy Markdown
Member

I have multiple LLVM builds on all my computers, and often enough ended up with an older lld version on the path, which often breaks Offload builds.
I've also seen autodiff builds take forever since some of it's files are huge, and builds somehow end up using ld.

This fixes both by just using our up-to-date in-tree lld (if available).
I used an LLM to implement a couple of bootstrap fixes, including this one. I then split this one out and cleaned it up.

r? kobzol

closes: #160584

@rustbot

rustbot commented Sep 15, 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 Sep 15, 2026
@rustbot

rustbot commented Sep 15, 2026

Copy link
Copy Markdown
Collaborator

kobzol is not on the review rotation at the moment.
They may take a while to respond.

@ZuseZ4

ZuseZ4 commented Sep 15, 2026

Copy link
Copy Markdown
Member Author

This should be the last bootstrap PR for a while.
I then (might) just come with a really big one in the future to delete most of this ^^
Now that @sgasho's PR is in, we don't rely on the clang-linker-wrapper anymore and have a bit more control.
The OffloadBinary format was only needed when passing artifacts around between clang tooling, which keeps wrapping and unwrapping IR/asm. Since we're in full control now, we can delete a lot of that.

@ZuseZ4 ZuseZ4 mentioned this pull request Sep 15, 2026
5 tasks
Comment thread src/bootstrap/src/core/build_steps/llvm.rs Outdated
}

let lld_bin = builder.ensure(Lld { target }).join("bin");
ldflags.push_all(format!("-B{} -fuse-ld=lld", lld_bin.display()));

@Kobzol Kobzol Sep 16, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This duplicates the -fuse-ld=lld flag set on line 846, right?

View changes since the review

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep. I don't think it's harmful, but I moved it to avoid it.

@rust-log-analyzer

This comment has been minimized.

@rust-bors

This comment has been minimized.

@rustbot

rustbot commented Sep 17, 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.

@Kobzol

Kobzol commented Sep 18, 2026

Copy link
Copy Markdown
Member

@bors r+

@rust-bors

rust-bors Bot commented Sep 18, 2026

Copy link
Copy Markdown
Contributor

📌 Commit 752e7c0 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 Sep 18, 2026
Zalathar added a commit to Zalathar/rust that referenced this pull request Sep 18, 2026
link Enzyme and the offload with in-tree lld if possible

I have multiple LLVM builds on all my computers, and often enough ended up with an older lld version on the path, which often breaks Offload builds.
I've also seen autodiff builds take forever since some of it's files are huge, and builds somehow end up using ld.

This fixes both by just using our up-to-date in-tree lld (if available).
I used an LLM to implement a couple of bootstrap fixes, including this one. I then split this one out and cleaned it up.

r? kobzol

closes: rust-lang#160584
rust-bors Bot pushed a commit that referenced this pull request Sep 18, 2026
Rollup of 9 pull requests

Successful merges:

 - #161777 (Add Natvis visualiser and debuginfo tests for `f128`)
 - #162423 (Rename the src install build step to rust-src.)
 - #162824 (link Enzyme and the offload with in-tree lld if possible)
 - #161803 (Fix docs of make_ascii_lowercase/make_ascii_upercase)
 - #162256 (Add mentions to sync back `RELEASES.md` to the `main` branch)
 - #162803 (docs(num): add documentation for `NonZero::from_str`)
 - #162906 (Move more `rustdoc-html` tests in the right location)
 - #162922 (An assortment of polonius tweaks)
 - #162930 (Use niche length type for strlen to guarantee `isize::MAX` bound)
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Sep 18, 2026
link Enzyme and the offload with in-tree lld if possible

I have multiple LLVM builds on all my computers, and often enough ended up with an older lld version on the path, which often breaks Offload builds.
I've also seen autodiff builds take forever since some of it's files are huge, and builds somehow end up using ld.

This fixes both by just using our up-to-date in-tree lld (if available).
I used an LLM to implement a couple of bootstrap fixes, including this one. I then split this one out and cleaned it up.

r? kobzol

closes: rust-lang#160584
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Sep 18, 2026
link Enzyme and the offload with in-tree lld if possible

I have multiple LLVM builds on all my computers, and often enough ended up with an older lld version on the path, which often breaks Offload builds.
I've also seen autodiff builds take forever since some of it's files are huge, and builds somehow end up using ld.

This fixes both by just using our up-to-date in-tree lld (if available).
I used an LLM to implement a couple of bootstrap fixes, including this one. I then split this one out and cleaned it up.

r? kobzol

closes: rust-lang#160584
rust-bors Bot pushed a commit that referenced this pull request Sep 18, 2026
…uwer

Rollup of 15 pull requests

Successful merges:

 - #160401 (sparc: make ABI consistent with clang)
 - #161777 (Add Natvis visualiser and debuginfo tests for `f128`)
 - #162423 (Rename the src install build step to rust-src.)
 - #162740 (stdarch subtree update)
 - #162824 (link Enzyme and the offload with in-tree lld if possible)
 - #162832 (add `Div` and `Mul` for `Complex<{float}>`)
 - #161005 (fix: unfulfilled nested dead code lint)
 - #161803 (Fix docs of make_ascii_lowercase/make_ascii_upercase)
 - #162256 (Add mentions to sync back `RELEASES.md` to the `main` branch)
 - #162661 (simplify `Target::GenericParam`)
 - #162666 (Tidy footnote in `platform-support.md`)
 - #162803 (docs(num): add documentation for `NonZero::from_str`)
 - #162906 (Move more `rustdoc-html` tests in the right location)
 - #162922 (An assortment of polonius tweaks)
 - #162930 (Use niche length type for strlen to guarantee `isize::MAX` bound)
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Sep 18, 2026
link Enzyme and the offload with in-tree lld if possible

I have multiple LLVM builds on all my computers, and often enough ended up with an older lld version on the path, which often breaks Offload builds.
I've also seen autodiff builds take forever since some of it's files are huge, and builds somehow end up using ld.

This fixes both by just using our up-to-date in-tree lld (if available).
I used an LLM to implement a couple of bootstrap fixes, including this one. I then split this one out and cleaned it up.

r? kobzol

closes: rust-lang#160584
rust-bors Bot pushed a commit that referenced this pull request Sep 18, 2026
…uwer

Rollup of 15 pull requests

Successful merges:

 - #160401 (sparc: make ABI consistent with clang)
 - #161777 (Add Natvis visualiser and debuginfo tests for `f128`)
 - #162423 (Rename the src install build step to rust-src.)
 - #162740 (stdarch subtree update)
 - #162824 (link Enzyme and the offload with in-tree lld if possible)
 - #161005 (fix: unfulfilled nested dead code lint)
 - #161803 (Fix docs of make_ascii_lowercase/make_ascii_upercase)
 - #162256 (Add mentions to sync back `RELEASES.md` to the `main` branch)
 - #162661 (simplify `Target::GenericParam`)
 - #162666 (Tidy footnote in `platform-support.md`)
 - #162803 (docs(num): add documentation for `NonZero::from_str`)
 - #162906 (Move more `rustdoc-html` tests in the right location)
 - #162922 (An assortment of polonius tweaks)
 - #162929 (Update unicode_data to Unicode version 18.0.0)
 - #162930 (Use niche length type for strlen to guarantee `isize::MAX` bound)
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Sep 18, 2026
link Enzyme and the offload with in-tree lld if possible

I have multiple LLVM builds on all my computers, and often enough ended up with an older lld version on the path, which often breaks Offload builds.
I've also seen autodiff builds take forever since some of it's files are huge, and builds somehow end up using ld.

This fixes both by just using our up-to-date in-tree lld (if available).
I used an LLM to implement a couple of bootstrap fixes, including this one. I then split this one out and cleaned it up.

r? kobzol

closes: rust-lang#160584
rust-bors Bot pushed a commit that referenced this pull request Sep 18, 2026
…uwer

Rollup of 14 pull requests

Successful merges:

 - #160401 (sparc: make ABI consistent with clang)
 - #161777 (Add Natvis visualiser and debuginfo tests for `f128`)
 - #162740 (stdarch subtree update)
 - #162824 (link Enzyme and the offload with in-tree lld if possible)
 - #161005 (fix: unfulfilled nested dead code lint)
 - #161803 (Fix docs of make_ascii_lowercase/make_ascii_upercase)
 - #162256 (Add mentions to sync back `RELEASES.md` to the `main` branch)
 - #162661 (simplify `Target::GenericParam`)
 - #162666 (Tidy footnote in `platform-support.md`)
 - #162803 (docs(num): add documentation for `NonZero::from_str`)
 - #162906 (Move more `rustdoc-html` tests in the right location)
 - #162922 (An assortment of polonius tweaks)
 - #162929 (Update unicode_data to Unicode version 18.0.0)
 - #162930 (Use niche length type for strlen to guarantee `isize::MAX` bound)
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Sep 18, 2026
link Enzyme and the offload with in-tree lld if possible

I have multiple LLVM builds on all my computers, and often enough ended up with an older lld version on the path, which often breaks Offload builds.
I've also seen autodiff builds take forever since some of it's files are huge, and builds somehow end up using ld.

This fixes both by just using our up-to-date in-tree lld (if available).
I used an LLM to implement a couple of bootstrap fixes, including this one. I then split this one out and cleaned it up.

r? kobzol

closes: rust-lang#160584
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Sep 18, 2026
link Enzyme and the offload with in-tree lld if possible

I have multiple LLVM builds on all my computers, and often enough ended up with an older lld version on the path, which often breaks Offload builds.
I've also seen autodiff builds take forever since some of it's files are huge, and builds somehow end up using ld.

This fixes both by just using our up-to-date in-tree lld (if available).
I used an LLM to implement a couple of bootstrap fixes, including this one. I then split this one out and cleaned it up.

r? kobzol

closes: rust-lang#160584
rust-bors Bot pushed a commit that referenced this pull request Sep 18, 2026
…uwer

Rollup of 20 pull requests

Successful merges:

 - #160401 (sparc: make ABI consistent with clang)
 - #162715 (don't calculate dtors if the self ty has impossible bounds)
 - #162740 (stdarch subtree update)
 - #162824 (link Enzyme and the offload with in-tree lld if possible)
 - #162946 (Simplify query stack printing)
 - #161005 (fix: unfulfilled nested dead code lint)
 - #161246 (Normalize non-rigid aliases in ty_known_to_outlive)
 - #161803 (Fix docs of make_ascii_lowercase/make_ascii_upercase)
 - #162256 (Add mentions to sync back `RELEASES.md` to the `main` branch)
 - #162661 (simplify `Target::GenericParam`)
 - #162666 (Tidy footnote in `platform-support.md`)
 - #162803 (docs(num): add documentation for `NonZero::from_str`)
 - #162879 (use u64 limbs in core::num::bignum)
 - #162903 (PassWrapper: adapt to LLVM reading exception model from module flag)
 - #162905 (c-variadic: add checks for windows i686)
 - #162906 (Move more `rustdoc-html` tests in the right location)
 - #162922 (An assortment of polonius tweaks)
 - #162929 (Update unicode_data to Unicode version 18.0.0)
 - #162930 (Use niche length type for strlen to guarantee `isize::MAX` bound)
 - #162960 (Guard types with unstable `Allocator` params ahead of partial stabilization)
@JonathanBrouwer

Copy link
Copy Markdown
Member

💔 I suspect this PR failed tests as part of a rollup
@bors r-

After fixing the problem, consider running a try job for the failed job before re-approving.

Link to failure: #162983 (comment)

@rust-bors rust-bors Bot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Sep 18, 2026
@rust-bors

rust-bors Bot commented Sep 18, 2026

Copy link
Copy Markdown
Contributor

This pull request was unapproved.

This PR was contained in a rollup (#162983), which was unapproved.

View changes since this unapproval

@JonathanBrouwer

Copy link
Copy Markdown
Member

@bors try jobs=dist-x86_64-llvm-mingw

@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Sep 18, 2026
link Enzyme and the offload with in-tree lld if possible


try-job: dist-x86_64-llvm-mingw
@ZuseZ4

ZuseZ4 commented Sep 18, 2026

Copy link
Copy Markdown
Member Author

Oh, this was aimed at and tested on x86-linux, since that's where offload is currently active, but I guess via autodiff it could have broken mingw, even though I'd find it a bit surprising. I'll have a look, sorry

@rust-bors

rust-bors Bot commented Sep 18, 2026

Copy link
Copy Markdown
Contributor

💔 Test for f70d840 failed: CI. Failed job:

@rust-log-analyzer

Copy link
Copy Markdown
Collaborator

The job dist-x86_64-llvm-mingw failed! Check out the build log: (web) (plain enhanced) (plain)

Click to see the possible cause of the failure (guessed by this bot)
CMAKE_x86_64-pc-windows-gnullvm = None
CMAKE_x86_64_pc_windows_gnullvm = None
HOST_CMAKE = None
CMAKE = None
running: "cmake" "D:\\a\\rust\\rust\\src/tools/enzyme/enzyme/" "-G" "Ninja" "-DCMAKE_INSTALL_MESSAGE=LAZY" "-DCMAKE_C_COMPILER_LAUNCHER=sccache" "-DCMAKE_CXX_COMPILER_LAUNCHER=sccache" "-DCMAKE_C_COMPILER=clang.exe" "-DCMAKE_CXX_COMPILER=clang++.exe" "-DCMAKE_ASM_COMPILER=clang.exe" "-DCMAKE_C_FLAGS= -Wno-deprecated -ffunction-sections -fdata-sections -m64 --target=x86_64-pc-windows-gnu -w -fdebug-prefix-map=D:\\a\\rust\\rust=/rustc/llvm" "-DCMAKE_CXX_FLAGS= -Wno-deprecated -ffunction-sections -fdata-sections -m64 --target=x86_64-pc-windows-gnu -w -fdebug-prefix-map=D:\\a\\rust\\rust=/rustc/llvm" "-DCMAKE_SHARED_LINKER_FLAGS= -BD:\\a\\rust\\rust\\build\\x86_64-pc-windows-gnullvm\\lld\\bin -fuse-ld=lld -static-libstdc++" "-DCMAKE_MODULE_LINKER_FLAGS= -BD:\\a\\rust\\rust\\build\\x86_64-pc-windows-gnullvm\\lld\\bin -fuse-ld=lld -static-libstdc++" "-DCMAKE_EXE_LINKER_FLAGS= -BD:\\a\\rust\\rust\\build\\x86_64-pc-windows-gnullvm\\lld\\bin -fuse-ld=lld -static-libstdc++" "-DLLVM_ENABLE_ASSERTIONS=ON" "-DENZYME_EXTERNAL_SHARED_LIB=ON" "-DENZYME_BC_LOADER=OFF" "-DLLVM_DIR=D:\\a\\rust\\rust\\build\\x86_64-pc-windows-gnullvm\\llvm\\lib\\cmake\\llvm" "-DCMAKE_INSTALL_PREFIX=D:\\a\\rust\\rust\\build\\x86_64-pc-windows-gnullvm\\enzyme" "-DCMAKE_ASM_FLAGS= -ffunction-sections -fdata-sections -m64 --target=x86_64-pc-windows-gnu -w" "-DCMAKE_BUILD_TYPE=Release"
-- The C compiler identification is Clang 21.1.5
-- The CXX compiler identification is Clang 21.1.5
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - failed
-- Check for working C compiler: D:/a/rust/rust/clang64/bin/clang.exe
---
  is not able to compile a simple test program.

  It fails with the following output:

    Change Dir: 'D:/a/rust/rust/build/x86_64-pc-windows-gnullvm/enzyme/build/CMakeFiles/CMakeScratch/TryCompile-esl7lj'
    
    Run Build Command(s): D:/a/rust/rust/ninja/ninja.exe -v cmTC_548cd
    [1/2] D:\a\rust\rust\clang64\bin\clang.exe   -Wno-deprecated -ffunction-sections -fdata-sections -m64 --target=x86_64-pc-windows-gnu -w -fdebug-prefix-map=D:\a\rust\rust=/rustc/llvm -MD -MT CMakeFiles/cmTC_548cd.dir/testCCompiler.c.obj -MF CMakeFiles\cmTC_548cd.dir\testCCompiler.c.obj.d -o CMakeFiles/cmTC_548cd.dir/testCCompiler.c.obj -c D:/a/rust/rust/build/x86_64-pc-windows-gnullvm/enzyme/build/CMakeFiles/CMakeScratch/TryCompile-esl7lj/testCCompiler.c
    [2/2] C:\Windows\system32\cmd.exe /C "cd . && D:\a\rust\rust\clang64\bin\clang.exe -Wno-deprecated -ffunction-sections -fdata-sections -m64 --target=x86_64-pc-windows-gnu -w -fdebug-prefix-map=D:\a\rust\rust=/rustc/llvm -BD:\a\rust\rust\build\x86_64-pc-windows-gnullvm\lld\bin -fuse-ld=lld -static-libstdc++ CMakeFiles/cmTC_548cd.dir/testCCompiler.c.obj -o cmTC_548cd.exe -Wl,--out-implib,libcmTC_548cd.dll.a -Wl,--major-image-version,0,--minor-image-version,0  -lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32 && cd ."
    FAILED: cmTC_548cd.exe 
    C:\Windows\system32\cmd.exe /C "cd . && D:\a\rust\rust\clang64\bin\clang.exe -Wno-deprecated -ffunction-sections -fdata-sections -m64 --target=x86_64-pc-windows-gnu -w -fdebug-prefix-map=D:\a\rust\rust=/rustc/llvm -BD:\a\rust\rust\build\x86_64-pc-windows-gnullvm\lld\bin -fuse-ld=lld -static-libstdc++ CMakeFiles/cmTC_548cd.dir/testCCompiler.c.obj -o cmTC_548cd.exe -Wl,--out-implib,libcmTC_548cd.dll.a -Wl,--major-image-version,0,--minor-image-version,0  -lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32 && cd ."
    clang-21: error: linker command failed due to signal (use -v to see invocation)

    ninja: build stopped: subcommand failed.
    
    

---
   0: __rustc::rust_begin_unwind
             at /rustc/cbae9b4cae2b108f6a3d18cfe6075714bb739463/library\std\src/panicking.rs:679:5
   1: core::panicking::panic_fmt
             at /rustc/cbae9b4cae2b108f6a3d18cfe6075714bb739463/library\core\src/panicking.rs:80:14
   2: cmake::fail
   3: cmake::run
   4: <cmake::Config>::build
   5: <bootstrap::core::build_steps::llvm::Enzyme as bootstrap::core::builder::CommandLineStep>::run
             at .\src\bootstrap\src\core\build_steps\llvm.rs:1623:13
   6: <bootstrap::core::build_steps::llvm::Enzyme as bootstrap::core::builder::Step>::run
             at .\src\bootstrap\src\core\builder\mod.rs:134:9
   7: <bootstrap::core::builder::Builder>::ensure::<bootstrap::core::build_steps::llvm::Enzyme>
             at .\src\bootstrap\src\core\builder\mod.rs:1637:36
   8: <bootstrap::core::build_steps::dist::Enzyme as bootstrap::core::builder::CommandLineStep>::run
             at .\src\bootstrap\src\core\build_steps\dist.rs:2837:30
   9: <bootstrap::core::build_steps::dist::Enzyme as bootstrap::core::builder::Step>::run
             at .\src\bootstrap\src\core\builder\mod.rs:134:9
  10: <bootstrap::core::builder::Builder>::ensure::<bootstrap::core::build_steps::dist::Enzyme>
             at .\src\bootstrap\src\core\builder\mod.rs:1637:36
  11: <bootstrap::core::build_steps::dist::Enzyme as bootstrap::core::builder::CommandLineStep>::make_run
             at .\src\bootstrap\src\core\build_steps\dist.rs:2824:21
  12: <bootstrap::core::builder::CommandLineStepDescription>::maybe_run
             at .\src\bootstrap\src\core\builder\mod.rs:470:13
  13: bootstrap::core::builder::cli_paths::match_paths_to_steps_and_run
             at .\src\bootstrap\src\core\builder\cli_paths.rs:138:19
  14: <bootstrap::core::builder::Builder>::run_step_descriptions
             at .\src\bootstrap\src\core\builder\mod.rs:1173:9
  15: <bootstrap::core::builder::Builder>::execute_cli

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

Labels

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)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bootstrap build order - missing lld for autodiff/offload

5 participants