Skip to content

Configure the swiftImageInspectionShared to generate arch & sdk specific directories #16191

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion stdlib/public/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ endif()

set(shared_only_libs)
if(SWIFT_BUILD_STATIC_STDLIB AND "${SWIFT_HOST_VARIANT_SDK}" STREQUAL "LINUX")
list(APPEND shared_only_libs swiftImageInspectionShared)
list(APPEND swift_core_private_link_libraries swiftImageInspectionShared)
endif()

add_swift_library(swiftCore ${SWIFT_STDLIB_LIBRARY_BUILD_TYPES} IS_STDLIB IS_STDLIB_CORE
Expand Down
43 changes: 35 additions & 8 deletions stdlib/public/runtime/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -103,16 +103,39 @@ if(SWIFT_BUILD_STATIC_STDLIB AND "${sdk}" STREQUAL "LINUX")
string(TOLOWER "${sdk}" lowercase_sdk)

# These two libraries are only used with the static swiftcore
add_swift_library(swiftImageInspectionShared STATIC
add_swift_library(swiftImageInspectionShared TARGET_LIBRARY STATIC
ImageInspectionELF.cpp
C_COMPILE_FLAGS ${swift_runtime_library_compile_flags}
LINK_FLAGS ${swift_runtime_linker_flags})
set_target_properties(swiftImageInspectionShared PROPERTIES
ARCHIVE_OUTPUT_DIRECTORY "${SWIFTSTATICLIB_DIR}/${lowercase_sdk}")
LINK_FLAGS ${swift_runtime_linker_flags}
INSTALL_IN_COMPONENT stdlib)

foreach(arch IN LISTS SWIFT_SDK_${sdk}_ARCHITECTURES)
set(FragileSupportLibrary swiftImageInspectionShared-${SWIFT_SDK_${sdk}_LIB_SUBDIR}-${arch})
set(LibraryLocation ${SWIFTSTATICLIB_DIR}/${lowercase_sdk}/${arch})
add_custom_command_target(swift_image_inspection_${arch}_static
COMMAND
"${CMAKE_COMMAND}" -E copy $<TARGET_FILE:${FragileSupportLibrary}> ${LibraryLocation}
OUTPUT
"${LibraryLocation}/${CMAKE_STATIC_LIBRARY_PREFIX}swiftImageInspectionShared${CMAKE_STATIC_LIBRARY_SUFFIX}"
DEPENDS
${FragileSupportLibrary})
swift_install_in_component(stdlib
FILES $<TARGET_FILE:${FragileSupportLibrary}>
DESTINATION "lib/swift_static/${lowercase_sdk}/${arch}")
endforeach()

swift_install_in_component(stdlib
TARGETS swiftImageInspectionShared
DESTINATION "lib/swift_static/${lowercase_sdk}")
set(FragileSupportLibraryPrimary swiftImageInspectionShared-${SWIFT_SDK_${sdk}_LIB_SUBDIR}-${SWIFT_PRIMARY_VARIANT_ARCH})
set(LibraryLocationPrimary ${SWIFTSTATICLIB_DIR}/${lowercase_sdk})
add_custom_command_target(swift_image_inspection_static_primary_arch
COMMAND
"${CMAKE_COMMAND}" -E copy $<TARGET_FILE:${FragileSupportLibraryPrimary}> ${LibraryLocationPrimary}
OUTPUT
"${LibraryLocationPrimary}/${CMAKE_STATIC_LIBRARY_PREFIX}swiftImageInspectionShared${CMAKE_STATIC_LIBRARY_SUFFIX}"
DEPENDS
${FragileSupportLibraryPrimary})
swift_install_in_component(stdlib
FILES $<TARGET_FILE:${FragileSupportLibraryPrimary}>
DESTINATION "lib/swift_static/${lowercase_sdk}")

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

add_swift_library(swiftImageInspectionShared OBJECT_LIBRARY TARGET_LIBRARY
add_swift_library(swiftImageInspectionSharedObject OBJECT_LIBRARY TARGET_LIBRARY
ImageInspectionELF.cpp
C_COMPILE_FLAGS ${swift_runtime_library_compile_flags}
LINK_FLAGS ${swift_runtime_linker_flags}
Expand Down
3 changes: 2 additions & 1 deletion unittests/runtime/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ if(("${SWIFT_HOST_VARIANT_SDK}" STREQUAL "${SWIFT_PRIMARY_VARIANT_SDK}") AND

set(swift_runtime_test_extra_libraries)
if(SWIFT_BUILD_STATIC_STDLIB AND "${SWIFT_HOST_VARIANT_SDK}" STREQUAL "LINUX")
list(APPEND swift_runtime_test_extra_libraries swiftImageInspectionShared)
list(APPEND swift_runtime_test_extra_libraries
$<TARGET_FILE:swiftImageInspectionShared-${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK}_LIB_SUBDIR}-${SWIFT_HOST_VARIANT_ARCH}>)
endif()

add_subdirectory(LongTests)
Expand Down