Skip to content

Install LLVM DLL in the right place on Windows#152609

Merged
rust-bors[bot] merged 3 commits intorust-lang:mainfrom
mati865:gnullvm-llvm-dll
Feb 17, 2026
Merged

Install LLVM DLL in the right place on Windows#152609
rust-bors[bot] merged 3 commits intorust-lang:mainfrom
mati865:gnullvm-llvm-dll

Conversation

@mati865
Copy link
Member

@mati865 mati865 commented Feb 14, 2026

Continuation of #151795 towards #151774.

Unlike other systems, Windows requires runtime libraries to be present in PATH or right next to the binary.
So, we copy the library next to the binary as the easier solution.

Tested building rust-openssl in debug and release modes, but the difference is within noise margin.

@rustbot rustbot added A-CI Area: Our Github Actions CI A-testsuite Area: The testsuite used to check the correctness of rustc 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) T-infra Relevant to the infrastructure team, which will review and decide on the PR/issue. labels Feb 14, 2026
@rustbot
Copy link
Collaborator

rustbot commented Feb 14, 2026

r? @Mark-Simulacrum

rustbot has assigned @Mark-Simulacrum.
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

/// compiler's sysroot.
///
/// For example this returns `lib` on Unix and `bin` on Windows.
pub fn sysroot_runtime_libdir_relative(&self, compiler: Compiler) -> PathBuf {
Copy link
Member

Choose a reason for hiding this comment

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

What is the difference with relative_libdir? And if there is difference when should you choose this one over relative_libdir and vice versa?

Copy link
Member Author

@mati865 mati865 Feb 14, 2026

Choose a reason for hiding this comment

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

To be honest, I have no idea what is the deal with stage == 0, but I thought leaving it there would be safer.

Also, libdir_relative doesn't "Windowsize" the path, so uncommenting install.libdir in bootstrap.toml will result in a broken Windows build because the DLLs would go to build/host/stage1/lib.
Although I don't know how much we should care about it since it doesn't work anyway. With this PR, libLLVM will correctly go to stage1/bin, but rustc_driver and std still go to stage1/lib.

Technically, all shared objects should be handled by sysroot_runtime_libdir_relative or similar function.

Copy link
Member Author

Choose a reason for hiding this comment

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

I can change this PR to use relative_libdir for installing LLVM, if we don't care about install.libdir case and stage0 is not a problem.

Copy link
Member

Choose a reason for hiding this comment

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

install.libdir is meant for the Unix world, not for Windows. Setting install.libdir on Windows probably already results in a broken build before this PR as rustc_driver.dll ends up in the wrong dir.

Copy link
Member Author

Choose a reason for hiding this comment

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

Fair enough, removed the new helper.

@@ -2533,7 +2533,7 @@ fn maybe_install_llvm(
),
)]
pub fn maybe_install_llvm_target(builder: &Builder<'_>, target: TargetSelection, sysroot: &Path) {
let dst_libdir = sysroot.join("lib/rustlib").join(target).join("lib");
let dst_libdir = sysroot.join("lib/rustlib").join(target).join(libdir(target));
Copy link
Member

Choose a reason for hiding this comment

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

Rustc probably expects it in lib when linking. I don't think this copy of the LLVM dylib is every used at runtime.

Copy link
Member Author

Choose a reason for hiding this comment

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

That wouldn't work well on Windows. With both GNU toolchains you can link to DLL directly, but it's a hit-or-miss situation. Linking via import library is the right way to do it.
With MSVC's link.exe and lld-link the situation is clearer - you cannot link DLL directly at all, the import library is the only way.

Maybe we don't need it at all and should bundle the import library instead on Windows?

Copy link
Member

Choose a reason for hiding this comment

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

This function should be installing both the DLL and the import library into the rustc linker path. Putting just the import library in rustlib and having a single copy of LLVM.dll in $(rustc --print sysroot)/bin would make sense to me. Doesn't have to be in the same PR IMO.

Copy link
Member Author

Choose a reason for hiding this comment

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

Currently it only installs the DLL. I'll revert this change when I'm back home.

@Mark-Simulacrum
Copy link
Member

r? @bjorn3 perhaps? Seems like you have more context/knowledge here.

@rustbot rustbot assigned bjorn3 and unassigned Mark-Simulacrum Feb 14, 2026
Unlike other systems, Windows requires runtime libraries to be present
in `PATH` or right next to the binary.

So, we copy the library next to the binary as the easier solution.
@bjorn3
Copy link
Member

bjorn3 commented Feb 15, 2026

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

Please verify that the resulting toolchain can still build custom rustc drivers like miri. I don't have access to a Windows machine to check myself. r=me if that still works.

@rust-bors

This comment has been minimized.

rust-bors bot pushed a commit that referenced this pull request Feb 15, 2026
Install LLVM DLL in the right place on Windows


try-job: dist-x86_64-llvm-mingw
@rust-bors
Copy link
Contributor

rust-bors bot commented Feb 15, 2026

☀️ Try build successful (CI)
Build commit: f0ea08a (f0ea08a0f2730b2678044d4dccd0ad5e0374f562, parent: ce0bf0b22b646bacf91f73393483f684a44848ca)

@mati865
Copy link
Member Author

mati865 commented Feb 15, 2026

It fails to find -lLLVM-22-rust-1.95.0-nightly because lib/rustlib/x86_64-pc-windows-gnullvm/lib (nor bin) is added to linker's search path. I'll look tomorrow why it's not being added.

@rustbot author

@rustbot rustbot 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-review Status: Awaiting review from the assignee but also interested parties. labels Feb 15, 2026
@mati865
Copy link
Member Author

mati865 commented Feb 15, 2026

@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 Feb 15, 2026
Install LLVM DLL in the right place on Windows


try-job: dist-x86_64-llvm-mingw
@rust-bors
Copy link
Contributor

rust-bors bot commented Feb 15, 2026

☀️ Try build successful (CI)
Build commit: 6faffc6 (6faffc66527e366ec8729ee8a6c91814460532c7, parent: 4c37f6d78c9c83e05caa0d1e43ce7d0c3f27538e)

@mati865
Copy link
Member Author

mati865 commented Feb 15, 2026

Looks like that was it.
This time ./miri build succeeded after a minute and ./miri test reports 13 passes and 73 ignored tests.

@bjorn3
Copy link
Member

bjorn3 commented Feb 15, 2026

@bors r+ rollup=iffy

@rust-bors
Copy link
Contributor

rust-bors bot commented Feb 15, 2026

📌 Commit 585297c has been approved by bjorn3

It is now in the queue for this repository.

JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Feb 15, 2026
Install LLVM DLL in the right place on Windows

Continuation of rust-lang#151795 towards rust-lang#151774.

Unlike other systems, Windows requires runtime libraries to be present in `PATH` or right next to the binary.
So, we copy the library next to the binary as the easier solution.

Tested building `rust-openssl` in debug and release modes, but the difference is within noise margin.
@mati865
Copy link
Member Author

mati865 commented Feb 15, 2026

@bors r-

I need to reword that wip commit.

@JonathanBrouwer could you cancel the rollup? Sorry for the trouble.

@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 Feb 15, 2026
@rust-bors
Copy link
Contributor

rust-bors bot commented Feb 15, 2026

Commit 585297c has been unapproved.

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

@JonathanBrouwer
Copy link
Contributor

With new bors the rollup is automatically unapproved if you r- :)

