Skip to content

Commit 70d4545

Browse files
committed
Add libgccjit-libs-dir config
1 parent 9050733 commit 70d4545

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
@@ -46,8 +46,37 @@ impl GccOutput {
4646
format!("Cannot find libgccjit at {}", self.libgccjit.display())
4747
);
4848

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

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)