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 ab4112b

Browse files
committedApr 11, 2025·
Auto merge of rust-lang#139242 - jieyouxu:run-make-artifact-names-cross, r=<try>
[WIP] run-make-support: Calculate artifact names for target platform, not host platform > [!CAUTION] > > Stacked on top of rust-lang#139469. This was implemented incorrectly during the porting process, where we relied on std consts. However, `run-make-support` is a host-only library, which meant that these artifact names were for the *host* and not the *target*. Helps with rust-lang#138066. r? `@Kobzol` try-job: armhf-gnu try-job: test-various try-job: x86_64-msvc-1 try-job: i686-msvc-1 try-job: x86_64-mingw-1 try-job: aarch64-apple try-job: x86_64-apple-1
2 parents 71b68da + 0be2f52 commit ab4112b

File tree

8 files changed

+187
-58
lines changed

8 files changed

+187
-58
lines changed
 
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
//! A collection of helpers to construct artifact names, such as names of dynamic or static
2-
//! librarys which are target-dependent.
3-
4-
// FIXME(jieyouxu): convert these to return `PathBuf`s instead of strings!
2+
//! libraries which are target-dependent.
53
4+
use crate::target;
65
use crate::targets::is_msvc;
76

87
/// Construct the static library name based on the target.
8+
#[track_caller]
99
#[must_use]
1010
pub fn static_lib_name(name: &str) -> String {
1111
assert!(!name.contains(char::is_whitespace), "static library name cannot contain whitespace");
@@ -14,15 +14,34 @@ pub fn static_lib_name(name: &str) -> String {
1414
}
1515

1616
/// Construct the dynamic library name based on the target.
17+
#[track_caller]
1718
#[must_use]
1819
pub fn dynamic_lib_name(name: &str) -> String {
1920
assert!(!name.contains(char::is_whitespace), "dynamic library name cannot contain whitespace");
2021

21-
format!("{}{name}.{}", std::env::consts::DLL_PREFIX, std::env::consts::DLL_EXTENSION)
22+
format!("{}{name}.{}", dynamic_lib_prefix(), dynamic_lib_extension())
23+
}
24+
25+
fn dynamic_lib_prefix() -> &'static str {
26+
if target().contains("windows") { "" } else { "lib" }
2227
}
2328

24-
/// Construct the name of the import library for the dynamic library, exclusive to MSVC and
25-
/// accepted by link.exe.
29+
/// Construct the dynamic library extension based on the target.
30+
#[must_use]
31+
pub fn dynamic_lib_extension() -> &'static str {
32+
let target = target();
33+
34+
if target.contains("apple") {
35+
"dylib"
36+
} else if target.contains("windows") {
37+
"dll"
38+
} else {
39+
"so"
40+
}
41+
}
42+
43+
/// Construct the name of the import library for the dynamic library, exclusive to MSVC and accepted
44+
/// by link.exe.
2645
#[track_caller]
2746
#[must_use]
2847
pub fn msvc_import_dynamic_lib_name(name: &str) -> String {
@@ -32,20 +51,28 @@ pub fn msvc_import_dynamic_lib_name(name: &str) -> String {
3251
format!("{name}.dll.lib")
3352
}
3453

35-
/// Construct the dynamic library extension based on the target.
36-
#[must_use]
37-
pub fn dynamic_lib_extension() -> &'static str {
38-
std::env::consts::DLL_EXTENSION
39-
}
40-
4154
/// Construct the name of a rust library (rlib).
55+
#[track_caller]
4256
#[must_use]
4357
pub fn rust_lib_name(name: &str) -> String {
4458
format!("lib{name}.rlib")
4559
}
4660

