From 5d332c9bf4da43e9a66bdf9388cb8b6ea3dc1914 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Kr=C3=B6ning?= Date: Thu, 16 Sep 2021 21:55:39 +0200 Subject: [PATCH] build.rs: Migrate to CARGO_ENCODED_RUSTFLAGS --- hermit-sys/build.rs | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/hermit-sys/build.rs b/hermit-sys/build.rs index e952ae14c..457890c6f 100644 --- a/hermit-sys/build.rs +++ b/hermit-sys/build.rs @@ -98,30 +98,29 @@ fn build_hermit(src_dir: &Path, target_dir_opt: Option<&Path>) { } let mut rustflags = vec!["-Zmutable-noalias=no".to_string()]; + let outer_rustflags = env::var("CARGO_ENCODED_RUSTFLAGS").unwrap(); #[cfg(feature = "instrument")] { rustflags.push("-Zinstrument-mcount".to_string()); - // Add outer `RUSTFLAGS` to command - if let Ok(var) = env::var("RUSTFLAGS") { - rustflags.push(var); - } + // Add outer rustflags to command + rustflags.push(outer_rustflags); } #[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 it from outer rustflags before adding them to the command. + if !outer_rustflags.is_empty() { + let flags = outer_rustflags + .split('\x1f') .filter(|&flag| !flag.contains("instrument-mcount")) .map(String::from); rustflags.extend(flags); } } - cmd.env("RUSTFLAGS", rustflags.join(" ")); + cmd.env("CARGO_ENCODED_RUSTFLAGS", rustflags.join("\x1f")); let status = cmd.status().expect("failed to start kernel build"); assert!(status.success());