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.
|
# LLVM flags into account.
|
||||||
set(LDC_LINKERFLAG_LIST ${SANITIZE_LDFLAGS} ${LLVM_LIBRARIES} ${LLVM_LDFLAGS})
|
set(LDC_LINKERFLAG_LIST ${SANITIZE_LDFLAGS} ${LLVM_LIBRARIES} ${LLVM_LDFLAGS})
|
||||||
if(LDC_WITH_LLD)
|
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(NOT (LDC_LLVM_VER LESS 600))
|
||||||
if(MSVC)
|
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()
|
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()
|
endif()
|
||||||
if(APPLE) # bug, should be fixed in LLVM 6.0.1
|
if(APPLE) # bug, should be fixed in LLVM 6.0.1
|
||||||
list(APPEND LDC_LINKERFLAG_LIST -lxml2)
|
list(APPEND LDC_LINKERFLAG_LIST -lxml2)
|
||||||
|
|
|
@ -656,7 +656,7 @@ int linkObjToBinaryGcc(llvm::StringRef outputPath,
|
||||||
argsBuilder.build(outputPath, defaultLibNames);
|
argsBuilder.build(outputPath, defaultLibNames);
|
||||||
|
|
||||||
const auto fullArgs =
|
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.
|
// CanExitEarly == true means that LLD can and will call `exit()` when errors occur.
|
||||||
const bool CanExitEarly = false;
|
const bool CanExitEarly = false;
|
||||||
|
@ -670,6 +670,10 @@ int linkObjToBinaryGcc(llvm::StringRef outputPath,
|
||||||
#else
|
#else
|
||||||
success = lld::mach_o::link(fullArgs);
|
success = lld::mach_o::link(fullArgs);
|
||||||
#endif
|
#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 {
|
} else {
|
||||||
error(Loc(), "unknown target binary format for internal linking");
|
error(Loc(), "unknown target binary format for internal linking");
|
||||||
}
|
}
|
||||||
|
|
|
@ -88,6 +88,9 @@ static std::string getOutputName() {
|
||||||
extension = global.dll_ext;
|
extension = global.dll_ext;
|
||||||
} else if (triple.isOSWindows()) {
|
} else if (triple.isOSWindows()) {
|
||||||
extension = "exe";
|
extension = "exe";
|
||||||
|
} else if (triple.getArch() == llvm::Triple::wasm32 ||
|
||||||
|
triple.getArch() == llvm::Triple::wasm64) {
|
||||||
|
extension = "wasm";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (global.params.exefile) {
|
if (global.params.exefile) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue