Skip to content

Commit 7d64c7c

Browse files
committed
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.
1 parent 4087dea commit 7d64c7c

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
@@ -1273,9 +1273,7 @@ impl Step for Sysroot {
12731273
}
12741274

12751275
// Copy the compiler into the correct sysroot.
1276-
let ci_rustc_dir =
1277-
builder.config.out.join(&*builder.config.build.triple).join("ci-rustc");
1278-
builder.cp_r(&ci_rustc_dir, &sysroot);
1276+
builder.cp_r(&builder.ci_rustc_dir(builder.build.build), &sysroot);
12791277
return INTERNER.intern_path(sysroot);
12801278
}
12811279

@@ -1377,7 +1375,10 @@ impl Step for Assemble {
13771375

13781376
// If we're downloading a compiler from CI, we can use the same compiler for all stages other than 0.
13791377
if builder.download_rustc() {
1380-
builder.ensure(Sysroot { compiler: target_compiler });
1378+
let sysroot = builder.ensure(Sysroot { compiler: target_compiler });
1379+
// Ensure that `libLLVM.so` ends up in the newly created target directory,
1380+
// so that tools using `rustc_private` can use it.
1381+
dist::maybe_install_llvm_target(builder, target_compiler.host, &sysroot);
13811382
return target_compiler;
13821383
}
13831384

src/bootstrap/dist.rs

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

1963+
// FIXME: for reasons I don't understand, the LLVM so in the `rustc` component is different than the one in `rust-dev`.
1964+
// Only the one in `rustc` works with the downloaded compiler.
1965+
if builder.download_rustc() && target == builder.build.build {
1966+
let src_libdir = builder.ci_rustc_dir(target).join("lib");
1967+
for entry in t!(std::fs::read_dir(&src_libdir)) {
1968+
let entry = t!(entry);
1969+
if entry.file_name().to_str().unwrap().starts_with("libLLVM-") {
1970+
install_llvm_file(builder, &entry.path(), dst_libdir);
1971+
return !builder.config.dry_run();
1972+
}
1973+
}
1974+
panic!("libLLVM.so not found in src_libdir {}!", src_libdir.display());
1975+
}
1976+
19631977
// On macOS, rustc (and LLVM tools) link to an unversioned libLLVM.dylib
19641978
// instead of libLLVM-11-rust-....dylib, as on linux. It's not entirely
19651979
// 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
@@ -805,6 +805,11 @@ impl Build {
805805
self.stage_out(compiler, mode).join(&*target.triple).join(self.cargo_dir())
806806
}
807807

808+
/// Directory where the extracted `rustc-dev` component is stored.
809+
fn ci_rustc_dir(&self, target: TargetSelection) -> PathBuf {
810+
self.out.join(&*target.triple).join("ci-rustc")
811+
}
812+
808813
/// Root output directory for LLVM compiled for `target`
809814
///
810815
/// Note that if LLVM is configured externally then the directory returned

0 commit comments

Comments
 (0)