Skip to content

Commit 276fa29

Browse files
committed
Auto merge of #110263 - jyn514:ui-fulldeps-llvm, r=albertlarsan68
Add `libLLVM.so` to the target libdir when download-rustc is enabled Previously, we would only add it to the host libdir, which meant it couldn't be loaded by `ui-fulldeps` tests that used rustc_private. Fixes #110225, fixes #110226.
2 parents 660c966 + 7d64c7c commit 276fa29

File tree

3 files changed

+24
-4
lines changed

3 files changed

+24
-4
lines changed

src/bootstrap/compile.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -1281,9 +1281,7 @@ impl Step for Sysroot {
12811281
}
12821282

12831283
// Copy the compiler into the correct sysroot.
1284-
let ci_rustc_dir =
1285-
builder.config.out.join(&*builder.config.build.triple).join("ci-rustc");
1286-
builder.cp_r(&ci_rustc_dir, &sysroot);
1284+
builder.cp_r(&builder.ci_rustc_dir(builder.build.build), &sysroot);
12871285
return INTERNER.intern_path(sysroot);
12881286
}
12891287

@@ -1385,7 +1383,10 @@ impl Step for Assemble {
13851383

13861384
// If we're downloading a compiler from CI, we can use the same compiler for all stages other than 0.
13871385
if builder.download_rustc() {
1388-
builder.ensure(Sysroot { compiler: target_compiler });
1386+
let sysroot = builder.ensure(Sysroot { compiler: target_compiler });
1387+
// Ensure that `libLLVM.so` ends up in the newly created target directory,
1388+
// so that tools using `rustc_private` can use it.
1389+
dist::maybe_install_llvm_target(builder, target_compiler.host, &sysroot);
13891390
return target_compiler;
13901391
}
13911392

src/bootstrap/dist.rs

+14
Original file line numberDiff line numberDiff line change
@@ -1962,6 +1962,20 @@ fn maybe_install_llvm(builder: &Builder<'_>, target: TargetSelection, dst_libdir
19621962
}
19631963
}
19641964

1965+
// FIXME: for reasons I don't understand, the LLVM so in the `rustc` component is different than the one in `rust-dev`.
1966+
// Only the one in `rustc` works with the downloaded compiler.
1967+
if builder.download_rustc() && target == builder.build.build {
1968+
let src_libdir = builder.ci_rustc_dir(target).join("lib");
1969+
for entry in t!(std::fs::read_dir(&src_libdir)) {
1970+
let entry = t!(entry);
1971+
if entry.file_name().to_str().unwrap().starts_with("libLLVM-") {
1972+
install_llvm_file(builder, &entry.path(), dst_libdir);
1973+
return !builder.config.dry_run();
1974+
}
1975+
}
1976+
panic!("libLLVM.so not found in src_libdir {}!", src_libdir.display());
1977+
}
1978+
19651979
// On macOS, rustc (and LLVM tools) link to an unversioned libLLVM.dylib
19661980
// instead of libLLVM-11-rust-....dylib, as on linux. It's not entirely
19671981
// clear why this is the case, though. llvm-config will emit the versioned

src/bootstrap/lib.rs

+5
Original file line numberDiff line numberDiff line change
@@ -814,6 +814,11 @@ impl Build {
814814
self.stage_out(compiler, mode).join(&*target.triple).join(self.cargo_dir())
815815
}
816816

817+
/// Directory where the extracted `rustc-dev` component is stored.
818+
fn ci_rustc_dir(&self, target: TargetSelection) -> PathBuf {
819+
self.out.join(&*target.triple).join("ci-rustc")
820+
}
821+
817822
/// Root output directory for LLVM compiled for `target`
818823
///
819824
/// Note that if LLVM is configured externally then the directory returned

0 commit comments

Comments
 (0)