Closed LPGhatguy closed 11 months ago
I haven't implemented running as cargo clif build
yet, but that shouldn't be too hard to do. The reason it is called cargo-clif
rather than cargo
is to avoid infinite recursion on Windows. cargo-clif calls cargo, expecting it to be the real cargo, but on windows this would previously call itself as windows looks in the current directory before looking at PATH
like other OSes.
Does this work?
diff --git a/scripts/cargo-clif.rs b/scripts/cargo-clif.rs
index 99b97be2..5977652a 100644
--- a/scripts/cargo-clif.rs
+++ b/scripts/cargo-clif.rs
@@ -40,14 +40,20 @@ fn main() {
"cargo"
};
- let args: Vec<_> = match env::args().nth(1).as_deref() {
+ let mut args = env::args().skip(1).collect::<Vec<_>>();
+ if args.get(0).map(|arg| &**arg) == Some("clif") {
+ args.remove(0);
+ }
+
+ let args: Vec<_> = match args.get(0).map(|arg| &**arg) {
Some("jit") => {
env::set_var(
"RUSTFLAGS",
env::var("RUSTFLAGS").unwrap_or(String::new()) + " -Cprefer-dynamic",
);
+ args.remove(0);
IntoIterator::into_iter(["rustc".to_string()])
- .chain(env::args().skip(2))
+ .chain(args)
.chain([
"--".to_string(),
"-Zunstable-options".to_string(),
@@ -60,8 +66,9 @@ fn main() {
"RUSTFLAGS",
env::var("RUSTFLAGS").unwrap_or(String::new()) + " -Cprefer-dynamic",
);
+ args.remove(0);
IntoIterator::into_iter(["rustc".to_string()])
- .chain(env::args().skip(2))
+ .chain(args)
.chain([
"--".to_string(),
"-Zunstable-options".to_string(),
@@ -69,7 +76,7 @@ fn main() {
])
.collect()
}
- _ => env::args().skip(1).collect(),
+ _ => args,
};
#[cfg(unix)]
Hello! Today I set up rustc_codegen_cranelift to try it out on some of my projects on Windows.
I added the binaries to my PATH and ran
which resulted in thousands of copies of
cargo.exe
andcargo-clif.exe
being spawned!This made my PC fairly angry.
Running as
cargo-clif build
works fine. Is running this backend as a cargo subcommand an intended feature, or did I stumble upon something goofy on accident?