4761
/// Construct the binary (executable) name based on the target.
62+
#[track_caller]
4863
#[must_use]
4964
pub fn bin_name(name: &str) -> String {
50-
format!("{name}{}", std::env::consts::EXE_SUFFIX)
65+
let target = target();
66+
67+
if target.contains("windows") {
68+
format!("{name}.exe")
69+
} else if target.contains("uefi") {
70+
format!("{name}.efi")
71+
} else if target.contains("wasm") {
72+
format!("{name}.wasm")
73+
} else if target.contains("nvptx") {
74+
format!("{name}.ptx")
75+
} else {
76+
name.to_string()
77+
}
5178
}
+27-5
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,43 @@
1-
use run_make_support::{bin_name, rust_lib_name, rustc};
1+
use run_make_support::{bin_name, rust_lib_name, rustc, target};
22

33
fn main() {
4-
rustc().print("crate-name").input("crate.rs").run().assert_stdout_equals("foo");
5-
rustc().print("file-names").input("crate.rs").run().assert_stdout_equals(bin_name("foo"));
64
rustc()
5+
.target(target())
6+
.print("crate-name")
7+
.input("crate.rs")
8+
.run()
9+
.assert_stdout_equals("foo");
10+
rustc()
11+
.target(target())
12+
.print("file-names")
13+
.input("crate.rs")
14+
.run()
15+
.assert_stdout_equals(bin_name("foo"));
16+
rustc()
17+
.target(target())
718
.print("file-names")
819
.crate_type("lib")
920
.arg("--test")
1021
.input("crate.rs")
1122
.run()
1223
.assert_stdout_equals(bin_name("foo"));
1324
rustc()
25+
.target(target())
1426
.print("file-names")
1527
.arg("--test")
1628
.input("lib.rs")
1729
.run()
1830
.assert_stdout_equals(bin_name("mylib"));
19-
rustc().print("file-names").input("lib.rs").run().assert_stdout_equals(rust_lib_name("mylib"));
20-
rustc().print("file-names").input("rlib.rs").run().assert_stdout_equals(rust_lib_name("mylib"));
31+
rustc()
32+
.target(target())
33+
.print("file-names")
34+
.input("lib.rs")
35+
.run()
36+
.assert_stdout_equals(rust_lib_name("mylib"));
37+
rustc()
38+
.target(target())
39+
.print("file-names")
40+
.input("rlib.rs")
41+
.run()
42+
.assert_stdout_equals(rust_lib_name("mylib"));
2143
}

‎tests/run-make/crate-name-priority/rmake.rs

+7-5
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,17 @@
44
// and the compiler flags, and checks that the flag is favoured each time.
55
// See https://github.com/rust-lang/rust/pull/15518
66

7-
use run_make_support::{bin_name, rfs, rustc};
7+
//@ ignore-cross-compile (relocations in generic ELF against `arm-unknown-linux-gnueabihf`)
8+
9+
use run_make_support::{bin_name, rfs, rustc, target};
810

911
fn main() {
10-
rustc().input("foo.rs").run();
12+
rustc().target(target()).input("foo.rs").run();
1113
rfs::remove_file(bin_name("foo"));
12-
rustc().input("foo.rs").crate_name("bar").run();
14+
rustc().target(target()).input("foo.rs").crate_name("bar").run();
1315
rfs::remove_file(bin_name("bar"));
14-
rustc().input("foo1.rs").run();
16+
rustc().target(target()).input("foo1.rs").run();
1517
rfs::remove_file(bin_name("foo"));
16-
rustc().input("foo1.rs").output(bin_name("bar1")).run();
18+
rustc().target(target()).input("foo1.rs").output(bin_name("bar1")).run();
1719
rfs::remove_file(bin_name("bar1"));
1820
}

‎tests/run-make/extra-filename-with-temp-outputs/rmake.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,14 @@
66
// are named as expected.
77
// See https://github.com/rust-lang/rust/pull/15686
88

9-
use run_make_support::{bin_name, cwd, has_prefix, has_suffix, rfs, rustc, shallow_find_files};
9+
//@ ignore-cross-compile (relocations in generic ELF against `arm-unknown-linux-gnueabihf`)
10+
11+
use run_make_support::{
12+
bin_name, cwd, has_prefix, has_suffix, rfs, rustc, shallow_find_files, target,
13+
};
1014

