File tree 4 files changed +63
-11
lines changed
tests/run-make/link-args-order
4 files changed +63
-11
lines changed Original file line number Diff line number Diff line change @@ -195,6 +195,24 @@ impl Rustc {
195
195
self
196
196
}
197
197
198
+ /// Add multiple extra arguments to the linker invocation, via `-Clink-args`.
199
+ pub fn link_args ( & mut self , link_args : & str ) -> & mut Self {
200
+ self . cmd . arg ( format ! ( "-Clink-args={link_args}" ) ) ;
201
+ self
202
+ }
203
+
204
+ /// Add an extra argument to prepend the linker invocation, via `-Zpre-link-arg`.
205
+ pub fn pre_link_arg ( & mut self , link_arg : & str ) -> & mut Self {
206
+ self . cmd . arg ( format ! ( "-Zpre-link-arg={link_arg}" ) ) ;
207
+ self
208
+ }
209
+
210
+ /// Add multiple extra arguments to the linker invocation, via `-Zpre-link-args`.
211
+ pub fn pre_link_args ( & mut self , link_args : & str ) -> & mut Self {
212
+ self . cmd . arg ( format ! ( "-Zpre-link-args={link_args}" ) ) ;
213
+ self
214
+ }
215
+
198
216
/// Specify a stdin input
199
217
pub fn stdin < I : AsRef < [ u8 ] > > ( & mut self , input : I ) -> & mut Self {
200
218
self . stdin = Some ( input. as_ref ( ) . to_vec ( ) . into_boxed_slice ( ) ) ;
@@ -214,6 +232,12 @@ impl Rustc {
214
232
self
215
233
}
216
234
235
+ /// Specify the linker flavor
236
+ pub fn linker_flavor ( & mut self , linker_flavor : & str ) -> & mut Self {
237
+ self . cmd . arg ( format ! ( "-Clinker-flavor={linker_flavor}" ) ) ;
238
+ self
239
+ }
240
+
217
241
/// Get the [`Output`] of the finished process.
218
242
#[ track_caller]
219
243
pub fn command_output ( & mut self ) -> Output {
Original file line number Diff line number Diff line change @@ -115,7 +115,6 @@ run-make/libtest-junit/Makefile
115
115
run-make/libtest-padding/Makefile
116
116
run-make/libtest-thread-limit/Makefile
117
117
run-make/link-arg/Makefile
118
- run-make/link-args-order/Makefile
119
118
run-make/link-cfg/Makefile
120
119
run-make/link-dedup/Makefile
121
120
run-make/link-framework/Makefile
Load Diff This file was deleted.
Original file line number Diff line number Diff line change
1
+ // Passing linker arguments to the compiler used to be lost or reordered in a messy way
2
+ // as they were passed further to the linker. This was fixed in #70665, and this test
3
+ // checks that linker arguments remain intact and in the order they were originally passed in.
4
+ // See https://github.com/rust-lang/rust/pull/70665
5
+
6
+ use run_make_support:: rustc;
7
+
8
+ fn main ( ) {
9
+ assert ! (
10
+ String :: from_utf8(
11
+ rustc( )
12
+ . input( "empty.rs" )
13
+ . linker_flavor( "ld" )
14
+ . link_arg( "a" )
15
+ . link_args( "\" b c\" " )
16
+ . link_args( "\" d e\" " )
17
+ . link_arg( "f" )
18
+ . run_fail( )
19
+ . stderr
20
+ )
21
+ . unwrap( )
22
+ . contains( "\" a\" \" b\" \" c\" \" d\" \" e\" \" f\" " )
23
+ ) ;
24
+ assert ! (
25
+ String :: from_utf8(
26
+ rustc( )
27
+ . input( "empty.rs" )
28
+ . linker_flavor( "ld" )
29
+ . pre_link_arg( "a" )
30
+ . pre_link_args( "\" b c\" " )
31
+ . pre_link_args( "\" d e\" " )
32
+ . pre_link_arg( "f" )
33
+ . run_fail( )
34
+ . stderr
35
+ )
36
+ . unwrap( )
37
+ . contains( "\" a\" \" b\" \" c\" \" d\" \" e\" \" f\" " )
38
+ ) ;
39
+ }
You can’t perform that action at this time.
0 commit comments