Skip to content

Commit f5d5a3d

Browse files
committed
Add support for recovering rustc codegen options
1 parent 5e2a1ed commit f5d5a3d

2 files changed

Lines changed: 22 additions & 1 deletion

File tree

cargo-auditable/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ auditable-serde = {version = "0.8.0", path = "../auditable-serde"}
1818
miniz_oxide = {version = "0.8.0"}
1919
serde_json = "1.0.57"
2020
cargo_metadata = "0.18"
21-
pico-args = { version = "0.5", features = ["eq-separator"] }
21+
pico-args = { version = "0.5", features = ["eq-separator", "short-space-opt"] }
2222
serde = "1.0.147"
2323
wasm-gen = "0.1.4"
2424

cargo-auditable/src/rustc_arguments.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ pub struct RustcArgs {
2121
pub out_dir: Option<PathBuf>,
2222
pub target: Option<String>,
2323
pub print: Vec<String>,
24+
pub codegen: Vec<String>,
2425
}
2526

2627
impl RustcArgs {
@@ -62,6 +63,7 @@ impl RustcArgs {
6263
})?,
6364
target: parser.opt_value_from_str("--target")?,
6465
print: parser.values_from_str("--print")?,
66+
codegen: parser.values_from_str("-C")?,
6567
})
6668
}
6769
}
@@ -168,4 +170,23 @@ mod tests {
168170

169171
assert_eq!(args.emit, expected)
170172
}
173+
174+
#[test]
175+
fn multiple_codegen_options() {
176+
let raw_rustc_args = vec![
177+
"-Clinker=clang",
178+
"-C",
179+
"link-arg=-fuse-ld=/usr/bin/mold",
180+
];
181+
let raw_rustc_args: Vec<OsString> = raw_rustc_args.into_iter().map(|s| s.into()).collect();
182+
let mut args = RustcArgs::from_vec(raw_rustc_args).unwrap();
183+
184+
let expected = vec!["linker=clang", "link-arg=-fuse-ld=/usr/bin/mold"];
185+
let mut expected: Vec<String> = expected.into_iter().map(|s| s.into()).collect();
186+
187+
args.codegen.sort();
188+
expected.sort();
189+
190+
assert_eq!(args.codegen, expected)
191+
}
171192
}

0 commit comments

Comments
 (0)