1115
fn main() {
12-
rustc().extra_filename("bar").input("foo.rs").arg("-Csave-temps").run();
16+
rustc().target(target()).extra_filename("bar").input("foo.rs").arg("-Csave-temps").run();
1317
let object_files = shallow_find_files(cwd(), |path| {
1418
has_prefix(path, "foobar.foo") && has_suffix(path, "0.rcgu.o")
1519
});

‎tests/run-make/output-type-permutations/rmake.rs

+93-24
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,14 @@
44
// files are exactly what is expected, no more, no less.
55
// See https://github.com/rust-lang/rust/pull/12020
66

7+
//@ ignore-cross-compile
8+
// Reason: some cross-compiled targets don't support various crate types and fail to link.
9+
710
use std::path::PathBuf;
811

912
use run_make_support::{
1013
bin_name, dynamic_lib_name, filename_not_in_denylist, rfs, rust_lib_name, rustc,
11-
shallow_find_files, static_lib_name,
14+
shallow_find_files, static_lib_name, target,
1215
};
1316

1417
// Each test takes 4 arguments:
@@ -17,6 +20,7 @@ use run_make_support::{
1720
// `dir`: the name of the directory where the test happens
1821
// `rustc_invocation`: the rustc command being tested
1922
// Any unexpected output files not listed in `must_exist` or `can_exist` will cause a failure.
23+
#[track_caller]
2024
fn assert_expected_output_files(expectations: Expectations, rustc_invocation: impl Fn()) {
2125
let Expectations { expected_files: must_exist, allowed_files: can_exist, test_dir: dir } =
2226
expectations;
@@ -81,6 +85,7 @@ fn main() {
8185
},
8286
|| {
8387
rustc()
88+
.target(target())
8489
.input("foo.rs")
8590
.out_dir("three-crates")
8691
.crate_type("rlib,dylib,staticlib")
@@ -95,7 +100,7 @@ fn main() {
95100
test_dir: "bin-crate".to_string(),
96101
},
97102
|| {
98-
rustc().input("foo.rs").crate_type("bin").out_dir("bin-crate").run();
103+
rustc().target(target()).input("foo.rs").crate_type("bin").out_dir("bin-crate").run();
99104
},
100105
);
101106

@@ -106,7 +111,12 @@ fn main() {
106111
test_dir: "all-emit".to_string(),
107112
},
108113
|| {
109-
rustc().input("foo.rs").emit("asm,llvm-ir,llvm-bc,obj,link").out_dir("all-emit").run();
114+
rustc()
115+
.target(target())
116+
.input("foo.rs")
117+
.emit("asm,llvm-ir,llvm-bc,obj,link")
118+
.out_dir("all-emit")
119+
.run();
110120
},
111121
);
112122

@@ -117,7 +127,7 @@ fn main() {
117127
test_dir: "asm-emit".to_string(),
118128
},
119129
|| {
120-
rustc().input("foo.rs").emit("asm").output("asm-emit/foo").run();
130+
rustc().target(target()).input("foo.rs").emit("asm").output("asm-emit/foo").run();
121131
},
122132
);
123133
assert_expected_output_files(
@@ -127,7 +137,7 @@ fn main() {
127137
test_dir: "asm-emit2".to_string(),
128138
},
129139
|| {
130-
rustc().input("foo.rs").emit("asm=asm-emit2/foo").run();
140+
rustc().target(target()).input("foo.rs").emit("asm=asm-emit2/foo").run();
131141
},
132142
);
133143
assert_expected_output_files(
@@ -137,7 +147,7 @@ fn main() {
137147
test_dir: "asm-emit3".to_string(),
138148
},
139149
|| {
140-
rustc().input("foo.rs").arg("--emit=asm=asm-emit3/foo").run();
150+
rustc().target(target()).input("foo.rs").arg("--emit=asm=asm-emit3/foo").run();
141151
},
142152
);
143153

@@ -148,7 +158,12 @@ fn main() {
148158
test_dir: "llvm-ir-emit".to_string(),
149159
},
150160
|| {
151-
rustc().input("foo.rs").emit("llvm-ir").output("llvm-ir-emit/foo").run();
161+
rustc()
162+
.target(target())
163+
.input("foo.rs")
164+
.emit("llvm-ir")
165+
.output("llvm-ir-emit/foo")
166+
.run();
152167
},
153168
);
154169
assert_expected_output_files(
@@ -158,7 +173,7 @@ fn main() {
158173
test_dir: "llvm-ir-emit2".to_string(),
159174
},
160175
|| {
161-
rustc().input("foo.rs").emit("llvm-ir=llvm-ir-emit2/foo").run();
176+
rustc().target(target()).input("foo.rs").emit("llvm-ir=llvm-ir-emit2/foo").run();
162177
},
163178
);
164179
assert_expected_output_files(
@@ -168,7 +183,7 @@ fn main() {
168183
test_dir: "llvm-ir-emit3".to_string(),
169184
},
170185
|| {
171-
rustc().input("foo.rs").arg("--emit=llvm-ir=llvm-ir-emit3/foo").run();
186+
rustc().target(target()).input("foo.rs").arg("--emit=llvm-ir=llvm-ir-emit3/foo").run();
172187
},
173188
);
174189

