Skip to content

Commit

Permalink
rewrite long-linker-command-lines-cmd-exe to rmake
Browse files Browse the repository at this point in the history
  • Loading branch information
Oneirical committed Jul 25, 2024
1 parent 90ba355 commit 9ed58e6
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 31 deletions.
1 change: 0 additions & 1 deletion src/tools/tidy/src/allowed_run_make_makefiles.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 0 additions & 7 deletions tests/run-make/long-linker-command-lines-cmd-exe/Makefile

This file was deleted.

26 changes: 3 additions & 23 deletions tests/run-make/long-linker-command-lines-cmd-exe/foo.rs
Original file line number Diff line number Diff line change
@@ -1,30 +1,12 @@
// 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};
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) => {
Expand All @@ -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 {
Expand All @@ -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()
Expand Down
25 changes: 25 additions & 0 deletions tests/run-make/long-linker-command-lines-cmd-exe/rmake.rs
Original file line number Diff line number Diff line change
@@ -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");
}

0 comments on commit 9ed58e6

Please sign in to comment.