Skip to content

Commit 269cbc2

Browse files
committed
respect CARGO_EXTRA_FLAGS in more places
1 parent 95fe7ab commit 269cbc2

File tree

5 files changed

+18
-7
lines changed

5 files changed

+18
-7
lines changed

src/tools/miri/ci.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ function run_tests {
5252

5353
# Also run some many-seeds tests. 64 seeds means this takes around a minute per test.
5454
for FILE in tests/many-seeds/*.rs; do
55-
MIRI_SEEDS=64 CARGO_EXTRA_FLAGS="$CARGO_EXTRA_FLAGS -q" ./miri many-seeds ./miri run "$FILE"
55+
MIRI_SEEDS=64 ./miri many-seeds ./miri run "$FILE"
5656
done
5757

5858
# Check that the benchmarks build and run, but without actually benchmarking.

src/tools/miri/miri

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
set -e
33
# Instead of doing just `cargo run --manifest-path .. $@`, we invoke miri-script binary directly. Invoking `cargo run` goes through
44
# rustup (that sets it's own environmental variables), which is undesirable.
5-
cargo build -q --manifest-path "$(dirname "$0")"/miri-script/Cargo.toml
5+
cargo build $CARGO_EXTRA_FLAGS -q --manifest-path "$(dirname "$0")"/miri-script/Cargo.toml
66
"$(dirname "$0")"/miri-script/target/debug/miri-script "$@"

src/tools/miri/miri-script/src/commands.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,8 @@ impl Command {
319319
let Some((program_name, args)) = hyperfine.split_first() else {
320320
bail!("expected HYPERFINE environment variable to be non-empty");
321321
};
322+
// Extra flags to pass to cargo.
323+
let cargo_extra_flags = std::env::var("CARGO_EXTRA_FLAGS").unwrap_or_default();
322324
// Make sure we have an up-to-date Miri installed and selected the right toolchain.
323325
Self::install(vec![])?;
324326

@@ -341,7 +343,7 @@ impl Command {
341343
// That seems to make Windows CI happy.
342344
cmd!(
343345
sh,
344-
"{program_name} {args...} 'cargo miri run --manifest-path \"'{current_bench}'\"'"
346+
"{program_name} {args...} 'cargo miri run '{cargo_extra_flags}' --manifest-path \"'{current_bench}'\"'"
345347
)
346348
.run()?;
347349
}

src/tools/miri/test-cargo-miri/run-test.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,14 @@
1515
CBOLD = '\33[1m'
1616
CEND = '\33[0m'
1717

18+
CARGO_EXTRA_FLAGS = os.environ.get("CARGO_EXTRA_FLAGS", "").split()
19+
1820
def fail(msg):
1921
print("\nTEST FAIL: {}".format(msg))
2022
sys.exit(1)
2123

2224
def cargo_miri(cmd, quiet = True):
23-
args = ["cargo", "miri", cmd]
25+
args = ["cargo", "miri", cmd] + CARGO_EXTRA_FLAGS
2426
if quiet:
2527
args += ["-q"]
2628
if 'MIRI_TEST_TARGET' in os.environ:

src/tools/miri/tests/compiletest.rs

+10-3
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ fn get_host() -> String {
1616
.host
1717
}
1818

19+
pub fn flagsplit(flags: &str) -> Vec<String> {
20+
// This code is taken from `RUSTFLAGS` handling in cargo.
21+
flags.split(' ').map(str::trim).filter(|s| !s.is_empty()).map(str::to_string).collect()
22+
}
23+
1924
// Build the shared object file for testing external C function calls.
2025
fn build_so_for_c_ffi_tests() -> PathBuf {
2126
let cc = option_env!("CC").unwrap_or("cc");
@@ -100,14 +105,16 @@ fn test_config(target: &str, path: &str, mode: Mode, with_dependencies: bool) ->
100105
if with_dependencies && use_std {
101106
config.dependencies_crate_manifest_path =
102107
Some(Path::new("test_dependencies").join("Cargo.toml"));
103-
config.dependency_builder.args = vec![
104-
"run".into(),
108+
let mut builder_args = vec!["run".into()];
109+
builder_args.extend(flagsplit(&env::var("CARGO_EXTRA_FLAGS").unwrap_or_default()));
110+
builder_args.extend([
105111
"--manifest-path".into(),
106112
"cargo-miri/Cargo.toml".into(),
107113
"--".into(),
108114
"miri".into(),
109115
"run".into(), // There is no `cargo miri build` so we just use `cargo miri run`.
110-
];
116+
]);
117+
config.dependency_builder.args = builder_args.into_iter().map(Into::into).collect();
111118
}
112119
config
113120
}

0 commit comments

Comments
 (0)