Skip to content

Commit 68125c7

Browse files
committed
Auto merge of #120721 - onur-ozkan:incorrect-llvm-path-on-cross-target, r=albertlarsan68
fix `llvm_out` to use the correct LLVM root When `download-ci-llvm` is enabled, `llvm_out` ends up with the error below due to an incorrect path on cross-compilations. This change fixes that. ```sh failed to execute command: "/rust/build/x86_64-unknown-linux-gnu/llvm/build/bin/llvm-config" "--version" ERROR: No such file or directory (os error 2) ```
2 parents b5c46dc + 63cc3c7 commit 68125c7

File tree

3 files changed

+24
-3
lines changed

3 files changed

+24
-3
lines changed

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ pub fn prebuilt_llvm_config(
9898
let out_dir = builder.llvm_out(target);
9999

100100
let mut llvm_config_ret_dir = builder.llvm_out(builder.config.build);
101-
if !builder.config.build.is_msvc() || builder.ninja() {
101+
if (!builder.config.build.is_msvc() || builder.ninja()) && !builder.config.llvm_from_ci {
102102
llvm_config_ret_dir.push("build");
103103
}
104104
llvm_config_ret_dir.push("bin");

src/bootstrap/src/core/builder/tests.rs

+17
Original file line numberDiff line numberDiff line change
@@ -524,6 +524,23 @@ mod dist {
524524
);
525525
}
526526

527+
#[test]
528+
fn llvm_out_behaviour() {
529+
let mut config = configure(&["A"], &["B"]);
530+
config.llvm_from_ci = true;
531+
let build = Build::new(config.clone());
532+
533+
let target = TargetSelection::from_user("A");
534+
assert!(build.llvm_out(target).ends_with("ci-llvm"));
535+
let target = TargetSelection::from_user("B");
536+
assert!(build.llvm_out(target).ends_with("llvm"));
537+
538+
config.llvm_from_ci = false;
539+
let build = Build::new(config.clone());
540+
let target = TargetSelection::from_user("A");
541+
assert!(build.llvm_out(target).ends_with("llvm"));
542+
}
543+
527544
#[test]
528545
fn build_with_empty_host() {
529546
let config = configure(&[], &["C"]);

src/bootstrap/src/lib.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -792,12 +792,16 @@ impl Build {
792792
self.stage_out(compiler, mode).join(&*target.triple).join(self.cargo_dir())
793793
}
794794

795-
/// Root output directory for LLVM compiled for `target`
795+
/// Root output directory of LLVM for `target`
796796
///
797797
/// Note that if LLVM is configured externally then the directory returned
798798
/// will likely be empty.
799799
fn llvm_out(&self, target: TargetSelection) -> PathBuf {
800-
self.out.join(&*target.triple).join("llvm")
800+
if self.config.llvm_from_ci && self.config.build == target {
801+
self.config.ci_llvm_root()
802+
} else {
803+
self.out.join(&*target.triple).join("llvm")
804+
}
801805
}
802806

803807
fn lld_out(&self, target: TargetSelection) -> PathBuf {

0 commit comments

Comments
 (0)