Skip to content

Commit 3bcdbb1

Browse files
committed
Add libgccjit-libs-dir config
1 parent 6840234 commit 3bcdbb1

File tree

3 files changed

+34
-2
lines changed

3 files changed

+34
-2
lines changed

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

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,37 @@ impl GccOutput {
5151
format!("Cannot find libgccjit at {}", self.libgccjit.display())
5252
);
5353

54-
let dst = directory.join(target_filename);
54+
let dst = directory.join(&target_filename);
5555
builder.copy_link(&actual_libgccjit_path, &dst, FileType::NativeLibrary);
56+
57+
if let Some(ref path) = builder.config.libgccjit_libs_dir {
58+
let host_target = builder.config.host_target.triple;
59+
60+
let source = path.join(host_target);
61+
let dst = directory;
62+
63+
let targets = builder.config.targets.iter()
64+
.map(|target| target.triple)
65+
.chain(std::iter::once(host_target));
66+
67+
for target in targets {
68+
let source = source.join(target).join(&target_filename);
69+
// To support symlinks in libgccjit-libs-dir, we have to resolve it first,
70+
// otherwise we'd create a symlink to a symlink, which wouldn't work.
71+
let actual_libgccjit_path = t!(
72+
source.canonicalize(),
73+
format!("Cannot find libgccjit at {}", self.libgccjit.display())
74+
);
75+
let target_dir = dst.join(target);
76+
t!(
77+
std::fs::create_dir_all(&target_dir),
78+
format!("Cannot create target dir {} for libgccjit", target_dir.display())
79+
);
80+
let dst = target_dir.join(&target_filename);
81+
builder.copy_link(&actual_libgccjit_path, &dst, FileType::NativeLibrary);
82+
}
83+
}
84+
5685
}
5786
}
5887

src/bootstrap/src/core/config/config.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,7 @@ pub struct Config {
188188

189189
// gcc codegen options
190190
pub gcc_ci_mode: GccCiMode,
191+
pub libgccjit_libs_dir: Option<PathBuf>,
191192

192193
// rust codegen options
193194
pub rust_optimize: RustOptimize,
@@ -620,7 +621,7 @@ impl Config {
620621
vendor: dist_vendor,
621622
} = toml.dist.unwrap_or_default();
622623

623-
let Gcc { download_ci_gcc: gcc_download_ci_gcc } = toml.gcc.unwrap_or_default();
624+
let Gcc { download_ci_gcc: gcc_download_ci_gcc, libgccjit_libs_dir } = toml.gcc.unwrap_or_default();
624625

625626
if rust_bootstrap_override_lld.is_some() && rust_bootstrap_override_lld_legacy.is_some() {
626627
panic!(
@@ -1327,6 +1328,7 @@ impl Config {
13271328
free_args: flags_free_args,
13281329
full_bootstrap: build_full_bootstrap.unwrap_or(false),
13291330
gcc_ci_mode,
1331+
libgccjit_libs_dir,
13301332
gdb: build_gdb.map(PathBuf::from),
13311333
host_target,
13321334
hosts,

src/bootstrap/src/core/config/toml/gcc.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,6 @@ define_config! {
1515
#[derive(Default)]
1616
struct Gcc {
1717
download_ci_gcc: Option<bool> = "download-ci-gcc",
18+
libgccjit_libs_dir: Option<PathBuf> = "libgccjit-libs-dir",
1819
}
1920
}

0 commit comments

Comments
 (0)