-
Notifications
You must be signed in to change notification settings - Fork 454
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Where applicable, detect which RUSTFLAGS were set for rustc and convert them into their corresponding cc flags in order to ensure consistent codegen across Rust and non-Rust modules.
- Loading branch information
1 parent
290a629
commit fc181eb
Showing
2 changed files
with
348 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
use crate::support::Test; | ||
mod support; | ||
|
||
/// This test is in its own module because it modifies the environment and would affect other tests | ||
/// when run in parallel with them. | ||
#[test] | ||
#[cfg(not(windows))] | ||
fn inherits_rustflags() { | ||
// Sanity check - no flags | ||
std::env::set_var("CARGO_ENCODED_RUSTFLAGS", ""); | ||
let test = Test::gnu(); | ||
test.gcc().file("foo.c").compile("foo"); | ||
test.cmd(0) | ||
.must_not_have("-fno-omit-frame-pointer") | ||
.must_not_have("-mcmodel=small") | ||
.must_not_have("-msoft-float"); | ||
|
||
// Correctly inherits flags from rustc | ||
std::env::set_var( | ||
"CARGO_ENCODED_RUSTFLAGS", | ||
"-Cforce-frame-pointers=true\u{1f}-Ccode-model=small\u{1f}-Csoft-float", | ||
); | ||
let test = Test::gnu(); | ||
test.gcc().file("foo.c").compile("foo"); | ||
test.cmd(0) | ||
.must_have("-fno-omit-frame-pointer") | ||
.must_have("-mcmodel=small") | ||
.must_have("-msoft-float"); | ||
} |