Skip to content

Commit e18e244

Browse files
SkglandGuillaumeGomez
authored andcommitted
prevent libgccjit.so download on unsupported os/arch (rust-lang#529)
prevent libgccjit.so download on unsupported os/arch (rust-lang#529) Co-authored-by: Guillaume Gomez <[email protected]>
1 parent b0e9967 commit e18e244

File tree

1 file changed

+18
-8
lines changed

1 file changed

+18
-8
lines changed

Diff for: build_system/src/config.rs

+18-8
Original file line numberDiff line numberDiff line change
@@ -231,13 +231,7 @@ impl ConfigInfo {
231231
let tempfile = output_dir.join(&tempfile_name);
232232
let is_in_ci = std::env::var("GITHUB_ACTIONS").is_ok();
233233

234-
let url = format!(
235-
"https://github.com/antoyo/gcc/releases/download/master-{}/libgccjit.so",
236-
commit,
237-
);
238-
239-
println!("Downloading `{}`...", url);
240-
download_gccjit(url, &output_dir, tempfile_name, !is_in_ci)?;
234+
download_gccjit(&commit, &output_dir, tempfile_name, !is_in_ci)?;
241235

242236
let libgccjit_so = output_dir.join(libgccjit_so_name);
243237
// If we reach this point, it means the file was correctly downloaded, so let's
@@ -469,11 +463,27 @@ impl ConfigInfo {
469463
}
470464

471465
fn download_gccjit(
472-
url: String,
466+
commit: &str,
473467
output_dir: &Path,
474468
tempfile_name: String,
475469
with_progress_bar: bool,
476470
) -> Result<(), String> {
471+
let url = if std::env::consts::OS == "linux" && std::env::consts::ARCH == "x86_64" {
472+
format!("https://github.com/rust-lang/gcc/releases/download/master-{}/libgccjit.so", commit)
473+
} else {
474+
eprintln!(
475+
"\
476+
Pre-compiled libgccjit.so not available for this os or architecture.
477+
Please compile it yourself and update the `config.toml` file
478+
to `download-gccjit = false` and set `gcc-path` to the appropriate directory."
479+
);
480+
return Err(String::from(
481+
"no appropriate pre-compiled libgccjit.so available for download",
482+
));
483+
};
484+
485+
println!("Downloading `{}`...", url);
486+
477487
// Try curl. If that fails and we are on windows, fallback to PowerShell.
478488
let mut ret = run_command_with_output(
479489
&[

0 commit comments

Comments
 (0)