@mati865
Copy link
Member Author

mati865 commented Feb 16, 2026

Only updated the comments, so it probably doesn't require re-review.

@bors r=bjorn3

With new bors the rollup is automatically unapproved if you r- :)

Yeah, that's a great feature. I didn't know about it before bors reply.

@rust-bors
Copy link
Contributor

rust-bors bot commented Feb 16, 2026

📌 Commit 1d1280a has been approved by bjorn3

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-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Feb 16, 2026
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Feb 16, 2026
Install LLVM DLL in the right place on Windows

Continuation of rust-lang#151795 towards rust-lang#151774.

Unlike other systems, Windows requires runtime libraries to be present in `PATH` or right next to the binary.
So, we copy the library next to the binary as the easier solution.

Tested building `rust-openssl` in debug and release modes, but the difference is within noise margin.
rust-bors bot pushed a commit that referenced this pull request Feb 16, 2026
…uwer

Rollup of 6 pull requests

Successful merges:

 - #152700 (miri subtree update)
 - #152715 (`rust-analyzer` subtree update)
 - #152609 (Install LLVM DLL in the right place on Windows)
 - #152206 (misc doc improvements)
 - #152664 (Fix mis-constructed `file_span` when generating scraped examples)
 - #152698 (Suppress unstable-trait notes under `-Zforce-unstable-if-unmarked`)
