@@ -98,7 +98,7 @@ pub struct Library {
9898 pub frameworks : Vec < String > ,
9999 pub framework_paths : Vec < PathBuf > ,
100100 pub include_paths : Vec < PathBuf > ,
101- pub ld_options : Vec < String > ,
101+ pub ld_options : Vec < Vec < String > > ,
102102 pub defines : HashMap < String , Option < String > > ,
103103 pub version : String ,
104104 _priv : ( ) ,
@@ -673,24 +673,29 @@ impl Library {
673673 }
674674 }
675675
676- let mut linker_options = words
677- . iter ( )
678- . filter ( |arg| arg. starts_with ( "-Wl," ) )
679- . filter ( |arg| {
680- let option = & arg[ 4 ..] ;
681- for handled in & [ "-framework" , "-isystem" , "-iquote" , "-idirafter" ] {
682- if option. starts_with ( handled) {
683- return false ;
684- }
676+ let mut linker_options = words. iter ( ) . filter ( |arg| arg. starts_with ( "-Wl," ) ) ;
677+ while let Some ( option) = linker_options. next ( ) {
678+ let mut pop = false ;
679+ let mut ld_option = vec ! [ ] ;
680+ for subopt in option[ 4 ..] . split ( ',' ) {
681+ if pop {
682+ pop = false ;
683+ continue ;
684+ }
685+
686+ if matches ! ( subopt, "-framework" | "-isystem" | "-iquote" | "idirafter" ) {
687+ pop = true ;
688+ continue ;
685689 }
686690
687- true
688- } ) ;
691+ ld_option . push ( subopt ) ;
692+ }
689693
690- while let Some ( option) = linker_options. next ( ) {
691- let meta = format ! ( "rustc-link-arg={}" , option) ;
694+ let meta = format ! ( "rustc-link-arg=-Wl,{}" , ld_option. join( "," ) ) ;
692695 config. print_metadata ( & meta) ;
693- self . ld_options . push ( option. to_string ( ) ) ;
696+
697+ self . ld_options
698+ . push ( ld_option. into_iter ( ) . map ( String :: from) . collect ( ) ) ;
694699 }
695700 }
696701
0 commit comments