Skip to content

Commit d14bb1e

Browse files
committed
Driver: sink the static-stdlib-args.lnk generation
This moves the standard library response file into the standard library generation rather than in the driver. Although the driver consumes this file, it is part of the standard library as it knows its dependencies. This removes the last of the ICU references in the toolchain.
1 parent ced7dc1 commit d14bb1e

File tree

2 files changed

+34
-39
lines changed

2 files changed

+34
-39
lines changed

lib/Driver/CMakeLists.txt

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -26,42 +26,3 @@ target_link_libraries(swiftDriver PRIVATE
2626
swiftAST
2727
swiftBasic
2828
swiftOption)
29-
30-
# Generate the static-stdlib-args.lnk file used by -static-stdlib option
31-
# for 'GenericUnix' (eg linux)
32-
if(SWIFT_BUILD_STATIC_STDLIB)
33-
set(static_stdlib_lnk_file_list)
34-
foreach(sdk ${SWIFT_CONFIGURED_SDKS})
35-
if("${SWIFT_SDK_${sdk}_OBJECT_FORMAT}" STREQUAL "ELF")
36-
string(TOLOWER "${sdk}" lowercase_sdk)
37-
if(SWIFT_${SWIFT_HOST_VARIANT_SDK}_${SWIFT_HOST_VARIANT_ARCH}_ICU_STATICLIB)
38-
set(ICU_STATICLIB "TRUE")
39-
else()
40-
set(ICU_STATICLIB "FALSE")
41-
find_package(ICU REQUIRED COMPONENTS uc i18n)
42-
get_filename_component(ICU_UC_LIBDIR "${ICU_UC_LIBRARIES}" DIRECTORY)
43-
get_filename_component(ICU_I18N_LIBDIR "${ICU_I18N_LIBRARIES}" DIRECTORY)
44-
endif()
45-
set(linkfile "${lowercase_sdk}/static-stdlib-args.lnk")
46-
add_custom_command_target(swift_static_stdlib_${sdk}_args
47-
COMMAND
48-
"${SWIFT_SOURCE_DIR}/utils/gen-static-stdlib-link-args"
49-
"${sdk}"
50-
"${SWIFTSTATICLIB_DIR}/${linkfile}"
51-
"${ICU_STATICLIB}"
52-
"${ICU_UC_LIBDIR}"
53-
"${ICU_I18N_LIBDIR}"
54-
OUTPUT
55-
"${SWIFTSTATICLIB_DIR}/${linkfile}"
56-
DEPENDS
57-
"${SWIFT_SOURCE_DIR}/utils/gen-static-stdlib-link-args")
58-
59-
list(APPEND static_stdlib_lnk_file_list ${swift_static_stdlib_${sdk}_args})
60-
swift_install_in_component(FILES "${SWIFTSTATICLIB_DIR}/${linkfile}"
61-
DESTINATION "lib/swift_static/${lowercase_sdk}"
62-
COMPONENT stdlib)
63-
endif()
64-
endforeach()
65-
add_custom_target(swift_static_lnk_args ALL DEPENDS ${static_stdlib_lnk_file_list})
66-
add_dependencies(stdlib swift_static_lnk_args)
67-
endif()

stdlib/public/runtime/CMakeLists.txt

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,40 @@ foreach(sdk ${SWIFT_CONFIGURED_SDKS})
263263
${swiftImageRegistration-${arch_suffix}})
264264
add_dependencies(stdlib swift-stdlib-${arch_suffix} swiftImageRegistration-${arch_suffix})
265265
endif()
266+
267+
# Generate the static-stdlib-args.lnk file used by -static-stdlib option for
268+
# 'GenericUnix' (eg linux)
269+
if(${SWIFT_SDK_${sdk}_OBJECT_FORMAT} STREQUAL ELF)
270+
string(TOLOWER "${sdk}" lowercase_sdk)
271+
if(SWIFT_${SWIFT_HOST_VARIANT_SDK}_${SWIFT_HOST_VARIANT_ARCH}_ICU_STATICLIB)
272+
set(ICU_STATICLIB "TRUE")
273+
else()
274+
set(ICU_STATICLIB "FALSE")
275+
find_package(ICU REQUIRED COMPONENTS uc i18n)
276+
get_filename_component(ICU_UC_LIBDIR "${ICU_UC_LIBRARIES}" DIRECTORY)
277+
get_filename_component(ICU_I18N_LIBDIR "${ICU_I18N_LIBRARIES}" DIRECTORY)
278+
endif()
279+
set(linkfile "${lowercase_sdk}/static-stdlib-args.lnk")
280+
add_custom_command_target(swift_static_stdlib_${sdk}_args
281+
COMMAND
282+
"${SWIFT_SOURCE_DIR}/utils/gen-static-stdlib-link-args"
283+
"${sdk}"
284+
"${SWIFTSTATICLIB_DIR}/${linkfile}"
285+
"${ICU_STATICLIB}"
286+
"${ICU_UC_LIBDIR}"
287+
"${ICU_I18N_LIBDIR}"
288+
OUTPUT
289+
"${SWIFTSTATICLIB_DIR}/${linkfile}"
290+
DEPENDS
291+
"${SWIFT_SOURCE_DIR}/utils/gen-static-stdlib-link-args")
292+
293+
list(APPEND static_stdlib_lnk_file_list ${swift_static_stdlib_${sdk}_args})
294+
swift_install_in_component(FILES "${SWIFTSTATICLIB_DIR}/${linkfile}"
295+
DESTINATION "lib/swift_static/${lowercase_sdk}"
296+
COMPONENT stdlib)
297+
endif()
266298
endforeach()
267299
endforeach()
300+
add_custom_target(swift_static_lnk_args ALL DEPENDS ${static_stdlib_lnk_file_list})
301+
add_dependencies(stdlib swift_static_lnk_args)
268302

0 commit comments

Comments
 (0)