File tree Expand file tree Collapse file tree 1 file changed +15
-5
lines changed Expand file tree Collapse file tree 1 file changed +15
-5
lines changed Original file line number Diff line number Diff line change @@ -587,12 +587,22 @@ void ArgsBuilder::build(llvm::StringRef outputPath,
587
587
void ArgsBuilder::addLinker () {
588
588
llvm::StringRef linker = opts::linker;
589
589
590
- // Default to ld.bfd for Android (placing .tdata and .tbss sections adjacent
591
- // to each other as required by druntime's rt.sections_android, contrary to
592
- // gold and lld as of Android NDK r21d).
593
- if (global.params .targetTriple ->getEnvironment () == llvm::Triple::Android &&
590
+ // We have a default linker preference for Linux targets. It can be disabled
591
+ // via `-linker=` (explicitly empty).
592
+ if (global.params .targetTriple ->isOSLinux () &&
594
593
opts::linker.getNumOccurrences () == 0 ) {
595
- linker = " bfd" ;
594
+ // Default to ld.bfd for Android (placing .tdata and .tbss sections adjacent
595
+ // to each other as required by druntime's rt.sections_android, contrary to
596
+ // gold and lld as of Android NDK r21d).
597
+ if (global.params .targetTriple ->getEnvironment () == llvm::Triple::Android) {
598
+ linker = " bfd" ;
599
+ }
600
+ // Otherwise default to ld.gold for Linux due to ld.bfd issues with ThinLTO
601
+ // (see #2278) and older bfd versions stripping llvm.used symbols (e.g.,
602
+ // ModuleInfo refs) with --gc-sections (see #2870).
603
+ else {
604
+ linker = " gold" ;
605
+ }
596
606
}
597
607
598
608
if (!linker.empty ())
You can’t perform that action at this time.
0 commit comments