mirror of
https://github.com/ldc-developers/ldc.git
synced 2025-05-13 14:36:18 +03:00
Add -link-internally support for MinGW and WebAssembly targets
This commit is contained in:
parent
631e29b761
commit
27e4ac0304
3 changed files with 11 additions and 4 deletions
|
@ -578,12 +578,12 @@ add_custom_target(${LDMD_EXE} ALL DEPENDS ${LDMD_EXE_FULL})
|
|||
# LLVM flags into account.
|
||||
set(LDC_LINKERFLAG_LIST ${SANITIZE_LDFLAGS} ${LLVM_LIBRARIES} ${LLVM_LDFLAGS})
|
||||
if(LDC_WITH_LLD)
|
||||
# ELF and Mach-O formats supported since LLD 6.0.0, otherwise just Windows COFF
|
||||
# ELF, Mach-O, MinGW and WebAssembly formats supported since LLD 6.0.0, otherwise just Windows COFF
|
||||
if(NOT (LDC_LLVM_VER LESS 600))
|
||||
if(MSVC)
|
||||
list(APPEND LDC_LINKERFLAG_LIST lldDriver.lib lldCOFF.lib lldELF.lib lldMachO.lib lldYAML.lib lldReaderWriter.lib lldCommon.lib lldCore.lib)
|
||||
list(APPEND LDC_LINKERFLAG_LIST lldDriver.lib lldMinGW.lib lldCOFF.lib lldELF.lib lldMachO.lib lldWasm.lib lldYAML.lib lldReaderWriter.lib lldCommon.lib lldCore.lib)
|
||||
else()
|
||||
set(LDC_LINKERFLAG_LIST -llldDriver -llldCOFF -llldELF -llldMachO -llldYAML -llldReaderWriter -llldCommon -llldCore ${LDC_LINKERFLAG_LIST})
|
||||
set(LDC_LINKERFLAG_LIST -llldDriver -llldMinGW -llldCOFF -llldELF -llldMachO -llldWasm -llldYAML -llldReaderWriter -llldCommon -llldCore ${LDC_LINKERFLAG_LIST})
|
||||
endif()
|
||||
if(APPLE) # bug, should be fixed in LLVM 6.0.1
|
||||
list(APPEND LDC_LINKERFLAG_LIST -lxml2)
|
||||
|
|
|
@ -656,7 +656,7 @@ int linkObjToBinaryGcc(llvm::StringRef outputPath,
|
|||
argsBuilder.build(outputPath, defaultLibNames);
|
||||
|
||||
const auto fullArgs =
|
||||
getFullArgs("ld.lld", argsBuilder.args, global.params.verbose);
|
||||
getFullArgs("lld", argsBuilder.args, global.params.verbose);
|
||||
|
||||
// CanExitEarly == true means that LLD can and will call `exit()` when errors occur.
|
||||
const bool CanExitEarly = false;
|
||||
|
@ -670,6 +670,10 @@ int linkObjToBinaryGcc(llvm::StringRef outputPath,
|
|||
#else
|
||||
success = lld::mach_o::link(fullArgs);
|
||||
#endif
|
||||
} else if (global.params.targetTriple->isOSBinFormatCOFF()) {
|
||||
success = lld::mingw::link(fullArgs);
|
||||
} else if (global.params.targetTriple->isOSBinFormatWasm()) {
|
||||
success = lld::wasm::link(fullArgs, CanExitEarly);
|
||||
} else {
|
||||
error(Loc(), "unknown target binary format for internal linking");
|
||||
}
|
||||
|
|
|
@ -88,6 +88,9 @@ static std::string getOutputName() {
|
|||
extension = global.dll_ext;
|
||||
} else if (triple.isOSWindows()) {
|
||||
extension = "exe";
|
||||
} else if (triple.getArch() == llvm::Triple::wasm32 ||
|
||||
triple.getArch() == llvm::Triple::wasm64) {
|
||||
extension = "wasm";
|
||||
}
|
||||
|
||||
if (global.params.exefile) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue