Skip to content

Commit e3e67f6

Browse files
committed
Auto merge of #151795 - mati865:push-okvosrxznyrr, r=<try>
[Proof of concept] Build shared LLVM lib for gnullvm try-job: dist-x86_64-llvm-mingw
2 parents d7daac0 + 813f3fa commit e3e67f6

3 files changed

Lines changed: 26 additions & 4 deletions

File tree

src/bootstrap/src/core/build_steps/dist.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ use crate::utils::build_stamp::{self, BuildStamp};
3535
use crate::utils::channel::{self, Info};
3636
use crate::utils::exec::{BootstrapCommand, command};
3737
use crate::utils::helpers::{
38-
exe, is_dylib, move_file, t, target_supports_cranelift_backend, timeit,
38+
exe, is_dylib, libdir, move_file, t, target_supports_cranelift_backend, timeit,
3939
};
4040
use crate::utils::tarball::{GeneratedTarball, OverlayKind, Tarball};
4141
use crate::{CodegenBackendKind, Compiler, DependencyType, FileType, LLVM_TOOLS, Mode, trace};
@@ -2518,7 +2518,7 @@ fn maybe_install_llvm(
25182518
}
25192519
}
25202520

2521-
/// Maybe add libLLVM.so to the target lib-dir for linking.
2521+
/// Maybe add libLLVM.so to the target runtime lib-dir.
25222522
#[cfg_attr(
25232523
feature = "tracing",
25242524
instrument(
@@ -2533,7 +2533,7 @@ fn maybe_install_llvm(
25332533
),
25342534
)]
25352535
pub fn maybe_install_llvm_target(builder: &Builder<'_>, target: TargetSelection, sysroot: &Path) {
2536-
let dst_libdir = sysroot.join("lib/rustlib").join(target).join("lib");
2536+
let dst_libdir = sysroot.join("lib/rustlib").join(target).join(libdir(target));
25372537
// We do not need to copy LLVM files into the sysroot if it is not
25382538
// dynamically linked; it is already included into librustc_llvm
25392539
// statically.
@@ -2557,7 +2557,8 @@ pub fn maybe_install_llvm_target(builder: &Builder<'_>, target: TargetSelection,
25572557
),
25582558
)]
25592559
pub fn maybe_install_llvm_runtime(builder: &Builder<'_>, target: TargetSelection, sysroot: &Path) {
2560-
let dst_libdir = sysroot.join(builder.sysroot_libdir_relative(Compiler::new(1, target)));
2560+
let dst_libdir =
2561+
sysroot.join(builder.sysroot_runtime_libdir_relative(Compiler::new(1, target)));
25612562
// We do not need to copy LLVM files into the sysroot if it is not
25622563
// dynamically linked; it is already included into librustc_llvm
25632564
// statically.

src/bootstrap/src/core/builder/mod.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1344,6 +1344,25 @@ Alternatively, you can set `build.local-rebuild=true` and use a stage0 compiler
13441344
}
13451345
}
13461346

1347+
/// Returns the compiler's relative runtime libdir where shared libraries are found for a
1348+
/// compiler's sysroot.
1349+
///
1350+
/// For example this returns `lib` on Unix and `bin` on Windows.
1351+
pub fn sysroot_runtime_libdir_relative(&self, compiler: Compiler) -> PathBuf {
1352+
let adjust_path = |path: &Path| -> PathBuf {
1353+
if compiler.host.is_windows() || compiler.host.contains("cygwin") {
1354+
path.parent().expect("original path should point to `lib` already").join("bin")
1355+
} else {
1356+
path.to_owned()
1357+
}
1358+
};
1359+
match self.config.libdir_relative() {
1360+
Some(relative_libdir) if compiler.stage >= 1 => adjust_path(relative_libdir),
1361+
_ if compiler.stage == 0 => adjust_path(&self.build.initial_relative_libdir),
1362+
_ => PathBuf::from(libdir(compiler.host)),
1363+
}
1364+
}
1365+
13471366
pub fn rustc_lib_paths(&self, compiler: Compiler) -> Vec<PathBuf> {
13481367
let mut dylib_dirs = vec![self.rustc_libdir(compiler)];
13491368

src/ci/github-actions/jobs.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -712,6 +712,7 @@ auto:
712712
--target=aarch64-pc-windows-gnullvm,i686-pc-windows-gnullvm
713713
--enable-full-tools
714714
--enable-profiler
715+
--enable-llvm-link-shared
715716
DIST_REQUIRE_ALL_TOOLS: 1
716717
CODEGEN_BACKENDS: llvm,cranelift
717718
CC_i686_pc_windows_gnullvm: i686-w64-mingw32-clang
@@ -724,6 +725,7 @@ auto:
724725
--build=x86_64-pc-windows-gnullvm
725726
--enable-full-tools
726727
--enable-profiler
728+
--enable-llvm-link-shared
727729
DIST_REQUIRE_ALL_TOOLS: 1
728730
CODEGEN_BACKENDS: llvm,cranelift
729731
<<: *job-windows

0 commit comments

Comments
 (0)