Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 281da17

Browse files
committedMar 5, 2025
Enable automatic cross-compilation in run-make tests
1 parent 4559163 commit 281da17

File tree

7 files changed

+13
-22
lines changed

7 files changed

+13
-22
lines changed
 

‎src/tools/run-make-support/src/external_deps/rustc.rs

+8-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use crate::command::Command;
66
use crate::env::env_var;
77
use crate::path_helpers::cwd;
88
use crate::util::set_host_compiler_dylib_path;
9-
use crate::{is_aix, is_darwin, is_msvc, is_windows, uname};
9+
use crate::{is_aix, is_darwin, is_msvc, is_windows, target, uname};
1010

1111
/// Construct a new `rustc` invocation. This will automatically set the library
1212
/// search path as `-L cwd()`. Use [`bare_rustc`] to avoid this.
@@ -52,12 +52,17 @@ impl Rustc {
5252
// `rustc` invocation constructor methods
5353

5454
/// Construct a new `rustc` invocation. This will automatically set the library
55-
/// search path as `-L cwd()`. Use [`bare_rustc`] to avoid this.
55+
/// search path as `-L cwd()` and also the compilation target.
56+
/// Use [`bare_rustc`] to avoid this.
5657
#[track_caller]
5758
pub fn new() -> Self {
5859
let mut cmd = setup_common();
5960
cmd.arg("-L").arg(cwd());
60-
Self { cmd }
61+
62+
let mut rustc = Self { cmd };
63+
// Automatically support cross-compilation
64+
rustc.target(target());
65+
rustc
6166
}
6267

6368
/// Construct a bare `rustc` invocation with no flags set.

‎tests/run-make/apple-deployment-target/rmake.rs

-5
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ fn main() {
4141

4242
// Remove env vars to get `rustc`'s default
4343
let output = rustc()
44-
.target(target())
4544
.env_remove("MACOSX_DEPLOYMENT_TARGET")
4645
.env_remove("IPHONEOS_DEPLOYMENT_TARGET")
4746
.env_remove("WATCHOS_DEPLOYMENT_TARGET")
@@ -58,7 +57,6 @@ fn main() {
5857
run_in_tmpdir(|| {
5958
let rustc = || {
6059
let mut rustc = rustc();
61-
rustc.target(target());
6260
rustc.crate_type("lib");
6361
rustc.emit("obj");
6462
rustc.input("foo.rs");
@@ -82,7 +80,6 @@ fn main() {
8280

8381
let rustc = || {
8482
let mut rustc = rustc();
85-
rustc.target(target());
8683
rustc.crate_type("dylib");
8784
rustc.input("foo.rs");
8885
rustc.output("libfoo.dylib");
@@ -108,7 +105,6 @@ fn main() {
108105
run_in_tmpdir(|| {
109106
let rustc = || {
110107
let mut rustc = rustc();
111-
rustc.target(target());
112108
rustc.crate_type("bin");
113109
rustc.input("foo.rs");
114110
rustc.output("foo");
@@ -147,7 +143,6 @@ fn main() {
147143
run_in_tmpdir(|| {
148144
let rustc = || {
149145
let mut rustc = rustc();
150-
rustc.target(target());
151146
rustc.incremental("incremental");
152147
rustc.crate_type("lib");
153148
rustc.emit("obj");

‎tests/run-make/apple-sdk-version/rmake.rs

+3-6
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@ fn has_sdk_version(file: &str, version: &str) {
2424

2525
fn main() {
2626
// Fetch rustc's inferred deployment target.
27-
let current_deployment_target =
28-
rustc().target(target()).print("deployment-target").run().stdout_utf8();
27+
let current_deployment_target = rustc().print("deployment-target").run().stdout_utf8();
2928
let current_deployment_target = current_deployment_target.split('=').last().unwrap().trim();
3029

3130
// Fetch current SDK version via. xcrun.
@@ -45,15 +44,15 @@ fn main() {
4544
let current_sdk_version = current_sdk_version.trim();
4645

4746
// Check the SDK version in the object file produced by the codegen backend.
48-
rustc().target(target()).crate_type("lib").emit("obj").input("foo.rs").output("foo.o").run();
47+
rustc().crate_type("lib").emit("obj").input("foo.rs").output("foo.o").run();
4948
// Set to 0, which means not set or "n/a".
5049
has_sdk_version("foo.o", "n/a");
5150

5251
// Check the SDK version in the .rmeta file, as set in `create_object_file`.
5352
//
5453
// This is just to ensure that we don't set some odd version in `create_object_file`,
5554
// if the rmeta file is packed in a different way in the future, this can safely be removed.
56-
rustc().target(target()).crate_type("rlib").input("foo.rs").output("libfoo.rlib").run();
55+
rustc().crate_type("rlib").input("foo.rs").output("libfoo.rlib").run();
5756
// Extra .rmeta file (which is encoded as an object file).
5857
cmd("ar").arg("-x").arg("libfoo.rlib").arg("lib.rmeta").run();
5958
has_sdk_version("lib.rmeta", "n/a");
@@ -69,7 +68,6 @@ fn main() {
6968
// Test with clang
7069
let file_name = format!("foo_cc{file_ext}");
7170
rustc()
72-
.target(target())
7371
.crate_type("bin")
7472
.arg("-Clinker-flavor=gcc")
7573
.input("foo.rs")
@@ -80,7 +78,6 @@ fn main() {
8078
// Test with ld64
8179
let file_name = format!("foo_ld{file_ext}");
8280
rustc()
83-
.target(target())
8481
.crate_type("bin")
8582
.arg("-Clinker-flavor=ld")
8683
.input("foo.rs")

‎tests/run-make/mte-ffi/rmake.rs

+1-5
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,7 @@ fn run_test(variant: &str) {
2222
flags
2323
};
2424
println!("{variant} test...");
25-
rustc()
26-
.input(format!("foo_{variant}.rs"))
27-
.target(target())
28-
.linker("aarch64-linux-gnu-gcc")
29-
.run();
25+
rustc().input(format!("foo_{variant}.rs")).linker("aarch64-linux-gnu-gcc").run();
3026
gcc()
3127
.input(format!("bar_{variant}.c"))
3228
.input(dynamic_lib_name("foo"))

‎tests/run-make/rustc-macro-dep-files/rmake.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use run_make_support::{diff, rustc, target};
88

99
fn main() {
1010
rustc().input("foo.rs").run();
11-
rustc().input("bar.rs").target(target()).emit("dep-info").run();
11+
rustc().input("bar.rs").emit("dep-info").run();
1212
// The emitted file should not contain "proc-macro source".
1313
diff().expected_file("correct.d").actual_file("bar.d").run();
1414
}

‎tests/run-make/static-pie/rmake.rs

-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ fn test(compiler: &str) {
4949

5050
rustc()
5151
.input("test-aslr.rs")
52-
.target(target())
5352
.linker(compiler)
5453
.arg("-Clinker-flavor=gcc")
5554
.arg("-Ctarget-feature=+crt-static")

‎tests/run-make/sysroot-crates-are-unstable/rmake.rs

-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ fn check_crate_is_unstable(cr: &Crate) {
3131
// Trying to use this crate from a user program should fail.
3232
let output = rustc()
3333
.crate_type("rlib")
34-
.target(target())
3534
.extern_(name, path)
3635
.input("-")
3736
.stdin_buf(format!("extern crate {name};"))

0 commit comments

Comments
 (0)
Failed to load comments.