Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ version = "1.2.1"
edition = "2021"
default-run = "gourd"
authors = [
"Mikołaj Gazeel <m.j.gazeel@student.tudelft.nl>",
"Mikołaj Gazeel <m.j.gazeel@tudelft.nl>",
Comment thread
andtsa marked this conversation as resolved.
Outdated
"Lukáš Chládek <l@chla.cz>",
"Ανδρέας Τσατσάνης <a.tsatsanis@student.tudelft.nl>",
"Ανδρέας Τσατσάνης <a.tsatsanis@tudelft.nl>",
"Jan Piotrowski <me@jan.wf>",
"Rūta Giedrytė <r.giedryte@student.tudelft.nl>"
"Rūta Giedrytė <r.giedryte@tudelft.nl>"
]

build = "build.rs"
Expand Down
27 changes: 26 additions & 1 deletion src/resources/build_builtin_examples.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,9 +193,34 @@ fn compile_rust_file(path: &Path) -> Result<()> {

let str_compiled_path = compiled_path.to_str().ok_or_else(|| anyhow!(":("))?;

// on linux, we statically link the examples to musl in order to prevent glibc
// compatibility errors.
let target_triple = format!("{}-unknown-linux-musl", std::env::consts::ARCH);
let compile_args = if std::env::consts::OS == "linux" {
std::process::Command::new("rustup")
.arg("target")
.arg("add")
.arg(&target_triple)
.spawn()?
.wait()?;

vec![
"--target",
&target_triple,
"-C",
"target-feature=+crt-static",
"-O",
str_path,
"-o",
str_compiled_path,
]
} else {
vec!["-O", str_path, "-o", str_compiled_path]
};

let output = run_command(
"rustc",
&vec!["-O", str_path, "-o", str_compiled_path],
&compile_args,
Some(canon_path.parent().ok_or_else(|| anyhow!(":("))?.to_owned()),
)?;

Expand Down