diff --git a/lld/CMakeLists.txt b/lld/CMakeLists.txt --- a/lld/CMakeLists.txt +++ b/lld/CMakeLists.txt @@ -193,6 +193,15 @@ option(LLD_BUILD_TOOLS "Build the lld tools. If OFF, just generate build targets." ON) +set(LLD_DEFAULT_LD_LLD_BACKEND "ELF" + CACHE STRING "Default backend for ld.lld, can be either ELF (default) or MINGW") +string(TOUPPER "${LLD_DEFAULT_LD_LLD_BACKEND}" uppercase_LLD_DEFAULT_LD_LLD_BACKEND) +if (uppercase_LLD_DEFAULT_LD_LLD_BACKEND MATCHES "^ELF$|^MINGW$") + add_definitions("-DLLD_DEFAULT_LD_LLD_BACKEND=\"${uppercase_LLD_DEFAULT_LD_LLD_BACKEND}\"") +else() + message(FATAL_ERROR "LLD_DEFAULT_LD_LLD_BACKEND can only be either ELF or MINGW") +endif() + if (MSVC) add_definitions(-wd4530) # Suppress 'warning C4530: C++ exception handler used, but unwind semantics are not enabled.' add_definitions(-wd4062) # Suppress 'warning C4062: enumerator X in switch of enum Y is not handled' from system header. diff --git a/lld/tools/lld/lld.cpp b/lld/tools/lld/lld.cpp --- a/lld/tools/lld/lld.cpp +++ b/lld/tools/lld/lld.cpp @@ -92,7 +92,8 @@ continue; return isPETargetName(*(it + 1)); } - return false; + + return strcmp(LLD_DEFAULT_LD_LLD_BACKEND, "MINGW") ? false : true; } static Flavor parseProgname(StringRef progname) {