Skip to content

Commit 6dac8dd

Browse files
committed
build: cleanup swiftCore link definition
Colocate the target specific library specification. Inline the single site use of the place holder ICU_UC and ICU_I18N libraries rather than trying to create special library processing code for that.
1 parent 5482409 commit 6dac8dd

File tree

2 files changed

+18
-32
lines changed

2 files changed

+18
-32
lines changed

cmake/modules/AddSwift.cmake

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1861,24 +1861,7 @@ function(add_swift_target_library name)
18611861
endif()
18621862

18631863
foreach(lib ${SWIFTLIB_PRIVATE_LINK_LIBRARIES})
1864-
if("${lib}" STREQUAL "ICU_UC")
1865-
list(APPEND swiftlib_private_link_libraries_targets
1866-
"${SWIFT_${sdk}_${arch}_ICU_UC}")
1867-
# temporary fix for atomic needing to be
1868-
# after object files for libswiftCore.so
1869-
if("${sdk}" STREQUAL "ANDROID")
1870-
list(APPEND swiftlib_private_link_libraries_targets
1871-
"-latomic")
1872-
# the same issue on FreeBSD, missing symbols:
1873-
# __atomic_store, __atomic_compare_exchange, __atomic_load
1874-
elseif("${sdk}" STREQUAL "FREEBSD")
1875-
list(APPEND swiftlib_private_link_libraries_targets
1876-
"${SWIFTLIB_DIR}/clang/lib/freebsd/libclang_rt.builtins-${arch}.a")
1877-
endif()
1878-
elseif("${lib}" STREQUAL "ICU_I18N")
1879-
list(APPEND swiftlib_private_link_libraries_targets
1880-
"${SWIFT_${sdk}_${arch}_ICU_I18N}")
1881-
elseif(TARGET "${lib}${VARIANT_SUFFIX}")
1864+
if(TARGET "${lib}${VARIANT_SUFFIX}")
18821865
list(APPEND swiftlib_private_link_libraries_targets
18831866
"${lib}${VARIANT_SUFFIX}")
18841867
else()

stdlib/public/core/CMakeLists.txt

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -238,21 +238,33 @@ else()
238238
#set(LINK_FLAGS
239239
# -Wl,--whole-archive swiftRuntime -Wl,--no-whole-archive)
240240
if("${SWIFT_PATH_TO_LIBICU_BUILD}" STREQUAL "")
241-
list(APPEND swift_core_private_link_libraries ICU_UC ICU_I18N)
241+
list(APPEND swift_core_private_link_libraries
242+
${SWIFT_${SWIFT_PRIMARY_VARIANT_SDK}_${SWIFT_PRIMARY_VARIANT_ARCH}_ICU_UC}
243+
${SWIFT_${SWIFT_PRIMARY_VARIANT_SDK}_${SWIFT_PRIMARY_VARIANT_ARCH}_ICU_I18N})
242244
else()
243245
list(APPEND swift_core_private_link_libraries -licui18nswift -licuucswift -licudataswift)
244246
endif()
245247
endif()
246248

247-
if("${CMAKE_SYSTEM_NAME}" STREQUAL "CYGWIN")
249+
if(SWIFT_PRIMARY_VARIANT_SDK STREQUAL ANDROID)
250+
# workaround for libatomic needing to be after object files for swiftCore.so
251+
list(APPEND swift_core_private_link_libraries atomic)
252+
elseif(SWIFT_PRIMARY_VARIANT_SDK STREQUAL CYGWIN)
248253
# TODO(compnerd) cache this variable to permit re-configuration
249254
execute_process(COMMAND "cygpath" "-u" "$ENV{SYSTEMROOT}" OUTPUT_VARIABLE ENV_SYSTEMROOT)
250255
list(APPEND swift_core_private_link_libraries "${ENV_SYSTEMROOT}/system32/psapi.dll")
251-
endif()
252-
253-
if(SWIFT_PRIMARY_VARIANT_SDK STREQUAL FREEBSD)
256+
elseif(SWIFT_PRIMARY_VARIANT_SDK STREQUAL FREEBSD)
254257
find_library(EXECINFO_LIBRARY execinfo)
255258
list(APPEND swift_core_private_link_libraries ${EXECINFO_LIBRARY})
259+
# workaround for libatomic needing to be after object files for swiftCore.so
260+
list(APPEND swift_core_private_link_libraries
261+
${SWIFTLIB_DIR}/clang/lib/freebsd/libclang_rt.builtins-${SWIFT_PRIMARY_VARIANT_ARCH}.a)
262+
elseif(SWIFT_PRIMARY_VARIANT_SDK STREQUAL LINUX)
263+
if(SWIFT_BUILD_STATIC_STDLIB)
264+
list(APPEND swift_core_private_link_libraries swiftImageInspectionShared)
265+
endif()
266+
elseif(SWIFT_PRIMARY_VARIANT_SDK STREQUAL WINDOWS)
267+
list(APPEND swift_core_private_link_libraries shell32)
256268
endif()
257269

258270
option(SWIFT_CHECK_ESSENTIAL_STDLIB
@@ -275,15 +287,6 @@ if(SWIFT_CHECK_ESSENTIAL_STDLIB)
275287
target_link_libraries(swift_stdlib_essential ${RUNTIME_DEPENDENCY})
276288
endif()
277289

278-
279-
if(SWIFT_BUILD_STATIC_STDLIB AND "${SWIFT_PRIMARY_VARIANT_SDK}" STREQUAL "LINUX")
280-
list(APPEND swift_core_private_link_libraries swiftImageInspectionShared)
281-
endif()
282-
283-
if(SWIFT_PRIMARY_VARIANT_SDK STREQUAL WINDOWS)
284-
list(APPEND swift_core_private_link_libraries shell32)
285-
endif()
286-
287290
add_swift_target_library(swiftCore
288291
${SWIFT_STDLIB_LIBRARY_BUILD_TYPES} IS_STDLIB IS_STDLIB_CORE
289292
${SWIFTLIB_SOURCES}

0 commit comments

Comments
 (0)