@@ -179,7 +194,12 @@ fn main() {
179194
test_dir: "llvm-bc-emit".to_string(),
180195
},
181196
|| {
182-
rustc().input("foo.rs").emit("llvm-bc").output("llvm-bc-emit/foo").run();
197+
rustc()
198+
.target(target())
199+
.input("foo.rs")
200+
.emit("llvm-bc")
201+
.output("llvm-bc-emit/foo")
202+
.run();
183203
},
184204
);
185205
assert_expected_output_files(
@@ -189,7 +209,7 @@ fn main() {
189209
test_dir: "llvm-bc-emit2".to_string(),
190210
},
191211
|| {
192-
rustc().input("foo.rs").emit("llvm-bc=llvm-bc-emit2/foo").run();
212+
rustc().target(target()).input("foo.rs").emit("llvm-bc=llvm-bc-emit2/foo").run();
193213
},
194214
);
195215
assert_expected_output_files(
@@ -199,7 +219,7 @@ fn main() {
199219
test_dir: "llvm-bc-emit3".to_string(),
200220
},
201221
|| {
202-
rustc().input("foo.rs").arg("--emit=llvm-bc=llvm-bc-emit3/foo").run();
222+
rustc().target(target()).input("foo.rs").arg("--emit=llvm-bc=llvm-bc-emit3/foo").run();
203223
},
204224
);
205225

@@ -210,7 +230,7 @@ fn main() {
210230
test_dir: "obj-emit".to_string(),
211231
},
212232
|| {
213-
rustc().input("foo.rs").emit("obj").output("obj-emit/foo").run();
233+
rustc().target(target()).input("foo.rs").emit("obj").output("obj-emit/foo").run();
214234
},
215235
);
216236
assert_expected_output_files(
@@ -220,7 +240,7 @@ fn main() {
220240
test_dir: "obj-emit2".to_string(),
221241
},
222242
|| {
223-
rustc().input("foo.rs").emit("obj=obj-emit2/foo").run();
243+
rustc().target(target()).input("foo.rs").emit("obj=obj-emit2/foo").run();
224244
},
225245
);
226246
assert_expected_output_files(
@@ -230,7 +250,7 @@ fn main() {
230250
test_dir: "obj-emit3".to_string(),
231251
},
232252
|| {
233-
rustc().input("foo.rs").arg("--emit=obj=obj-emit3/foo").run();
253+
rustc().target(target()).input("foo.rs").arg("--emit=obj=obj-emit3/foo").run();
234254
},
235255
);
236256

