File tree Expand file tree Collapse file tree 4 files changed +63
-11
lines changed
tests/run-make/link-args-order Expand file tree Collapse file tree 4 files changed +63
-11
lines changed Original file line number Diff line number Diff line change @@ -193,6 +193,24 @@ impl Rustc {
193193 self
194194 }
195195
196+ /// Add multiple extra arguments to the linker invocation, via `-Clink-args`.
197+ pub fn link_args ( & mut self , link_args : & str ) -> & mut Self {
198+ self . cmd . arg ( format ! ( "-Clink-args={link_args}" ) ) ;
199+ self
200+ }
201+
202+ /// Add an extra argument to prepend the linker invocation, via `-Zpre-link-arg`.
203+ pub fn pre_link_arg ( & mut self , link_arg : & str ) -> & mut Self {
204+ self . cmd . arg ( format ! ( "-Zpre-link-arg={link_arg}" ) ) ;
205+ self
206+ }
207+
208+ /// Add multiple extra arguments to the linker invocation, via `-Zpre-link-args`.
209+ pub fn pre_link_args ( & mut self , link_args : & str ) -> & mut Self {
210+ self . cmd . arg ( format ! ( "-Zpre-link-args={link_args}" ) ) ;
211+ self
212+ }
213+
196214 /// Specify a stdin input
197215 pub fn stdin < I : AsRef < [ u8 ] > > ( & mut self , input : I ) -> & mut Self {
198216 self . cmd . set_stdin ( input. as_ref ( ) . to_vec ( ) . into_boxed_slice ( ) ) ;
@@ -211,4 +229,10 @@ impl Rustc {
211229 self . cmd . arg ( format ! ( "-Clinker={linker}" ) ) ;
212230 self
213231 }
232+
233+ /// Specify the linker flavor
234+ pub fn linker_flavor ( & mut self , linker_flavor : & str ) -> & mut Self {
235+ self . cmd . arg ( format ! ( "-Clinker-flavor={linker_flavor}" ) ) ;
236+ self
237+ }
214238}
Original file line number Diff line number Diff line change @@ -115,7 +115,6 @@ run-make/libtest-junit/Makefile
115115run-make/libtest-padding/Makefile
116116run-make/libtest-thread-limit/Makefile
117117run-make/link-arg/Makefile
118- run-make/link-args-order/Makefile
119118run-make/link-cfg/Makefile
120119run-make/link-dedup/Makefile
121120run-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