Fix missing libLLVM.so in stage0 sysroot.
When we dynamically link against libLLVM.so (as opposed to statically linking LLVM), we need libLLVM.so to be present in the stage0 sysroot, so that stage1 tools (which are built against the stage0 compiler+sysroot) can see it at build time (when the linker is run) See the comment in the commit for more details
This commit is contained in:
parent
1aa34d4dec
commit
8b9c5396ca
@ -456,6 +456,44 @@ fn run(self, builder: &Builder<'_>) {
|
||||
vec![],
|
||||
false);
|
||||
|
||||
// We used to build librustc_codegen_llvm as a separate step,
|
||||
// which produced a dylib that the compiler would dlopen() at runtime.
|
||||
// This meant that we only needed to make sure that libLLVM.so was
|
||||
// installed by the time we went to run a tool using it - since
|
||||
// librustc_codegen_llvm was effectively a standalone artifact,
|
||||
// other crates were completely oblivious to its dependency
|
||||
// on `libLLVM.so` during build time.
|
||||
//
|
||||
// However, librustc_codegen_llvm is now built as an ordinary
|
||||
// crate during the same step as the rest of the compiler crates.
|
||||
// This means that any crates depending on it will see the fact
|
||||
// that it uses `libLLVM.so` as a native library, and will
|
||||
// cause us to pass `-llibLLVM.so` to the linker when we link
|
||||
// a binary.
|
||||
//
|
||||
// For `rustc` itself, this works out fine.
|
||||
// During the `Assemble` step, we call `dist::maybe_install_llvm_dylib`
|
||||
// to copy libLLVM.so into the `stage` directory. We then link
|
||||
// the compiler binary, which will find `libLLVM.so` in the correct place.
|
||||
//
|
||||
// However, this is insufficient for tools that are build against stage0
|
||||
// (e.g. stage1 rustdoc). Since `Assemble` for stage0 doesn't actually do anything,
|
||||
// we won't have `libLLVM.so` in the stage0 sysroot. In the past, this wasn't
|
||||
// a problem - we would copy the tool binary into its correct stage directory
|
||||
// (e.g. stage1 for a stage1 rustdoc built against a stage0 compiler).
|
||||
// Since libLLVM.so wasn't resolved until runtime, it was fine for it to
|
||||
// not exist while we were building it.
|
||||
//
|
||||
// To ensure that we can still build stage1 tools against a stage0 compiler,
|
||||
// we explicitly copy libLLVM.so into the stage0 sysroot when building
|
||||
// the stage0 compiler. This ensures that tools built against stage0
|
||||
// will see libLLVM.so at build time, making the linker happy.
|
||||
if compiler.stage == 0 {
|
||||
builder.info(&format!("Installing libLLVM.so to stage 0 ({})", compiler.host));
|
||||
let sysroot = builder.sysroot(compiler);
|
||||
dist::maybe_install_llvm_dylib(builder, compiler.host, &sysroot);
|
||||
}
|
||||
|
||||
builder.ensure(RustcLink {
|
||||
compiler: builder.compiler(compiler.stage, builder.config.build),
|
||||
target_compiler: compiler,
|
||||
|
Loading…
Reference in New Issue
Block a user