Skip to content

Add -linker command-line option#2386

Merged
kinke merged 1 commit intoldc-developers:masterfrom
kinke:mslink
Oct 27, 2017
Merged

Add -linker command-line option#2386
kinke merged 1 commit intoldc-developers:masterfrom
kinke:mslink

Conversation

@kinke
Copy link
Member

@kinke kinke commented Oct 25, 2017

Needed for LTO via external lld-link.exe (v5.0+).

@kinke
Copy link
Member Author

kinke commented Oct 25, 2017

We quickly hit an LLVM 5.0 unreachable() when trying to compile druntime (or Phobos) with -flto=full on Windows:

this directive only supported on COFF targets
UNREACHABLE executed at C:\LDC\llvm\lib\MC\MCStreamer.cpp:811!
#4 0x00007ff6dcded49d llvm::MCStreamer::BeginCOFFSymbolDef(class llvm::MCSymbol const *) c:\ldc\llvm\lib\mc\mcstreamer.cpp:811:0
#5 0x00007ff6dcd96f36 `anonymous namespace'::COFFAsmParser::ParseDirectiveDef c:\ldc\llvm\lib\mc\mcparser\coffasmparser.cpp:428:0
#6 0x00007ff6dcd961d6 llvm::MCAsmParserExtension::HandleDirective<class `anonymous namespace'::COFFAsmParser,&A0x2504f220::COFFAsmParser::ParseDirectiveDef(class llvm::StringRef,class llvm::SMLoc)>(class llvm::MCAsmParserExtension *,class llvm::StringRef,class llvm::SMLoc) c:\ldc\llvm\include\llvm\mc\mcparser\mcasmparserextension.h:39:0
#7 0x00007ff6dcd87713 `anonymous namespace'::AsmParser::parseStatement c:\ldc\llvm\lib\mc\mcparser\asmparser.cpp:1763:0
#8 0x00007ff6dcd73e49 `anonymous namespace'::AsmParser::Run c:\ldc\llvm\lib\mc\mcparser\asmparser.cpp:764:0
#9 0x00007ff6dcbd46a0 llvm::ModuleSymbolTable::CollectAsmSymbols(class llvm::Module const &,class llvm::function_ref<void (class llvm::StringRef,enum llvm::object::BasicSymbolRef::Flags)>) c:\ldc\llvm\lib\object\modulesymboltable.cpp:195:0
#10 0x00007ff6dcbd5240 llvm::ModuleSymbolTable::addModule(class llvm::Module *) c:\ldc\llvm\lib\object\modulesymboltable.cpp:70:0
#11 0x00007ff6dcbd706c `anonymous namespace'::Builder::addModule c:\ldc\llvm\lib\object\irsymtab.cpp:120:0
#12 0x00007ff6dcbd7fc0 `anonymous namespace'::Builder::build c:\ldc\llvm\lib\object\irsymtab.cpp:257:0
#13 0x00007ff6dcbd83ad llvm::irsymtab::build(class llvm::ArrayRef<class llvm::Module *>,class llvm::SmallVector<char,0> &,class llvm::StringTableBuilder &,class llvm::BumpPtrAllocatorImpl<class llvm::MallocAllocator,4096,4096> &) c:\ldc\llvm\lib\object\irsymtab.cpp:280:0
#14 0x00007ff6dca157ee llvm::BitcodeWriter::writeSymtab(void) c:\ldc\llvm\lib\bitcode\writer\bitcodewriter.cpp:3875:0
#15 0x00007ff6dc9fea9b llvm::WriteBitcodeToFile(class llvm::Module const *,class llvm::raw_ostream &,bool,class llvm::ModuleSummaryIndex const *,bool,class std::array<unsigned int,5> *) c:\ldc\llvm\lib\bitcode\writer\bitcodewriter.cpp:3949:0
#16 0x00007ff6dba6017f writeModule(class llvm::Module *,char const *) c:\ldc\ldc\driver\toobj.cpp:381:0

@JohanEngelen
Copy link
Member

could this option be generalized to set the linker for any target?
(can be useful for e.g. choosing between ld.bfd and ld.gold, or for cross compiling stuff?)

@kinke
Copy link
Member Author

kinke commented Oct 26, 2017

Good idea, using it as -fuse-ld=... arg for the other targets' gcc command line. So it'll be -linker=<lld-link|gold|bfd|lld> etc.

To set the linker executable for MSVC targets (e.g., `lld-link`) or the
`-fuse-ld` arg for the gcc linking command-line for the other targets.
@kinke kinke changed the title Add -mslink command-line option to set linker for MSVC targets Add -linker command-line option Oct 26, 2017
@kinke
Copy link
Member Author

kinke commented Oct 26, 2017

Implemented.

Copy link
Contributor

@PetarKirov PetarKirov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.

@kinke kinke merged commit aeaf35c into ldc-developers:master Oct 27, 2017
@kinke kinke deleted the mslink branch October 27, 2017 23:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants