Skip to content

Commit fe4cd9a

Browse files
committedAug 6, 2024
rewrite long-linker-command-lines-cmd-exe to rmake
1 parent fe6feb8 commit fe4cd9a

File tree

6 files changed

+32
-38
lines changed

6 files changed

+32
-38
lines changed
 

‎src/tools/tidy/src/allowed_run_make_makefiles.txt

-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ run-make/libs-through-symlinks/Makefile
1212
run-make/libtest-json/Makefile
1313
run-make/libtest-junit/Makefile
1414
run-make/libtest-thread-limit/Makefile
15-
run-make/long-linker-command-lines-cmd-exe/Makefile
1615
run-make/macos-deployment-target/Makefile
1716
run-make/min-global-align/Makefile
1817
run-make/native-link-modifier-bundle/Makefile

‎tests/run-make/cross-lang-lto-upstream-rlibs/rmake.rs

+2-6
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,6 @@
44
// thin LTO.
55
// See https://github.com/rust-lang/rust/pull/53031
66

7-
// ignore windows due to libLLVM being present in PATH and the PATH and library path being the same
8-
// (so fixing it is harder). See #57765 for context
9-
//FIXME(Oneirical): ignore-windows
10-
117
use run_make_support::{
128
cwd, has_extension, has_prefix, has_suffix, llvm_ar, rfs, rustc, shallow_find_files,
139
static_lib_name,
@@ -22,7 +18,7 @@ fn main() {
2218
.codegen_units(1)
2319
.output(static_lib_name("staticlib"))
2420
.run();
25-
llvm_ar().arg("x").arg(static_lib_name("staticlib")).run();
21+
llvm_ar().extract().arg(static_lib_name("staticlib")).run();
2622
// Ensure the upstream object file was included.
2723
assert_eq!(
2824
shallow_find_files(cwd(), |path| {
@@ -50,7 +46,7 @@ fn main() {
5046
.arg("-Clto=thin")
5147
.output(static_lib_name("staticlib"))
5248
.run();
53-
llvm_ar().arg("x").arg(static_lib_name("staticlib")).run();
49+
llvm_ar().extract().arg(static_lib_name("staticlib")).run();
5450
assert_eq!(
5551
shallow_find_files(cwd(), |path| {
5652
has_prefix(path, "upstream.") && has_suffix(path, ".rcgu.o")

‎tests/run-make/long-linker-command-lines-cmd-exe/Makefile

-7
This file was deleted.

‎tests/run-make/long-linker-command-lines-cmd-exe/foo.rs

+3-23
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,12 @@
1-
// Like the `long-linker-command-lines` test this test attempts to blow
2-
// a command line limit for running the linker. Unlike that test, however,
3-
// this test is testing `cmd.exe` specifically rather than the OS.
4-
//
5-
// Unfortunately `cmd.exe` has a 8192 limit which is relatively small
6-
// in the grand scheme of things and anyone sripting rustc's linker
7-
// is probably using a `*.bat` script and is likely to hit this limit.
8-
//
9-
// This test uses a `foo.bat` script as the linker which just simply
10-
// delegates back to this program. The compiler should use a lower
11-
// limit for arguments before passing everything via `@`, which
12-
// means that everything should still succeed here.
13-
141
use std::env;
152
use std::fs::{self, File};
163
use std::io::{BufWriter, Read, Write};
174
use std::path::PathBuf;
185
use std::process::Command;
196

207
fn main() {
21-
if !cfg!(windows) {
22-
return;
23-
}
24-
25-
let tmpdir = PathBuf::from(env::var_os("OUT_DIR").unwrap());
26-
let ok = tmpdir.join("ok");
27-
let not_ok = tmpdir.join("not_ok");
8+
let ok = PathBuf::from("ok");
9+
let not_ok = PathBuf::from("not_ok");
2810
if env::var("YOU_ARE_A_LINKER").is_ok() {
2911
match env::args_os().find(|a| a.to_string_lossy().contains("@")) {
3012
Some(file) => {
@@ -45,7 +27,7 @@ fn main() {
4527
for i in (1..).map(|i| i * 10) {
4628
println!("attempt: {}", i);
4729

48-
let file = tmpdir.join("bar.rs");
30+
let file = PathBuf::from("bar.rs");
4931
let mut f = BufWriter::new(File::create(&file).unwrap());
5032
let mut lib_name = String::new();
5133
for _ in 0..i {
@@ -63,8 +45,6 @@ fn main() {
6345
.arg(&file)
6446
.arg("-C")
6547
.arg(&bat_linker)
66-
.arg("--out-dir")
67-
.arg(&tmpdir)
6848
.env("YOU_ARE_A_LINKER", "1")
6949
.env("MY_LINKER", &me)
7050
.status()
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// Like the `long-linker-command-lines` test this test attempts to blow
2+
// a command line limit for running the linker. Unlike that test, however,
3+
// this test is testing `cmd.exe` specifically rather than the OS.
4+
//
5+
// Unfortunately, the maximum length of the string that you can use at the
6+
// command prompt (`cmd.exe`) is 8191 characters.
7+
// Anyone scripting rustc's linker
8+
// is probably using a `*.bat` script and is likely to hit this limit.
9+
//
10+
// This test uses a `foo.bat` script as the linker which just simply
11+
// delegates back to this program. The compiler should use a lower
12+
// limit for arguments before passing everything via `@`, which
13+
// means that everything should still succeed here.
14+
// See https://github.com/rust-lang/rust/pull/47507
15+
16+
//@ ignore-cross-compile
17+
// Reason: the compiled binary is executed
18+
//@ only-windows
19+
// Reason: this test is specific to Windows executables
20+
21+
use run_make_support::{run, rustc};
22+
23+
fn main() {
24+
rustc().input("foo.rs").arg("-g").run();
25+
run("foo");
26+
}

‎tests/run-make/long-linker-command-lines/foo.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ fn main() {
4343
return;
4444
}
4545

46-
let rustc = env::var_os("RUSTC").unwrap_or("rustc".into());
46+
let rustc = env::var_os("RUSTC").unwrap();
4747
let me_as_linker = format!("linker={}", env::current_exe().unwrap().display());
4848
for i in (1..).map(|i| i * 100) {
4949
println!("attempt: {}", i);

0 commit comments

Comments
 (0)