Skip to content

Commit f4c24d6

Browse files
authored
Merge pull request swiftlang#16403 from lanza/inspect-arch-sdk
Configure the swiftImageInspectionShared to generate arch & sdk speci…
2 parents 84298d9 + 9815368 commit f4c24d6

File tree

3 files changed

+38
-10
lines changed

3 files changed

+38
-10
lines changed

stdlib/public/core/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ endif()
252252

253253
set(shared_only_libs)
254254
if(SWIFT_BUILD_STATIC_STDLIB AND "${SWIFT_HOST_VARIANT_SDK}" STREQUAL "LINUX")
255-
list(APPEND shared_only_libs swiftImageInspectionShared)
255+
list(APPEND swift_core_private_link_libraries swiftImageInspectionShared)
256256
endif()
257257

258258
add_swift_library(swiftCore ${SWIFT_STDLIB_LIBRARY_BUILD_TYPES} IS_STDLIB IS_STDLIB_CORE

stdlib/public/runtime/CMakeLists.txt

Lines changed: 35 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -103,16 +103,39 @@ if(SWIFT_BUILD_STATIC_STDLIB AND "${sdk}" STREQUAL "LINUX")
103103
string(TOLOWER "${sdk}" lowercase_sdk)
104104

105105
# These two libraries are only used with the static swiftcore
106-
add_swift_library(swiftImageInspectionShared STATIC
106+
add_swift_library(swiftImageInspectionShared TARGET_LIBRARY STATIC
107107
ImageInspectionELF.cpp
108108
C_COMPILE_FLAGS ${swift_runtime_library_compile_flags}
109-
LINK_FLAGS ${swift_runtime_linker_flags})
110-
set_target_properties(swiftImageInspectionShared PROPERTIES
111-
ARCHIVE_OUTPUT_DIRECTORY "${SWIFTSTATICLIB_DIR}/${lowercase_sdk}")
109+
LINK_FLAGS ${swift_runtime_linker_flags}
110+
INSTALL_IN_COMPONENT stdlib)
111+
112+
foreach(arch IN LISTS SWIFT_SDK_${sdk}_ARCHITECTURES)
113+
set(FragileSupportLibrary swiftImageInspectionShared-${SWIFT_SDK_${sdk}_LIB_SUBDIR}-${arch})
114+
set(LibraryLocation ${SWIFTSTATICLIB_DIR}/${lowercase_sdk}/${arch})
115+
add_custom_command_target(swift_image_inspection_${arch}_static
116+
COMMAND
117+
"${CMAKE_COMMAND}" -E copy $<TARGET_FILE:${FragileSupportLibrary}> ${LibraryLocation}
118+
OUTPUT
119+
"${LibraryLocation}/${CMAKE_STATIC_LIBRARY_PREFIX}swiftImageInspectionShared${CMAKE_STATIC_LIBRARY_SUFFIX}"
120+
DEPENDS
121+
${FragileSupportLibrary})
122+
swift_install_in_component(stdlib
123+
FILES $<TARGET_FILE:${FragileSupportLibrary}>
124+
DESTINATION "lib/swift_static/${lowercase_sdk}/${arch}")
125+
endforeach()
112126

113-
swift_install_in_component(stdlib
114-
TARGETS swiftImageInspectionShared
115-
DESTINATION "lib/swift_static/${lowercase_sdk}")
127+
set(FragileSupportLibraryPrimary swiftImageInspectionShared-${SWIFT_SDK_${sdk}_LIB_SUBDIR}-${SWIFT_PRIMARY_VARIANT_ARCH})
128+
set(LibraryLocationPrimary ${SWIFTSTATICLIB_DIR}/${lowercase_sdk})
129+
add_custom_command_target(swift_image_inspection_static_primary_arch
130+
COMMAND
131+
"${CMAKE_COMMAND}" -E copy $<TARGET_FILE:${FragileSupportLibraryPrimary}> ${LibraryLocationPrimary}
132+
OUTPUT
133+
"${LibraryLocationPrimary}/${CMAKE_STATIC_LIBRARY_PREFIX}swiftImageInspectionShared${CMAKE_STATIC_LIBRARY_SUFFIX}"
134+
DEPENDS
135+
${FragileSupportLibraryPrimary})
136+
swift_install_in_component(stdlib
137+
FILES $<TARGET_FILE:${FragileSupportLibraryPrimary}>
138+
DESTINATION "lib/swift_static/${lowercase_sdk}")
116139

117140
# Generate the static-executable-args.lnk file used for ELF systems (eg linux)
118141
set(linkfile "${lowercase_sdk}/static-executable-args.lnk")
@@ -131,8 +154,12 @@ if(SWIFT_BUILD_STATIC_STDLIB AND "${sdk}" STREQUAL "LINUX")
131154
FILES "${SWIFTSTATICLIB_DIR}/${linkfile}"
132155
DESTINATION "lib/swift_static/${lowercase_sdk}")
133156
add_custom_target(static_binary_magic ALL DEPENDS ${static_binary_lnk_file_list})
157+
foreach(arch IN LISTS SWIFT_SDK_LINUX_ARCHITECTURES)
158+
add_dependencies(static_binary_magic ${swift_image_inspection_${arch}_static})
159+
endforeach()
160+
add_dependencies(static_binary_magic ${swift_image_inspection_static_primary_arch})
134161

135-
add_swift_library(swiftImageInspectionShared OBJECT_LIBRARY TARGET_LIBRARY
162+
add_swift_library(swiftImageInspectionSharedObject OBJECT_LIBRARY TARGET_LIBRARY
136163
ImageInspectionELF.cpp
137164
C_COMPILE_FLAGS ${swift_runtime_library_compile_flags}
138165
LINK_FLAGS ${swift_runtime_linker_flags}

unittests/runtime/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ if(("${SWIFT_HOST_VARIANT_SDK}" STREQUAL "${SWIFT_PRIMARY_VARIANT_SDK}") AND
33

44
set(swift_runtime_test_extra_libraries)
55
if(SWIFT_BUILD_STATIC_STDLIB AND "${SWIFT_HOST_VARIANT_SDK}" STREQUAL "LINUX")
6-
list(APPEND swift_runtime_test_extra_libraries swiftImageInspectionShared)
6+
list(APPEND swift_runtime_test_extra_libraries
7+
$<TARGET_FILE:swiftImageInspectionShared-${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK}_LIB_SUBDIR}-${SWIFT_HOST_VARIANT_ARCH}>)
78
endif()
89

910
add_subdirectory(LongTests)

0 commit comments

Comments
 (0)