Skip to content

Commit 4d5755f

Browse files
committed
Add libgccjit-libs-dir config
1 parent d5525a7 commit 4d5755f

File tree

3 files changed

+33
-1
lines changed

3 files changed

+33
-1
lines changed

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

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,35 @@ impl GccOutput {
5151
t!(fs::create_dir_all(&dest_dir));
5252
let dst = dest_dir.join(target_filename);
5353
builder.copy_link(&actual_libgccjit_path, &dst, FileType::NativeLibrary);
54+
55+
if let Some(ref path) = builder.config.libgccjit_libs_dir {
56+
let host_target = builder.config.host_target.triple;
57+
58+
let source = path.join(host_target);
59+
let dst = directory;
60+
61+
let targets = builder.config.targets.iter()
62+
.map(|target| target.triple)
63+
.chain(std::iter::once(host_target));
64+
65+
for target in targets {
66+
let source = source.join(target).join(&target_filename);
67+
// To support symlinks in libgccjit-libs-dir, we have to resolve it first,
68+
// otherwise we'd create a symlink to a symlink, which wouldn't work.
69+
let actual_libgccjit_path = t!(
70+
source.canonicalize(),
71+
format!("Cannot find libgccjit at {}", self.libgccjit.display())
72+
);
73+
let target_dir = dst.join(target);
74+
t!(
75+
std::fs::create_dir_all(&target_dir),
76+
format!("Cannot create target dir {} for libgccjit", target_dir.display())
77+
);
78+
let dst = target_dir.join(&target_filename);
79+
builder.copy_link(&actual_libgccjit_path, &dst, FileType::NativeLibrary);
80+
}
81+
}
82+
5483
}
5584
}
5685

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)