Skip to content

Commit 61e0b2b

Browse files
mati865mstorsjo
authored andcommitted
[LLD] Allow configuring default ld.lld backend
The motivation for this is ld.lld --help targeting MinGW which currently prints help for the ELF backend unless -m i386pe{,p} is added. This confuses build systems that grep through linker help to find supported flags. This matches LD from Binutils which always prints help for MinGW when configured to target it. After this change, the backend can still be overridden to any supported ELF/MinGW target by using correct -m <arch>. Differential Revision: https://reviews.llvm.org/D87418
1 parent 7b416c5 commit 61e0b2b

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

lld/CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,12 @@ endif()
174174
option(LLD_BUILD_TOOLS
175175
"Build the lld tools. If OFF, just generate build targets." ON)
176176

177+
option(LLD_DEFAULT_LD_LLD_IS_MINGW
178+
"Use MinGW as the default backend for ld.lld. If OFF, ELF will be used." OFF)
179+
if (LLD_DEFAULT_LD_LLD_IS_MINGW)
180+
add_definitions("-DLLD_DEFAULT_LD_LLD_IS_MINGW=1")
181+
endif()
182+
177183
if (MSVC)
178184
add_definitions(-wd4530) # Suppress 'warning C4530: C++ exception handler used, but unwind semantics are not enabled.'
179185
add_definitions(-wd4062) # Suppress 'warning C4062: enumerator X in switch of enum Y is not handled' from system header.

lld/tools/lld/lld.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,12 @@ static bool isPETarget(std::vector<const char *> &v) {
9292
continue;
9393
return isPETargetName(*(it + 1));
9494
}
95+
96+
#ifdef LLD_DEFAULT_LD_LLD_IS_MINGW
97+
return true;
98+
#else
9599
return false;
100+
#endif
96101
}
97102

98103
static Flavor parseProgname(StringRef progname) {

0 commit comments

Comments
 (0)