diff options
| author | Stuart Cook <Zalathar@users.noreply.github.com> | 2025-09-12 20:02:18 +1000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-09-12 20:02:18 +1000 |
| commit | accb4a3a8f9004136eb430d95bb62722becb3dd1 (patch) | |
| tree | 01e3a8ae6c35d6056606bcac4ccdda6b183ad653 | |
| parent | 249730f521921016e19d226a7799d5bdc879f8f2 (diff) | |
| parent | 256aa0d9414f52664dd6e9e97d90fe485a203630 (diff) | |
| download | rust-accb4a3a8f9004136eb430d95bb62722becb3dd1.tar.gz rust-accb4a3a8f9004136eb430d95bb62722becb3dd1.zip | |
Rollup merge of #146449 - Kobzol:gcc-fix-symlink, r=GuillaumeGomez
Fix `libgccjit` symlink when we build GCC locally Unblocks https://github.com/rust-lang/rust/pull/146414. r? ```@GuillaumeGomez```
| -rw-r--r-- | src/bootstrap/src/core/build_steps/gcc.rs | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/bootstrap/src/core/build_steps/gcc.rs b/src/bootstrap/src/core/build_steps/gcc.rs index 77c9622a9bf..717dea37e9e 100644 --- a/src/bootstrap/src/core/build_steps/gcc.rs +++ b/src/bootstrap/src/core/build_steps/gcc.rs @@ -32,6 +32,10 @@ pub struct GccOutput { impl GccOutput { /// Install the required libgccjit library file(s) to the specified `path`. pub fn install_to(&self, builder: &Builder<'_>, directory: &Path) { + if builder.config.dry_run() { + return; + } + // At build time, cg_gcc has to link to libgccjit.so (the unversioned symbol). // However, at runtime, it will by default look for libgccjit.so.0. // So when we install the built libgccjit.so file to the target `directory`, we add it there @@ -39,8 +43,16 @@ impl GccOutput { let mut target_filename = self.libgccjit.file_name().unwrap().to_str().unwrap().to_string(); target_filename.push_str(".0"); + // If we build libgccjit ourselves, then `self.libgccjit` can actually be a symlink. + // In that case, we have to resolve it first, otherwise we'd create a symlink to a symlink, + // which wouldn't work. + let actual_libgccjit_path = t!( + self.libgccjit.canonicalize(), + format!("Cannot find libgccjit at {}", self.libgccjit.display()) + ); + let dst = directory.join(target_filename); - builder.copy_link(&self.libgccjit, &dst, FileType::NativeLibrary); + builder.copy_link(&actual_libgccjit_path, &dst, FileType::NativeLibrary); } } |
