Skip to content

Commit b12acf5

Browse files
committed
static libc link in examples
1 parent 428abea commit b12acf5

File tree

2 files changed

+22
-4
lines changed

2 files changed

+22
-4
lines changed

Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ version = "1.2.1"
66
edition = "2021"
77
default-run = "gourd"
88
authors = [
9-
"Mikołaj Gazeel <m.j.gazeel@student.tudelft.nl>",
9+
"Mikołaj Gazeel <[email protected]>",
1010
"Lukáš Chládek <[email protected]>",
11-
"Ανδρέας Τσατσάνης <a.tsatsanis@student.tudelft.nl>",
11+
"Ανδρέας Τσατσάνης <[email protected]>",
1212
"Jan Piotrowski <[email protected]>",
13-
"Rūta Giedrytė <r.giedryte@student.tudelft.nl>"
13+
"Rūta Giedrytė <[email protected]>"
1414
]
1515

1616
build = "build.rs"

src/resources/build_builtin_examples.rs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,9 +193,27 @@ fn compile_rust_file(path: &Path) -> Result<()> {
193193

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

196+
// on linux, we statically link the examples to musl in order to prevent glibc
197+
// compatibility errors.
198+
let target_triple = format!("{}-unknown-linux-musl", std::env::consts::ARCH);
199+
let compile_args = if std::env::consts::OS == "linux" {
200+
vec![
201+
"--target",
202+
&target_triple,
203+
"-C",
204+
"target-feature=+crt-static",
205+
"-O",
206+
str_path,
207+
"-o",
208+
str_compiled_path,
209+
]
210+
} else {
211+
vec!["-O", str_path, "-o", str_compiled_path]
212+
};
213+
196214
let output = run_command(
197215
"rustc",
198-
&vec!["-O", str_path, "-o", str_compiled_path],
216+
&compile_args,
199217
Some(canon_path.parent().ok_or_else(|| anyhow!(":("))?.to_owned()),
200218
)?;
201219

0 commit comments

Comments
 (0)