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 Aug 6, 2024
1 parent fe6feb8 commit fe4cd9a
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 38 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 @@ -12,7 +12,6 @@ run-make/libs-through-symlinks/Makefile
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/macos-deployment-target/Makefile
run-make/min-global-align/Makefile
run-make/native-link-modifier-bundle/Makefile
Expand Down
8 changes: 2 additions & 6 deletions tests/run-make/cross-lang-lto-upstream-rlibs/rmake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@
// thin LTO.
// See https://github.com/rust-lang/rust/pull/53031

// ignore windows due to libLLVM being present in PATH and the PATH and library path being the same
// (so fixing it is harder). See #57765 for context
//FIXME(Oneirical): ignore-windows

use run_make_support::{
cwd, has_extension, has_prefix, has_suffix, llvm_ar, rfs, rustc, shallow_find_files,
static_lib_name,
Expand All @@ -22,7 +18,7 @@ fn main() {
.codegen_units(1)
.output(static_lib_name("staticlib"))
.run();
llvm_ar().arg("x").arg(static_lib_name("staticlib")).run();
llvm_ar().extract().arg(static_lib_name("staticlib")).run();
// Ensure the upstream object file was included.
assert_eq!(
shallow_find_files(cwd(), |path| {
Expand Down Expand Up @@ -50,7 +46,7 @@ fn main() {
.arg("-Clto=thin")
.output(static_lib_name("staticlib"))
.run();
llvm_ar().arg("x").arg(static_lib_name("staticlib")).run();
llvm_ar().extract().arg(static_lib_name("staticlib")).run();
assert_eq!(
shallow_find_files(cwd(), |path| {
has_prefix(path, "upstream.") && has_suffix(path, ".rcgu.o")
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
26 changes: 26 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,26 @@
// 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, the maximum length of the string that you can use at the
// command prompt (`cmd.exe`) is 8191 characters.
// Anyone scripting 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");
}
2 changes: 1 addition & 1 deletion tests/run-make/long-linker-command-lines/foo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ fn main() {
return;
}

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

0 comments on commit fe4cd9a

Please sign in to comment.