Skip to content

Commit 1baeed7

Browse files
committed
build: allow experimental selection of lld
Add an option which the user can specify to switch to the lld linker. Although this linker is still nascent, it is interesting to permit linking with this. It is also an alternative to the BFD linker for COFF targets. It will allow for a cross-compilation story for Windows on non-Windows targets.
1 parent 1abe85a commit 1baeed7

File tree

3 files changed

+14
-0
lines changed

3 files changed

+14
-0
lines changed

CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,10 @@ set(SWIFT_COMPILER_VERSION "" CACHE STRING
110110
set(CLANG_COMPILER_VERSION "" CACHE STRING
111111
"The internal version of the Clang compiler")
112112

113+
# Indicate whether Swift should attempt to use the lld linker.
114+
set(SWIFT_ENABLE_LLD_LINKER FALSE CACHE BOOL
115+
"Enable using the lld linker when available")
116+
113117
# Indicate whether Swift should attempt to use the gold linker.
114118
# This is not used on Darwin.
115119
set(SWIFT_ENABLE_GOLD_LINKER FALSE CACHE BOOL

cmake/modules/AddSwift.cmake

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -888,6 +888,9 @@ function(_add_swift_library_single target name)
888888
"${SWIFT_SDK_${SWIFTLIB_SINGLE_SDK}_OBJECT_FORMAT}" STREQUAL "ELF")
889889
list(APPEND link_flags "-fuse-ld=gold")
890890
endif()
891+
if (SWIFT_ENABLE_LLD_LINKER)
892+
list(APPEND link_flags "-fuse-ld=lld")
893+
endif()
891894

892895
# Configure plist creation for OS X.
893896
set(PLIST_INFO_PLIST "Info.plist" CACHE STRING "Plist name")
@@ -1530,6 +1533,9 @@ function(_add_swift_executable_single name)
15301533
"${SWIFT_SDK_${SWIFTEXE_SINGLE_SDK}_OBJECT_FORMAT}" STREQUAL "ELF")
15311534
list(APPEND link_flags "-fuse-ld=gold")
15321535
endif()
1536+
if(SWIFT_ENABLE_LLD_LINKER)
1537+
list(APPEND link_flags "-fuse-ld=lld")
1538+
endif()
15331539

15341540
# Find the names of dependency library targets.
15351541
#

cmake/modules/AddSwiftUnittests.cmake

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,10 @@ function(add_swift_unittest test_dirname)
5151
set_property(TARGET "${test_dirname}" APPEND_STRING PROPERTY
5252
LINK_FLAGS " -fuse-ld=gold")
5353
endif()
54+
if(SWIFT_ENABLE_LLD_LINKER)
55+
set_property(TARGET "${test_dirname}" APPEND_STRING PROPERTY
56+
LINK_FLAGS " -fuse-ld=lld")
57+
endif()
5458
endfunction()
5559

5660

0 commit comments

Comments
 (0)