Skip to content

Commit

Permalink
rewrite long-linker-command-lines to rmake
Browse files Browse the repository at this point in the history
  • Loading branch information
Oneirical committed Aug 6, 2024
1 parent 342b807 commit fe6feb8
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 23 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 @@ -13,7 +13,6 @@ run-make/libtest-json/Makefile
run-make/libtest-junit/Makefile
run-make/libtest-thread-limit/Makefile
run-make/long-linker-command-lines-cmd-exe/Makefile
run-make/long-linker-command-lines/Makefile
run-make/macos-deployment-target/Makefile
run-make/min-global-align/Makefile
run-make/native-link-modifier-bundle/Makefile
Expand Down
8 changes: 0 additions & 8 deletions tests/run-make/long-linker-command-lines/Makefile

This file was deleted.

16 changes: 2 additions & 14 deletions tests/run-make/long-linker-command-lines/foo.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,3 @@
// This is a test which attempts to blow out the system limit with how many
// arguments can be passed to a process. This'll successively call rustc with
// larger and larger argument lists in an attempt to find one that's way too
// big for the system at hand. This file itself is then used as a "linker" to
// detect when the process creation succeeds.
//
// Eventually we should see an argument that looks like `@` as we switch from
// passing literal arguments to passing everything in the file.

use std::collections::HashSet;
use std::env;
use std::fs::{self, File};
Expand Down Expand Up @@ -43,8 +34,7 @@ fn read_linker_args(path: &Path) -> String {
}

fn main() {
let tmpdir = PathBuf::from(env::var_os("TMPDIR").unwrap());
let ok = tmpdir.join("ok");
let ok = PathBuf::from("ok");
if env::var("YOU_ARE_A_LINKER").is_ok() {
if let Some(file) = env::args_os().find(|a| a.to_string_lossy().contains("@")) {
let file = file.to_str().expect("non-utf8 file argument");
Expand All @@ -57,16 +47,14 @@ fn main() {
let me_as_linker = format!("linker={}", env::current_exe().unwrap().display());
for i in (1..).map(|i| i * 100) {
println!("attempt: {}", i);
let file = tmpdir.join("bar.rs");
let file = PathBuf::from("bar.rs");
let mut expected_libs = write_test_case(&file, i);

drop(fs::remove_file(&ok));
let output = Command::new(&rustc)
.arg(&file)
.arg("-C")
.arg(&me_as_linker)
.arg("--out-dir")
.arg(&tmpdir)
.env("YOU_ARE_A_LINKER", "1")
.output()
.unwrap();
Expand Down
19 changes: 19 additions & 0 deletions tests/run-make/long-linker-command-lines/rmake.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// This is a test which attempts to blow out the system limit with how many
// arguments can be passed to a process. This'll successively call rustc with
// larger and larger argument lists in an attempt to find one that's way too
// big for the system at hand. This file itself is then used as a "linker" to
// detect when the process creation succeeds.
//
// Eventually we should see an argument that looks like `@` as we switch from
// passing literal arguments to passing everything in the file.
// See https://github.com/rust-lang/rust/issues/41190

//@ ignore-cross-compile
// Reason: the compiled binary is executed

use run_make_support::{run, rustc};

fn main() {
rustc().input("foo.rs").arg("-g").opt().run();
run("foo");
}

0 comments on commit fe6feb8

Please sign in to comment.