22// see https://github.com/rust-lang/compiler-team/issues/510 for more info
33
44//@ needs-rust-lld
5- //@ ignore-msvc
65//@ ignore-s390x lld does not yet support s390x as target
76
87use std:: process:: Output ;
98
109use run_make_support:: regex:: Regex ;
11- use run_make_support:: rustc;
10+ use run_make_support:: { is_msvc , rustc} ;
1211
1312fn 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+
1416 // Opt-in to lld and the self-contained linker, to link with rust-lld. We'll check that by
1517 // asking the linker to display its version number with a link-arg.
1618 let output = rustc ( )
1719 . env ( "RUSTC_LOG" , "rustc_codegen_ssa::back::link=info" )
1820 . arg ( "-Zlinker-features=+lld" )
1921 . arg ( "-Clink-self-contained=+linker" )
2022 . arg ( "-Zunstable-options" )
21- . link_arg ( "-Wl,-v" )
23+ . link_arg ( linker_version_flag )
2224 . input ( "main.rs" )
2325 . run ( ) ;
2426 assert ! (
@@ -27,10 +29,10 @@ fn main() {
2729 output. stderr_utf8( )
2830 ) ;
2931
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.
3133 let output = rustc ( )
3234 . env ( "RUSTC_LOG" , "rustc_codegen_ssa::back::link=info" )
33- . link_arg ( "-Wl,-v" )
35+ . link_arg ( linker_version_flag )
3436 . arg ( "-Zlinker-features=-lld" )
3537 . input ( "main.rs" )
3638 . run ( ) ;
@@ -44,7 +46,7 @@ fn main() {
4446 // times to rustc.
4547 let output = rustc ( )
4648 . env ( "RUSTC_LOG" , "rustc_codegen_ssa::back::link=info" )
47- . link_arg ( "-Wl,-v" )
49+ . link_arg ( linker_version_flag )
4850 . arg ( "-Clink-self-contained=+linker" )
4951 . arg ( "-Zunstable-options" )
5052 . arg ( "-Zlinker-features=-lld" )
0 commit comments