@@ -241,7 +261,12 @@ fn main() {
241261
test_dir: "link-emit".to_string(),
242262
},
243263
|| {
244-
rustc().input("foo.rs").emit("link").output("link-emit/".to_owned() + &bin_foo).run();
264+
rustc()
265+
.target(target())
266+
.input("foo.rs")
267+
.emit("link")
268+
.output("link-emit/".to_owned() + &bin_foo)
269+
.run();
245270
},
246271
);
247272
assert_expected_output_files(
@@ -251,7 +276,11 @@ fn main() {
251276
test_dir: "link-emit2".to_string(),
252277
},
253278
|| {
254-
rustc().input("foo.rs").emit(&format!("link=link-emit2/{bin_foo}")).run();
279+
rustc()
280+
.target(target())
281+
.input("foo.rs")
282+
.emit(&format!("link=link-emit2/{bin_foo}"))
283+
.run();
255284
},
256285
);
257286
assert_expected_output_files(
@@ -261,7 +290,11 @@ fn main() {
261290
test_dir: "link-emit3".to_string(),
262291
},
263292
|| {
264-
rustc().input("foo.rs").arg(&format!("--emit=link=link-emit3/{bin_foo}")).run();
293+
rustc()
294+
.target(target())
295+
.input("foo.rs")
296+
.arg(&format!("--emit=link=link-emit3/{bin_foo}"))
297+
.run();
265298
},
266299
);
267300

@@ -272,7 +305,7 @@ fn main() {
272305
test_dir: "rlib".to_string(),
273306
},
274307
|| {
275-
rustc().crate_type("rlib").input("foo.rs").output("rlib/foo").run();
308+
rustc().target(target()).crate_type("rlib").input("foo.rs").output("rlib/foo").run();
276309
},
277310
);
278311
assert_expected_output_files(
@@ -282,7 +315,12 @@ fn main() {
282315
test_dir: "rlib2".to_string(),
283316
},
284317
|| {
285-
rustc().crate_type("rlib").input("foo.rs").emit("link=rlib2/foo").run();
318+
rustc()
319+
.target(target())
320+
.crate_type("rlib")
321+
.input("foo.rs")
322+
.emit("link=rlib2/foo")
323+
.run();
286324
},
287325
);
288326
assert_expected_output_files(
@@ -292,7 +330,12 @@ fn main() {
292330
test_dir: "rlib3".to_string(),
293331
},
294332
|| {
295-
rustc().crate_type("rlib").input("foo.rs").arg("--emit=link=rlib3/foo").run();
333+
rustc()
334+
.target(target())
335+
.crate_type("rlib")
336+
.input("foo.rs")
337+
.arg("--emit=link=rlib3/foo")
338+
.run();
296339
},
297340
);
298341

