Skip to content

Commit

Permalink
ensure correct linker gets chosen
Browse files Browse the repository at this point in the history
  • Loading branch information
Jamesbarford committed Feb 4, 2025
1 parent 4b7b39c commit 027b28b
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions crates/intrinsic-test/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -395,24 +395,31 @@ path = "{intrinsic}/main.rs""#,
/* If there has been a linker explicitly set from the command line then
* we want to set it via setting it in the RUSTFLAGS*/
let mut rust_flags = "-Cdebuginfo=0".to_string();
if let Some(linker) = linker {
rust_flags.push_str(" -Clinker=");
rust_flags.push_str(linker);
rust_flags.push_str(" -Clink-args=-static");
}

let cargo_command = format!(
"cargo {toolchain} build --target {target} --release",
toolchain = toolchain,
target = target
);

let output = Command::new("sh")
let mut command = Command::new("sh");

command
.current_dir("rust_programs")
.arg("-c")
.arg(cargo_command)
.env("RUSTFLAGS", rust_flags)
.output();
.arg(cargo_command);

if let Some(linker) = linker {
rust_flags.push_str(" -C linker=");
rust_flags.push_str(linker);
rust_flags.push_str(" -C link-args=-static");

command.env("CPPFLAGS", "-fuse-ld=lld");
}

command.env("RUSTFLAGS", rust_flags);
let output = command.output();

if let Ok(output) = output {
if output.status.success() {
true
Expand Down

0 comments on commit 027b28b

Please # to comment.