2
2
// see https://github.com/rust-lang/compiler-team/issues/510 for more info
3
3
4
4
//@ needs-rust-lld
5
- //@ ignore-msvc
6
5
//@ ignore-s390x lld does not yet support s390x as target
7
6
8
7
use std:: process:: Output ;
9
8
10
9
use run_make_support:: regex:: Regex ;
11
- use run_make_support:: rustc;
10
+ use run_make_support:: { is_msvc , rustc} ;
12
11
13
12
fn main ( ) {
13
+ // lld-link is used if msvc, otherwise a gnu-compatible lld is used.
14
+ let linker_version_flag = if is_msvc ( ) { "--version" } else { "-Wl,-v" } ;
15
+
14
16
// Opt-in to lld and the self-contained linker, to link with rust-lld. We'll check that by
15
17
// asking the linker to display its version number with a link-arg.
16
18
let output = rustc ( )
17
19
. env ( "RUSTC_LOG" , "rustc_codegen_ssa::back::link=info" )
18
20
. arg ( "-Zlinker-features=+lld" )
19
21
. arg ( "-Clink-self-contained=+linker" )
20
22
. arg ( "-Zunstable-options" )
21
- . link_arg ( "-Wl,-v" )
23
+ . link_arg ( linker_version_flag )
22
24
. input ( "main.rs" )
23
25
. run ( ) ;
24
26
assert ! (
@@ -27,10 +29,10 @@ fn main() {
27
29
output. stderr_utf8( )
28
30
) ;
29
31
30
- // It should not be used when we explictly opt-out of lld.
32
+ // It should not be used when we explicitly opt-out of lld.
31
33
let output = rustc ( )
32
34
. env ( "RUSTC_LOG" , "rustc_codegen_ssa::back::link=info" )
33
- . link_arg ( "-Wl,-v" )
35
+ . link_arg ( linker_version_flag )
34
36
. arg ( "-Zlinker-features=-lld" )
35
37
. input ( "main.rs" )
36
38
. run ( ) ;
@@ -44,7 +46,7 @@ fn main() {
44
46
// times to rustc.
45
47
let output = rustc ( )
46
48
. env ( "RUSTC_LOG" , "rustc_codegen_ssa::back::link=info" )
47
- . link_arg ( "-Wl,-v" )
49
+ . link_arg ( linker_version_flag )
48
50
. arg ( "-Clink-self-contained=+linker" )
49
51
. arg ( "-Zunstable-options" )
50
52
. arg ( "-Zlinker-features=-lld" )
0 commit comments