4
4
// files are exactly what is expected, no more, no less.
5
5
// See https://github.com/rust-lang/rust/pull/12020
6
6
7
+ //@ ignore-cross-compile
8
+ // Reason: some cross-compiled targets don't support various crate types and fail to link.
9
+
7
10
use std:: path:: PathBuf ;
8
11
9
12
use run_make_support:: {
10
13
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 ,
12
15
} ;
13
16
14
17
// Each test takes 4 arguments:
@@ -17,6 +20,7 @@ use run_make_support::{
17
20
// `dir`: the name of the directory where the test happens
18
21
// `rustc_invocation`: the rustc command being tested
19
22
// Any unexpected output files not listed in `must_exist` or `can_exist` will cause a failure.
23
+ #[ track_caller]
20
24
fn assert_expected_output_files ( expectations : Expectations , rustc_invocation : impl Fn ( ) ) {
21
25
let Expectations { expected_files : must_exist, allowed_files : can_exist, test_dir : dir } =
22
26
expectations;
@@ -81,6 +85,7 @@ fn main() {
81
85
} ,
82
86
|| {
83
87
rustc ( )
88
+ . target ( target ( ) )
84
89
. input ( "foo.rs" )
85
90
. out_dir ( "three-crates" )
86
91
. crate_type ( "rlib,dylib,staticlib" )
@@ -95,7 +100,7 @@ fn main() {
95
100
test_dir : "bin-crate" . to_string ( ) ,
96
101
} ,
97
102
|| {
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 ( ) ;
99
104
} ,
100
105
) ;
101
106
@@ -106,7 +111,12 @@ fn main() {
106
111
test_dir : "all-emit" . to_string ( ) ,
107
112
} ,
108
113
|| {
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 ( ) ;
110
120
} ,
111
121
) ;
112
122
@@ -117,7 +127,7 @@ fn main() {
117
127
test_dir : "asm-emit" . to_string ( ) ,
118
128
} ,
119
129
|| {
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 ( ) ;
121
131
} ,
122
132
) ;
123
133
assert_expected_output_files (
@@ -127,7 +137,7 @@ fn main() {
127
137
test_dir : "asm-emit2" . to_string ( ) ,
128
138
} ,
129
139
|| {
130
- rustc ( ) . input ( "foo.rs" ) . emit ( "asm=asm-emit2/foo" ) . run ( ) ;
140
+ rustc ( ) . target ( target ( ) ) . input ( "foo.rs" ) . emit ( "asm=asm-emit2/foo" ) . run ( ) ;
131
141
} ,
132
142
) ;
133
143
assert_expected_output_files (
@@ -137,7 +147,7 @@ fn main() {
137
147
test_dir : "asm-emit3" . to_string ( ) ,
138
148
} ,
139
149
|| {
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 ( ) ;
141
151
} ,
142
152
) ;
143
153
@@ -148,7 +158,12 @@ fn main() {
148
158
test_dir : "llvm-ir-emit" . to_string ( ) ,
149
159
} ,
150
160
|| {
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 ( ) ;
152
167
} ,
153
168
) ;
154
169
assert_expected_output_files (
@@ -158,7 +173,7 @@ fn main() {
158
173
test_dir : "llvm-ir-emit2" . to_string ( ) ,
159
174
} ,
160
175
|| {
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 ( ) ;
162
177
} ,
163
178
) ;
164
179
assert_expected_output_files (
@@ -168,7 +183,7 @@ fn main() {
168
183
test_dir : "llvm-ir-emit3" . to_string ( ) ,
169
184
} ,
170
185
|| {
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 ( ) ;
172
187
} ,
173
188
) ;
174
189
@@ -179,7 +194,12 @@ fn main() {
179
194
test_dir : "llvm-bc-emit" . to_string ( ) ,
180
195
} ,
181
196
|| {
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 ( ) ;
183
203
} ,
184
204
) ;
185
205
assert_expected_output_files (
@@ -189,7 +209,7 @@ fn main() {
189
209
test_dir : "llvm-bc-emit2" . to_string ( ) ,
190
210
} ,
191
211
|| {
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 ( ) ;
193
213
} ,
194
214
) ;
195
215
assert_expected_output_files (
@@ -199,7 +219,7 @@ fn main() {
199
219
test_dir : "llvm-bc-emit3" . to_string ( ) ,
200
220
} ,
201
221
|| {
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 ( ) ;
203
223
} ,
204
224
) ;
205
225
@@ -210,7 +230,7 @@ fn main() {
210
230
test_dir : "obj-emit" . to_string ( ) ,
211
231
} ,
212
232
|| {
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 ( ) ;
214
234
} ,
215
235
) ;
216
236
assert_expected_output_files (
@@ -220,7 +240,7 @@ fn main() {
220
240
test_dir : "obj-emit2" . to_string ( ) ,
221
241
} ,
222
242
|| {
223
- rustc ( ) . input ( "foo.rs" ) . emit ( "obj=obj-emit2/foo" ) . run ( ) ;
243
+ rustc ( ) . target ( target ( ) ) . input ( "foo.rs" ) . emit ( "obj=obj-emit2/foo" ) . run ( ) ;
224
244
} ,
225
245
) ;
226
246
assert_expected_output_files (
@@ -230,7 +250,7 @@ fn main() {
230
250
test_dir : "obj-emit3" . to_string ( ) ,
231
251
} ,
232
252
|| {
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 ( ) ;
234
254
} ,
235
255
) ;
236
256
@@ -241,7 +261,12 @@ fn main() {
241
261
test_dir : "link-emit" . to_string ( ) ,
242
262
} ,
243
263
|| {
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 ( ) ;
245
270
} ,
246
271
) ;
247
272
assert_expected_output_files (
@@ -251,7 +276,11 @@ fn main() {
251
276
test_dir : "link-emit2" . to_string ( ) ,
252
277
} ,
253
278
|| {
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 ( ) ;
255
284
} ,
256
285
) ;
257
286
assert_expected_output_files (
@@ -261,7 +290,11 @@ fn main() {
261
290
test_dir : "link-emit3" . to_string ( ) ,
262
291
} ,
263
292
|| {
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 ( ) ;
265
298
} ,
266
299
) ;
267
300
@@ -272,7 +305,7 @@ fn main() {
272
305
test_dir : "rlib" . to_string ( ) ,
273
306
} ,
274
307
|| {
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 ( ) ;
276
309
} ,
277
310
) ;
278
311
assert_expected_output_files (
@@ -282,7 +315,12 @@ fn main() {
282
315
test_dir : "rlib2" . to_string ( ) ,
283
316
} ,
284
317
|| {
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 ( ) ;
286
324
} ,
287
325
) ;
288
326
assert_expected_output_files (
@@ -292,7 +330,12 @@ fn main() {
292
330
test_dir : "rlib3" . to_string ( ) ,
293
331
} ,
294
332
|| {
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 ( ) ;
296
339
} ,
297
340
) ;
298
341
@@ -315,6 +358,7 @@ fn main() {
315
358
} ,
316
359
|| {
317
360
rustc ( )
361
+ . target ( target ( ) )
318
362
. crate_type ( "dylib" )
319
363
. input ( "foo.rs" )
320
364
. output ( "dylib/" . to_owned ( ) + & bin_foo)
@@ -340,6 +384,7 @@ fn main() {
340
384
} ,
341
385
|| {
342
386
rustc ( )
387
+ . target ( target ( ) )
343
388
. crate_type ( "dylib" )
344
389
. input ( "foo.rs" )
345
390
. emit ( & format ! ( "link=dylib2/{bin_foo}" ) )
@@ -365,6 +410,7 @@ fn main() {
365
410
} ,
366
411
|| {
367
412
rustc ( )
413
+ . target ( target ( ) )
368
414
. crate_type ( "dylib" )
369
415
. input ( "foo.rs" )
370
416
. arg ( & format ! ( "--emit=link=dylib3/{bin_foo}" ) )
@@ -379,7 +425,12 @@ fn main() {
379
425
test_dir : "staticlib" . to_string ( ) ,
380
426
} ,
381
427
|| {
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 ( ) ;
383
434
} ,
384
435
) ;
385
436
assert_expected_output_files (
@@ -389,7 +440,12 @@ fn main() {
389
440
test_dir : "staticlib2" . to_string ( ) ,
390
441
} ,
391
442
|| {
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 ( ) ;
393
449
} ,
394
450
) ;
395
451
assert_expected_output_files (
@@ -399,7 +455,12 @@ fn main() {
399
455
test_dir : "staticlib3" . to_string ( ) ,
400
456
} ,
401
457
|| {
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 ( ) ;
403
464
} ,
404
465
) ;
405
466
@@ -411,6 +472,7 @@ fn main() {
411
472
} ,
412
473
|| {
413
474
rustc ( )
475
+ . target ( target ( ) )
414
476
. crate_type ( "bin" )
415
477
. input ( "foo.rs" )
416
478
. output ( "bincrate/" . to_owned ( ) + & bin_foo)
@@ -425,6 +487,7 @@ fn main() {
425
487
} ,
426
488
|| {
427
489
rustc ( )
490
+ . target ( target ( ) )
428
491
. crate_type ( "bin" )
429
492
. input ( "foo.rs" )
430
493
. emit ( & format ! ( "link=bincrate2/{bin_foo}" ) )
@@ -439,6 +502,7 @@ fn main() {
439
502
} ,
440
503
|| {
441
504
rustc ( )
505
+ . target ( target ( ) )
442
506
. crate_type ( "bin" )
443
507
. input ( "foo.rs" )
444
508
. arg ( & format ! ( "--emit=link=bincrate3/{bin_foo}" ) )
@@ -454,6 +518,7 @@ fn main() {
454
518
} ,
455
519
|| {
456
520
rustc ( )
521
+ . target ( target ( ) )
457
522
. input ( "foo.rs" )
458
523
. emit ( "llvm-ir=rlib-ir/ir" )
459
524
. emit ( "link" )
@@ -471,6 +536,7 @@ fn main() {
471
536
} ,
472
537
|| {
473
538
rustc ( )
539
+ . target ( target ( ) )
474
540
. input ( "foo.rs" )
475
541
. emit ( "asm=staticlib-all/asm" )
476
542
. emit ( "llvm-ir=staticlib-all/ir" )
@@ -489,6 +555,7 @@ fn main() {
489
555
} ,
490
556
|| {
491
557
rustc ( )
558
+ . target ( target ( ) )
492
559
. input ( "foo.rs" )
493
560
. arg ( "--emit=asm=staticlib-all2/asm" )
494
561
. arg ( "--emit" )
@@ -510,6 +577,7 @@ fn main() {
510
577
} ,
511
578
|| {
512
579
rustc ( )
580
+ . target ( target ( ) )
513
581
. input ( "foo.rs" )
514
582
. emit ( "asm,llvm-ir,llvm-bc,obj,link" )
515
583
. crate_type ( "staticlib" )
@@ -529,6 +597,7 @@ fn main() {
529
597
|| {
530
598
rfs:: rename ( "staticlib-all3/bar.bc" , "rlib-emits/foo.bc" ) ;
531
599
rustc ( )
600
+ . target ( target ( ) )
532
601
. input ( "foo.rs" )
533
602
. emit ( "llvm-bc,link" )
534
603
. crate_type ( "rlib" )
0 commit comments