Skip to content

Commit e5ef98e

Browse files
authored
Unrolled build for #146449
Rollup merge of #146449 - Kobzol:gcc-fix-symlink, r=GuillaumeGomez Fix `libgccjit` symlink when we build GCC locally Unblocks #146414. r? ```@GuillaumeGomez```
2 parents ac4495a + 256aa0d commit e5ef98e

File tree

1 file changed

+13
-1
lines changed
  • src/bootstrap/src/core/build_steps

1 file changed

+13
-1
lines changed

src/bootstrap/src/core/build_steps/gcc.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,27 @@ pub struct GccOutput {
3232
impl GccOutput {
3333
/// Install the required libgccjit library file(s) to the specified `path`.
3434
pub fn install_to(&self, builder: &Builder<'_>, directory: &Path) {
35+
if builder.config.dry_run() {
36+
return;
37+
}
38+
3539
// At build time, cg_gcc has to link to libgccjit.so (the unversioned symbol).
3640
// However, at runtime, it will by default look for libgccjit.so.0.
3741
// So when we install the built libgccjit.so file to the target `directory`, we add it there
3842
// with the `.0` suffix.
3943
let mut target_filename = self.libgccjit.file_name().unwrap().to_str().unwrap().to_string();
4044
target_filename.push_str(".0");
4145

46+
// If we build libgccjit ourselves, then `self.libgccjit` can actually be a symlink.
47+
// In that case, we have to resolve it first, otherwise we'd create a symlink to a symlink,
48+
// which wouldn't work.
49+
let actual_libgccjit_path = t!(
50+
self.libgccjit.canonicalize(),
51+
format!("Cannot find libgccjit at {}", self.libgccjit.display())
52+
);
53+
4254
let dst = directory.join(target_filename);
43-
builder.copy_link(&self.libgccjit, &dst, FileType::NativeLibrary);
55+
builder.copy_link(&actual_libgccjit_path, &dst, FileType::NativeLibrary);
4456
}
4557
}
4658

0 commit comments

Comments
 (0)