Skip to content

Commit

Permalink
Pass all extra args in rustc-clif before user supplied args
Browse files Browse the repository at this point in the history
This allows the user to overwrite them and prevents confusing error
messages if the last argument supplied expects a value.
  • Loading branch information
bjorn3 committed Apr 25, 2023
1 parent a7c7979 commit c5be67b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
6 changes: 4 additions & 2 deletions scripts/rustc-clif.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,18 @@ fn main() {
env::consts::DLL_PREFIX.to_string() + "rustc_codegen_cranelift" + env::consts::DLL_SUFFIX,
);

let mut args = std::env::args_os().skip(1).collect::<Vec<_>>();
let passed_args = std::env::args_os().skip(1).collect::<Vec<_>>();
let mut args = vec![];
args.push(OsString::from("-Cpanic=abort"));
args.push(OsString::from("-Zpanic-abort-tests"));
let mut codegen_backend_arg = OsString::from("-Zcodegen-backend=");
codegen_backend_arg.push(cg_clif_dylib_path);
args.push(codegen_backend_arg);
if !args.contains(&OsString::from("--sysroot")) {
if !passed_args.contains(&OsString::from("--sysroot")) {
args.push(OsString::from("--sysroot"));
args.push(OsString::from(sysroot.to_str().unwrap()));
}
args.extend(passed_args);

// Ensure that the right toolchain is used
env::set_var("RUSTUP_TOOLCHAIN", env!("TOOLCHAIN_NAME"));
Expand Down
6 changes: 4 additions & 2 deletions scripts/rustdoc-clif.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,18 @@ fn main() {
env::consts::DLL_PREFIX.to_string() + "rustc_codegen_cranelift" + env::consts::DLL_SUFFIX,
);

let mut args = std::env::args_os().skip(1).collect::<Vec<_>>();
let passed_args = std::env::args_os().skip(1).collect::<Vec<_>>();
let mut args = vec![];
args.push(OsString::from("-Cpanic=abort"));
args.push(OsString::from("-Zpanic-abort-tests"));
let mut codegen_backend_arg = OsString::from("-Zcodegen-backend=");
codegen_backend_arg.push(cg_clif_dylib_path);
args.push(codegen_backend_arg);
if !args.contains(&OsString::from("--sysroot")) {
if !passed_args.contains(&OsString::from("--sysroot")) {
args.push(OsString::from("--sysroot"));
args.push(OsString::from(sysroot.to_str().unwrap()));
}
args.extend(passed_args);

// Ensure that the right toolchain is used
env::set_var("RUSTUP_TOOLCHAIN", env!("TOOLCHAIN_NAME"));
Expand Down

0 comments on commit c5be67b

Please sign in to comment.