@@ -315,6 +358,7 @@ fn main() {
315358
},
316359
|| {
317360
rustc()
361+
.target(target())
318362
.crate_type("dylib")
319363
.input("foo.rs")
320364
.output("dylib/".to_owned() + &bin_foo)
@@ -340,6 +384,7 @@ fn main() {
340384
},
341385
|| {
342386
rustc()
387+
.target(target())
343388
.crate_type("dylib")
344389
.input("foo.rs")
345390
.emit(&format!("link=dylib2/{bin_foo}"))
@@ -365,6 +410,7 @@ fn main() {
365410
},
366411
|| {
367412
rustc()
413+
.target(target())
368414
.crate_type("dylib")
369415
.input("foo.rs")
370416
.arg(&format!("--emit=link=dylib3/{bin_foo}"))
@@ -379,7 +425,12 @@ fn main() {
379425
test_dir: "staticlib".to_string(),
380426
},
381427
|| {
382-
rustc().crate_type("staticlib").input("foo.rs").output("staticlib/foo").run();
428+
rustc()
429+
.target(target())
430+
.crate_type("staticlib")
431+
.input("foo.rs")
432+
.output("staticlib/foo")
433+
.run();
383434
},
384435
);
385436
assert_expected_output_files(
@@ -389,7 +440,12 @@ fn main() {
389440
test_dir: "staticlib2".to_string(),
390441
},
391442
|| {
392-
rustc().crate_type("staticlib").input("foo.rs").emit("link=staticlib2/foo").run();
443+
rustc()
444+
.target(target())
445+
.crate_type("staticlib")
446+
.input("foo.rs")
447+
.emit("link=staticlib2/foo")
448+
.run();
393449
},
394450
);
395451
assert_expected_output_files(
@@ -399,7 +455,12 @@ fn main() {
399455
test_dir: "staticlib3".to_string(),
400456
},
401457
|| {
402-
rustc().crate_type("staticlib").input("foo.rs").arg("--emit=link=staticlib3/foo").run();
458+
rustc()
459+
.target(target())
460+
.crate_type("staticlib")
461+
.input("foo.rs")
462+
.arg("--emit=link=staticlib3/foo")
463+
.run();
403464
},
404465
);
405466

@@ -411,6 +472,7 @@ fn main() {
411472
},
412473
|| {
413474
rustc()
475+
.target(target())
414476
.crate_type("bin")
415477
.input("foo.rs")
416478
.output("bincrate/".to_owned() + &bin_foo)
@@ -425,6 +487,7 @@ fn main() {
425487
},
426488
|| {
427489
rustc()
490+
.target(target())
428491
.crate_type("bin")
429492
.input("foo.rs")
430493
.emit(&format!("link=bincrate2/{bin_foo}"))
@@ -439,6 +502,7 @@ fn main() {
439502
},
440503
|| {
441504
rustc()
505+
.target(target())
442506
.crate_type("bin")
443507
.input("foo.rs")
444508
.arg(&format!("--emit=link=bincrate3/{bin_foo}"))
@@ -454,6 +518,7 @@ fn main() {
454518
},
455519
|| {
456520
rustc()
521+
.target(target())
457522
.input("foo.rs")
458523
.emit("llvm-ir=rlib-ir/ir")
459524
.emit("link")
@@ -471,6 +536,7 @@ fn main() {
471536
},
472537
|| {
473538
rustc()
539+
.target(target())
474540
.input("foo.rs")
475541
.emit("asm=staticlib-all/asm")
476542
.emit("llvm-ir=staticlib-all/ir")
@@ -489,6 +555,7 @@ fn main() {
489555
},
490556
|| {
491557
rustc()
558+
.target(target())
492559
.input("foo.rs")
493560
.arg("--emit=asm=staticlib-all2/asm")
494561
.arg("--emit")
@@ -510,6 +577,7 @@ fn main() {
510577
},
511578
|| {
512579
rustc()
580+
.target(target())
513581
.input("foo.rs")
514582
.emit("asm,llvm-ir,llvm-bc,obj,link")
515583
.crate_type("staticlib")
@@ -529,6 +597,7 @@ fn main() {
529597
|| {
530598
rfs::rename("staticlib-all3/bar.bc", "rlib-emits/foo.bc");
531599
rustc()
600+
.target(target())
532601
.input("foo.rs")
533602
.emit("llvm-bc,link")
534603
.crate_type("rlib")

‎tests/run-make/reproducible-build/rmake.rs

+2
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
// See https://github.com/rust-lang/rust/pull/32293
2121
// Tracking Issue: https://github.com/rust-lang/rust/issues/129080
2222

23+
//@ ignore-cross-compile (linker binary needs to run)
24+
2325
use run_make_support::{
2426
bin_name, cwd, diff, is_darwin, is_windows, regex, rfs, run_in_tmpdir, rust_lib_name, rustc,
2527
};

‎tests/run-make/strip/rmake.rs

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
//@ ignore-windows Windows does not actually strip
1+
//@ ignore-windows (Windows does not actually strip)
2+
//@ ignore-cross-compile (relocations in generic ELF against `arm-unknown-linux-gnueabihf`)
23

34
// Test that -Cstrip correctly strips/preserves debuginfo and symbols.
45

5-
use run_make_support::{bin_name, is_darwin, llvm_dwarfdump, llvm_nm, rustc};
6+
use run_make_support::{bin_name, is_darwin, llvm_dwarfdump, llvm_nm, rustc, target};
67

78
fn main() {
89
// We use DW_ (the start of any DWARF name) to check that some debuginfo is present.
@@ -20,21 +21,21 @@ fn main() {
2021
// for std.
2122

2223
// -Cstrip=none should preserve symbols and debuginfo.
23-
rustc().arg("hello.rs").arg("-Cdebuginfo=2").arg("-Cstrip=none").run();
24+
rustc().target(target()).arg("hello.rs").arg("-Cdebuginfo=2").arg("-Cstrip=none").run();
2425
llvm_nm().input(binary).run().assert_stdout_contains(test_symbol);
2526
if do_debuginfo_check {
2627
llvm_dwarfdump().input(binary).run().assert_stdout_contains(dwarf_indicator);
2728
}
2829

2930
// -Cstrip=debuginfo should preserve symbols and strip debuginfo.
30-
rustc().arg("hello.rs").arg("-Cdebuginfo=2").arg("-Cstrip=debuginfo").run();
31+
rustc().target(target()).arg("hello.rs").arg("-Cdebuginfo=2").arg("-Cstrip=debuginfo").run();
3132
llvm_nm().input(binary).run().assert_stdout_contains(test_symbol);
3233
if do_debuginfo_check {
3334
llvm_dwarfdump().input(binary).run().assert_stdout_not_contains(dwarf_indicator);
3435
}
3536

3637
// -Cstrip=symbols should strip symbols and strip debuginfo.
37-
rustc().arg("hello.rs").arg("-Cdebuginfo=2").arg("-Cstrip=symbols").run();
38+
rustc().target(target()).arg("hello.rs").arg("-Cdebuginfo=2").arg("-Cstrip=symbols").run();
3839
llvm_nm().input(binary).run().assert_stderr_not_contains(test_symbol);
3940
if do_debuginfo_check {
4041
llvm_dwarfdump().input(binary).run().assert_stdout_not_contains(dwarf_indicator);

‎tests/run-make/symbols-all-mangled/rmake.rs

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
11
// Check that all symbols in cdylibs, staticlibs and bins are mangled
22
//@ only-elf some object file formats create multiple symbols for each function with different names
3+
//@ ignore-nvptx64 (needs target std)
4+
//@ ignore-cross-compile (host-only)
35

46
use run_make_support::object::read::{Object, ObjectSymbol};
5-
use run_make_support::{bin_name, dynamic_lib_name, object, rfs, rustc, static_lib_name};
7+
use run_make_support::{bin_name, dynamic_lib_name, object, rfs, rustc, static_lib_name, target};
68

79
fn main() {
810
let staticlib_name = static_lib_name("a_lib");
911
let cdylib_name = dynamic_lib_name("a_lib");
1012
let exe_name = bin_name("an_executable");
11-
rustc().crate_type("cdylib").input("a_lib.rs").run();
12-
rustc().crate_type("staticlib").input("a_lib.rs").run();
13-
rustc().crate_type("bin").input("an_executable.rs").run();
13+
rustc().target(target()).crate_type("cdylib").input("a_lib.rs").run();
14+
rustc().target(target()).crate_type("staticlib").input("a_lib.rs").run();
15+
rustc().target(target()).crate_type("bin").input("an_executable.rs").run();
1416

1517
symbols_check_archive(&staticlib_name);
1618
symbols_check(&cdylib_name);

0 commit comments

Comments
 (0)
Please sign in to comment.