@@ -76,6 +76,25 @@ function(is_darwin_based_sdk sdk_name out_var)
76
76
endif ()
77
77
endfunction ()
78
78
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
+
79
98
# Usage:
80
99
# _add_variant_c_compile_link_flags(
81
100
# SDK sdk
@@ -871,7 +890,8 @@ function(_add_swift_library_single target name)
871
890
RESULT_VAR_NAME link_flags
872
891
)
873
892
874
- if (SWIFT_ENABLE_GOLD_LINKER )
893
+ is_elfish_sdk ("${SWIFTLIB_SINGLE_SDK} " IS_ELFISH )
894
+ if (SWIFT_ENABLE_GOLD_LINKER AND IS_ELFISH )
875
895
list (APPEND link_flags "-fuse-ld=gold" )
876
896
endif ()
877
897
@@ -1512,9 +1532,8 @@ function(_add_swift_executable_single name)
1512
1532
"-Xlinker" "@executable_path/../lib/swift/${SWIFT_SDK_${SWIFTEXE_SINGLE_SDK} _LIB_SUBDIR}" )
1513
1533
endif ()
1514
1534
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 )
1518
1537
list (APPEND link_flags "-fuse-ld=gold" )
1519
1538
endif ()
1520
1539
0 commit comments