@@ -443,8 +443,9 @@ impl<'a> Linker for GccLinker<'a> {
443443 return ;
444444 }
445445
446+ let is_windows = self . sess . target . target . options . is_like_windows ;
446447 let mut arg = OsString :: new ( ) ;
447- let path = tmpdir. join ( "list" ) ;
448+ let path = tmpdir. join ( if is_windows { "list.def" } else { "list" } ) ;
448449
449450 debug ! ( "EXPORTED SYMBOLS:" ) ;
450451
@@ -460,6 +461,21 @@ impl<'a> Linker for GccLinker<'a> {
460461 if let Err ( e) = res {
461462 self . sess . fatal ( & format ! ( "failed to write lib.def file: {}" , e) ) ;
462463 }
464+ } else if is_windows {
465+ let res: io:: Result < ( ) > = try {
466+ let mut f = BufWriter :: new ( File :: create ( & path) ?) ;
467+
468+ // .def file similar to MSVC one but without LIBRARY section
469+ // because LD doesn't like when it's empty
470+ writeln ! ( f, "EXPORTS" ) ?;
471+ for symbol in self . info . exports [ & crate_type] . iter ( ) {
472+ debug ! ( " _{}" , symbol) ;
473+ writeln ! ( f, " {}" , symbol) ?;
474+ }
475+ } ;
476+ if let Err ( e) = res {
477+ self . sess . fatal ( & format ! ( "failed to write list.def file: {}" , e) ) ;
478+ }
463479 } else {
464480 // Write an LD version script
465481 let res: io:: Result < ( ) > = try {
@@ -493,7 +509,10 @@ impl<'a> Linker for GccLinker<'a> {
493509 if !self . is_ld {
494510 arg. push ( "-Wl," )
495511 }
496- arg. push ( "--version-script=" ) ;
512+ // Both LD and LLD accept export list in *.def file form, there are no flags required
513+ if !is_windows {
514+ arg. push ( "--version-script=" )
515+ }
497516 }
498517
499518 arg. push ( & path) ;
0 commit comments