Skip to content
Open
Show file tree
Hide file tree
Changes from 2 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
5 changes: 5 additions & 0 deletions .cargo/config.toml
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this supposed to be in the commit?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can see you've removed it from gitignore, but isn't the static linking only supposed to be relevant for examples?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

iirc we link all linux binaries against musl. I am not sure why this wasn't here or why it worked without

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I recall facing the issue when Emir (and some others) first tried testing it on delftblue that gourd didn't work at all because of glibc diff between GitHub runners and delftblue

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure, but seems fishy. @mgazeel?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to clarify, I had .cargo/config.toml locally (on delftblue) already so any version of gourd I compiled and tested on the cluster had this config

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[target.x86_64-unknown-linux-musl]
linker = "musl-gcc"
rustflags = [
"-C", "target-feature=+crt-static"
]
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,3 @@ Cargo.lock
/*.man
compile.fish
/*.profraw
.cargo
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>",
"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