Skip to content

Commit 058fb40

Browse files
authored
Merge pull request #3097 from compnerd/gold-is-elfish
2 parents 3a6a2da + 526127b commit 058fb40

File tree

1 file changed

+23
-4
lines changed

1 file changed

+23
-4
lines changed

cmake/modules/AddSwift.cmake

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,25 @@ function(is_darwin_based_sdk sdk_name out_var)
7676
endif()
7777
endfunction()
7878

79+
function(is_windows_based_sdk sdk_name out_var)
80+
if("${sdk_name}" STREQUAL "WINDOWS" OR
81+
"${sdk_name}" STREQUAL "CYGWIN")
82+
set(${out_var} TRUE PARENT_SCOPE)
83+
else()
84+
set(${out_var} FALSE PARENT_SCOPE)
85+
endif()
86+
endfunction()
87+
88+
function(is_elfish_sdk sdk_name out_var)
89+
is_darwin_based_sdk("${sdk_name}" IS_DARWIN)
90+
is_windows_based_sdk("${sdk_name}" IS_WINDOWS)
91+
if(IS_DARWIN OR IS_WINDOWS)
92+
set(${out_var} FALSE PARENT_SCOPE)
93+
else()
94+
set(${out_var} TRUE PARENT_SCOPE)
95+
endif()
96+
endfunction()
97+
7998
# Usage:
8099
# _add_variant_c_compile_link_flags(
81100
# SDK sdk
@@ -871,7 +890,8 @@ function(_add_swift_library_single target name)
871890
RESULT_VAR_NAME link_flags
872891
)
873892

874-
if(SWIFT_ENABLE_GOLD_LINKER)
893+
is_elfish_sdk("${SWIFTLIB_SINGLE_SDK}" IS_ELFISH)
894+
if(SWIFT_ENABLE_GOLD_LINKER AND IS_ELFISH)
875895
list(APPEND link_flags "-fuse-ld=gold")
876896
endif()
877897

@@ -1512,9 +1532,8 @@ function(_add_swift_executable_single name)
15121532
"-Xlinker" "@executable_path/../lib/swift/${SWIFT_SDK_${SWIFTEXE_SINGLE_SDK}_LIB_SUBDIR}")
15131533
endif()
15141534

1515-
if(SWIFT_ENABLE_GOLD_LINKER AND
1516-
( "${SWIFTEXE_SINGLE_SDK}" STREQUAL "LINUX" ) )
1517-
# Extend the link_flags for the gold linker.
1535+
is_elfish_sdk("${SWIFTLIB_SINGLE_SDK}" IS_ELFISH)
1536+
if(SWIFT_ENABLE_GOLD_LINKER AND IS_ELFISH)
15181537
list(APPEND link_flags "-fuse-ld=gold")
15191538
endif()
15201539

0 commit comments

Comments
 (0)