@@ -443,8 +443,9 @@ impl<'a> Linker for GccLinker<'a> {
443
443
return ;
444
444
}
445
445
446
+ let is_windows = self . sess . target . target . options . is_like_windows ;
446
447
let mut arg = OsString :: new ( ) ;
447
- let path = tmpdir. join ( "list" ) ;
448
+ let path = tmpdir. join ( if is_windows { "list.def" } else { "list" } ) ;
448
449
449
450
debug ! ( "EXPORTED SYMBOLS:" ) ;
450
451
@@ -460,6 +461,21 @@ impl<'a> Linker for GccLinker<'a> {
460
461
if let Err ( e) = res {
461
462
self . sess . fatal ( & format ! ( "failed to write lib.def file: {}" , e) ) ;
462
463
}
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
+ }
463
479
} else {
464
480
// Write an LD version script
465
481
let res: io:: Result < ( ) > = try {
@@ -493,7 +509,10 @@ impl<'a> Linker for GccLinker<'a> {
493
509
if !self . is_ld {
494
510
arg. push ( "-Wl," )
495
511
}
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
+ }
497
516
}
498
517
499
518
arg. push ( & path) ;
0 commit comments