Skip to content

Commit

Permalink
Merge #135
Browse files Browse the repository at this point in the history
135: Disable `mutable-noalias` r=stlankes a=mkroening

Fixes #128.

What do you think?

Co-authored-by: Martin Kröning <mkroening@posteo.net>
  • Loading branch information
bors[bot] and mkroening authored May 28, 2021
2 parents 86af428 + af41820 commit 204578e
Showing 1 changed file with 23 additions and 8 deletions.
31 changes: 23 additions & 8 deletions hermit-sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,18 +89,33 @@ fn build_hermit(src_dir: &Path, target_dir_opt: Option<&Path>) {
cmd.arg("vga");
}

let mut rustflags = Vec::new();
rustflags.push("-Zmutable-noalias=no".to_string());

#[cfg(feature = "instrument")]
{
cmd.env("RUSTFLAGS", "-Z instrument-mcount");
// if instrument is not set, ensure that instrument is not in environment variables!
cmd.env(
"RUSTFLAGS",
env::var("RUSTFLAGS")
.unwrap_or_else(|_| "".into())
.replace("-Z instrument-mcount", ""),
);
rustflags.push("-Zinstrument-mcount".to_string());
// Add outer `RUSTFLAGS` to command
if let Ok(var) = env::var("RUSTFLAGS") {
rustflags.push(var);
}
}

#[cfg(not(feature = "instrument"))]
{
// If the `instrument` feature feature is not enabled,
// filter it from outer `RUSTFLAGS` before adding them to the command.
if let Ok(var) = env::var("RUSTFLAGS") {
let flags = var
.split(',')
.filter(|&flag| !flag.contains("instrument-mcount"))
.map(String::from);
rustflags.extend(flags);
}
}

cmd.env("RUSTFLAGS", rustflags.join(","));

let output = cmd.output().expect("Unable to build kernel");
let stdout = std::string::String::from_utf8(output.stdout);
let stderr = std::string::String::from_utf8(output.stderr);
Expand Down

0 comments on commit 204578e

Please sign in to comment.