File tree Expand file tree Collapse file tree 2 files changed +18
-14
lines changed Expand file tree Collapse file tree 2 files changed +18
-14
lines changed Original file line number Diff line number Diff line change @@ -148,12 +148,22 @@ set(CLANG_COMPILER_VERSION "" CACHE STRING
148
148
"The internal version of the Clang compiler" )
149
149
150
150
# Indicate whether Swift should attempt to use the lld linker.
151
- set (SWIFT_ENABLE_LLD_LINKER TRUE CACHE BOOL
151
+ if (CMAKE_SYSTEM_NAME STREQUAL Windows AND NOT CMAKE_HOST_SYSTEM_NAME STREQUAL Windows )
152
+ set (SWIFT_ENABLE_LLD_LINKER_default TRUE )
153
+ else ()
154
+ set (SWIFT_ENABLE_LLD_LINKER_default FALSE )
155
+ endif ()
156
+ set (SWIFT_ENABLE_LLD_LINKER ${SWIFT_ENABLE_LLD_LINKER_default} CACHE BOOL
152
157
"Enable using the lld linker when available" )
153
158
154
159
# Indicate whether Swift should attempt to use the gold linker.
155
160
# This is not used on Darwin.
156
- set (SWIFT_ENABLE_GOLD_LINKER TRUE CACHE BOOL
161
+ if (CMAKE_SYSTEM_NAME STREQUAL Darwin OR CMAKE_SYSTEM_NAME STREQUAL Windows )
162
+ set (SWIFT_ENABLE_GOLD_LINKER_default FALSE )
163
+ else ()
164
+ set (SWIFT_ENABLE_GOLD_LINKER_default TRUE )
165
+ endif ()
166
+ set (SWIFT_ENABLE_GOLD_LINKER ${SWIFT_ENABLE_GOLD_LINKER_default} CACHE BOOL
157
167
"Enable using the gold linker when available" )
158
168
159
169
set (SWIFT_TOOLS_ENABLE_LTO OFF CACHE STRING "Build Swift tools with LTO. One
Original file line number Diff line number Diff line change @@ -368,18 +368,12 @@ function(_add_host_variant_link_flags target)
368
368
endif ()
369
369
370
370
if (NOT SWIFT_COMPILER_IS_MSVC_LIKE )
371
- # FIXME: On Apple platforms, find_program needs to look for "ld64.lld"
372
- find_program (LDLLD_PATH "ld.lld" )
373
- if ((SWIFT_ENABLE_LLD_LINKER AND LDLLD_PATH AND NOT APPLE ) OR
374
- (SWIFT_HOST_VARIANT_SDK STREQUAL WINDOWS AND NOT CMAKE_SYSTEM_NAME STREQUAL WINDOWS ))
375
- target_link_options (${target} PRIVATE -fuse-ld=lld )
376
- elseif (SWIFT_ENABLE_GOLD_LINKER AND
377
- "${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK} _OBJECT_FORMAT}" STREQUAL "ELF" )
378
- if (CMAKE_HOST_SYSTEM_NAME STREQUAL Windows )
379
- target_link_options (${target} PRIVATE -fuse-ld=gold.exe )
380
- else ()
381
- target_link_options (${target} PRIVATE -fuse-ld=gold )
382
- endif ()
371
+ if (SWIFT_ENABLE_LLD_LINKER )
372
+ target_link_options (${target} PRIVATE
373
+ -fuse-ld=lld$<$<STREQUAL:${CMAKE_HOST_SYSTEM_NAME},Windows>:.exe> )
374
+ elseif (SWIFT_ENABLE_GOLD_LINKER )
375
+ target_link_options (${target} PRIVATE
376
+ -fuse-ld=gold$<$<STREQUAL:${CMAKE_HOST_SYSTEM_NAME},Windows>:.exe> )
383
377
endif ()
384
378
endif ()
385
379
You can’t perform that action at this time.
0 commit comments