Skip to content

prevent libgccjit.so download on unsupported os/arch #529

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jun 1, 2024
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 19 additions & 8 deletions build_system/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -231,13 +231,7 @@ impl ConfigInfo {
let tempfile = output_dir.join(&tempfile_name);
let is_in_ci = std::env::var("GITHUB_ACTIONS").is_ok();

let url = format!(
"https://github.com/antoyo/gcc/releases/download/master-{}/libgccjit.so",
commit,
);

println!("Downloading `{}`...", url);
download_gccjit(url, &output_dir, tempfile_name, !is_in_ci)?;
download_gccjit(&commit, &output_dir, tempfile_name, !is_in_ci)?;

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

fn download_gccjit(
url: String,
commit: &str,
output_dir: &Path,
tempfile_name: String,
with_progress_bar: bool,
) -> Result<(), String> {
let url = if std::env::consts::OS == "linux" && std::env::consts::ARCH == "x86_64" {
format!("https://github.com/rust-lang/gcc/releases/download/master-{}/libgccjit.so", commit)
} else {
eprintln!(
"\
Pre-compiled libgccjit.so not available for this os or architecture.\n\
Please compile it yourself and update the `config.toml` file\n\
to `download-gccjit = false` and set `gcc-path` to the appropriate directory.\
"
);
return Err(String::from(
"no appropriate pre-compiled libgccjit.so available for download",
));
};

println!("Downloading `{}`...", url);

// Try curl. If that fails and we are on windows, fallback to PowerShell.
let mut ret = run_command_with_output(
&[
Expand Down
Loading