From 9ed58e699530d6795a10aaf63220859b7e946037 Mon Sep 17 00:00:00 2001 From: Oneirical Date: Thu, 25 Jul 2024 13:11:36 -0400 Subject: [PATCH] rewrite long-linker-command-lines-cmd-exe to rmake --- .../tidy/src/allowed_run_make_makefiles.txt | 1 - .../Makefile | 7 ----- .../long-linker-command-lines-cmd-exe/foo.rs | 26 +++---------------- .../rmake.rs | 25 ++++++++++++++++++ 4 files changed, 28 insertions(+), 31 deletions(-) delete mode 100644 tests/run-make/long-linker-command-lines-cmd-exe/Makefile create mode 100644 tests/run-make/long-linker-command-lines-cmd-exe/rmake.rs diff --git a/src/tools/tidy/src/allowed_run_make_makefiles.txt b/src/tools/tidy/src/allowed_run_make_makefiles.txt index 371d53b4c8af4..77438bc85fe97 100644 --- a/src/tools/tidy/src/allowed_run_make_makefiles.txt +++ b/src/tools/tidy/src/allowed_run_make_makefiles.txt @@ -33,7 +33,6 @@ run-make/libtest-json/Makefile run-make/libtest-junit/Makefile run-make/libtest-thread-limit/Makefile run-make/link-cfg/Makefile -run-make/long-linker-command-lines-cmd-exe/Makefile run-make/macos-deployment-target/Makefile run-make/min-global-align/Makefile run-make/native-link-modifier-bundle/Makefile diff --git a/tests/run-make/long-linker-command-lines-cmd-exe/Makefile b/tests/run-make/long-linker-command-lines-cmd-exe/Makefile deleted file mode 100644 index e43aab7f8e0fd..0000000000000 --- a/tests/run-make/long-linker-command-lines-cmd-exe/Makefile +++ /dev/null @@ -1,7 +0,0 @@ -# ignore-cross-compile -include ../tools.mk - -all: - $(RUSTC) foo.rs -g - cp foo.bat $(TMPDIR)/ - OUT_DIR="$(TMPDIR)" RUSTC="$(RUSTC_ORIGINAL)" $(call RUN,foo) diff --git a/tests/run-make/long-linker-command-lines-cmd-exe/foo.rs b/tests/run-make/long-linker-command-lines-cmd-exe/foo.rs index 1d5202dcdb493..a28cc7909fefb 100644 --- a/tests/run-make/long-linker-command-lines-cmd-exe/foo.rs +++ b/tests/run-make/long-linker-command-lines-cmd-exe/foo.rs @@ -1,16 +1,3 @@ -// Like the `long-linker-command-lines` test this test attempts to blow -// a command line limit for running the linker. Unlike that test, however, -// this test is testing `cmd.exe` specifically rather than the OS. -// -// Unfortunately `cmd.exe` has a 8192 limit which is relatively small -// in the grand scheme of things and anyone sripting rustc's linker -// is probably using a `*.bat` script and is likely to hit this limit. -// -// This test uses a `foo.bat` script as the linker which just simply -// delegates back to this program. The compiler should use a lower -// limit for arguments before passing everything via `@`, which -// means that everything should still succeed here. - use std::env; use std::fs::{self, File}; use std::io::{BufWriter, Read, Write}; @@ -18,13 +5,8 @@ use std::path::PathBuf; use std::process::Command; fn main() { - if !cfg!(windows) { - return; - } - - let tmpdir = PathBuf::from(env::var_os("OUT_DIR").unwrap()); - let ok = tmpdir.join("ok"); - let not_ok = tmpdir.join("not_ok"); + let ok = PathBuf::from("ok"); + let not_ok = PathBuf::from("not_ok"); if env::var("YOU_ARE_A_LINKER").is_ok() { match env::args_os().find(|a| a.to_string_lossy().contains("@")) { Some(file) => { @@ -45,7 +27,7 @@ fn main() { for i in (1..).map(|i| i * 10) { println!("attempt: {}", i); - let file = tmpdir.join("bar.rs"); + let file = PathBuf::from("bar.rs"); let mut f = BufWriter::new(File::create(&file).unwrap()); let mut lib_name = String::new(); for _ in 0..i { @@ -63,8 +45,6 @@ fn main() { .arg(&file) .arg("-C") .arg(&bat_linker) - .arg("--out-dir") - .arg(&tmpdir) .env("YOU_ARE_A_LINKER", "1") .env("MY_LINKER", &me) .status() diff --git a/tests/run-make/long-linker-command-lines-cmd-exe/rmake.rs b/tests/run-make/long-linker-command-lines-cmd-exe/rmake.rs new file mode 100644 index 0000000000000..02a3e36ea7ce9 --- /dev/null +++ b/tests/run-make/long-linker-command-lines-cmd-exe/rmake.rs @@ -0,0 +1,25 @@ +// Like the `long-linker-command-lines` test this test attempts to blow +// a command line limit for running the linker. Unlike that test, however, +// this test is testing `cmd.exe` specifically rather than the OS. +// +// Unfortunately `cmd.exe` has a 8192 limit which is relatively small +// in the grand scheme of things and anyone sripting rustc's linker +// is probably using a `*.bat` script and is likely to hit this limit. +// +// This test uses a `foo.bat` script as the linker which just simply +// delegates back to this program. The compiler should use a lower +// limit for arguments before passing everything via `@`, which +// means that everything should still succeed here. +// See https://github.com/rust-lang/rust/pull/47507 + +//@ ignore-cross-compile +// Reason: the compiled binary is executed +//@ only-windows +// Reason: this test is specific to Windows executables + +use run_make_support::{run, rustc}; + +fn main() { + rustc().input("foo.rs").arg("-g").run(); + run("foo"); +}