rust-bors bot pushed a commit that referenced this pull request Feb 16, 2026
…uwer

Rollup of 6 pull requests

Successful merges:

 - #152700 (miri subtree update)
 - #152715 (`rust-analyzer` subtree update)
 - #152609 (Install LLVM DLL in the right place on Windows)
 - #152206 (misc doc improvements)
 - #152664 (Fix mis-constructed `file_span` when generating scraped examples)
 - #152698 (Suppress unstable-trait notes under `-Zforce-unstable-if-unmarked`)
@JonathanBrouwer
Copy link
Contributor

JonathanBrouwer commented Feb 17, 2026

Since the rest of #152718 (comment) has been merged now, the failure there is either this PR or spurious
I'm expecting it to be spurious but will try to be sure
@bors try jobs=x86_64-msvc-1

@rust-bors

This comment has been minimized.

rust-bors bot pushed a commit that referenced this pull request Feb 17, 2026
Install LLVM DLL in the right place on Windows


try-job: x86_64-msvc-1
@rust-bors
Copy link
Contributor

rust-bors bot commented Feb 17, 2026

☀️ Try build successful (CI)
Build commit: 907dd07 (907dd0769a3f21c240a2e795974b1752b1b3566f, parent: d1a11b670b617f1370f7b1cdf86e225a4e070f15)

jdonszelmann added a commit to jdonszelmann/rust that referenced this pull request Feb 17, 2026
Install LLVM DLL in the right place on Windows

Continuation of rust-lang#151795 towards rust-lang#151774.

Unlike other systems, Windows requires runtime libraries to be present in `PATH` or right next to the binary.
So, we copy the library next to the binary as the easier solution.

Tested building `rust-openssl` in debug and release modes, but the difference is within noise margin.
rust-bors bot pushed a commit that referenced this pull request Feb 17, 2026
Rollup of 6 pull requests

Successful merges:

 - #152609 (Install LLVM DLL in the right place on Windows)
 - #149904 (`-Znext-solver` Remove the forced ambiguity hack from search graph)
 - #152704 (Remove `QueryCtxt` and trait `HasDepContext`)
 - #152746 (remove `#![allow(stable_features)]` from most tests)
 - #152675 (Improve `VaList` stdlib docs)
 - #152748 (Update `sysinfo` version to `0.38.2`)
@rust-bors rust-bors bot merged commit 485f76b into rust-lang:main Feb 17, 2026
12 checks passed
@rustbot rustbot added this to the 1.95.0 milestone Feb 17, 2026
rust-timer added a commit that referenced this pull request Feb 17, 2026
Rollup merge of #152609 - mati865:gnullvm-llvm-dll, r=bjorn3

Install LLVM DLL in the right place on Windows

Continuation of #151795 towards #151774.

Unlike other systems, Windows requires runtime libraries to be present in `PATH` or right next to the binary.
So, we copy the library next to the binary as the easier solution.

Tested building `rust-openssl` in debug and release modes, but the difference is within noise margin.
@ZuseZ4
Copy link
Member

ZuseZ4 commented Feb 17, 2026

Thanks again!

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

Labels

A-CI Area: Our Github Actions CI A-testsuite Area: The testsuite used to check the correctness of rustc 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) T-infra Relevant to the infrastructure team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants