Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions src/bootstrap/src/core/builder/cargo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use std::{env, fs};

use super::{Builder, Kind};
use crate::core::build_steps::compile::is_lto_stage;
use crate::core::build_steps::llvm::Llvm;
use crate::core::build_steps::test;
use crate::core::build_steps::tool::SourceType;
use crate::core::compiler::Compiler;
Expand Down Expand Up @@ -1243,12 +1244,18 @@ impl Builder<'_> {
if (mode == Mode::ToolRustcPrivate || mode == Mode::Codegen)
&& self.is_llvm_enabled_for(target)
{
let llvm_libdir_raw = command(self.host_llvm_config())
.cached()
.arg("--libdir")
.run_capture_stdout(self)
.stdout();
let llvm_libdir = llvm_libdir_raw.trim();
let llvm_libdir = if self.config.is_host_target(target) {
command(self.host_llvm_config())
.cached()
.arg("--libdir")
.run_capture_stdout(self)
.stdout()
.trim()
.to_owned()
} else {
let llvm_output = self.ensure(Llvm { target });
llvm_output.root_dir().join("lib").to_string_lossy().into_owned()

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.

Does this work also on macOS/Windows? That being said, it is surely better than passing the host LLVM libdir :)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It seems to work on macOS/Windows, but I don't have an environment to verify it. Could we test it on CI?

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.

Not sure if we actually cross-compile LLVM on CI somewhere on macOS/Windows. Let's try it.

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.

Wouldn't be hard if you want to try with something like https://github.com/rust-lang/rust/pull/148751/changes#diff-8291d819a8dc37b937e63c4e34dc5b27c59b1725e3ee677ffe0f970711d646df or windows-gnu.
This sounds like a recent-ish regression, as it seemed to work fine last year when gnullvm hosts were still cross-compiled from Linux.

};
if target.is_msvc() {
rustflags.arg(&format!("-Clink-arg=-LIBPATH:{llvm_libdir}"));
} else {
Expand Down
Loading