Skip to content

Remove SWIFTLIB_SINGLE_TARGET_LIBRARY #38978

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

Merged
merged 2 commits into from
Aug 24, 2021
Merged
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
70 changes: 27 additions & 43 deletions stdlib/cmake/modules/AddSwiftStdlib.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -622,7 +622,6 @@ function(_add_swift_target_library_single target name)
OBJECT_LIBRARY
SHARED
STATIC
TARGET_LIBRARY
INSTALL_WITH_SHARED)
set(SWIFTLIB_SINGLE_single_parameter_options
ARCHITECTURE
Expand Down Expand Up @@ -850,7 +849,7 @@ function(_add_swift_target_library_single target name)
endforeach()

set(SWIFTLIB_SINGLE_XCODE_WORKAROUND_SOURCES)
if(XCODE AND SWIFTLIB_SINGLE_TARGET_LIBRARY)
if(XCODE)
set(SWIFTLIB_SINGLE_XCODE_WORKAROUND_SOURCES
# Note: the dummy.cpp source file provides no definitions. However,
# it forces Xcode to properly link the static library.
Expand All @@ -873,8 +872,7 @@ function(_add_swift_target_library_single target name)
target_include_directories(${target} BEFORE PRIVATE
${SWIFT_SOURCE_DIR}/stdlib/include)
if(("${SWIFT_SDK_${SWIFTLIB_SINGLE_SDK}_OBJECT_FORMAT}" STREQUAL "ELF" OR
"${SWIFT_SDK_${SWIFTLIB_SINGLE_SDK}_OBJECT_FORMAT}" STREQUAL "COFF") AND
SWIFTLIB_SINGLE_TARGET_LIBRARY)
"${SWIFT_SDK_${SWIFTLIB_SINGLE_SDK}_OBJECT_FORMAT}" STREQUAL "COFF"))
if("${libkind}" STREQUAL "SHARED" AND NOT SWIFTLIB_SINGLE_NOSWIFTRT)
# TODO(compnerd) switch to the generator expression when cmake is upgraded
# to a version which supports it.
Expand Down Expand Up @@ -937,27 +935,25 @@ function(_add_swift_target_library_single target name)
SUFFIX ${LLVM_PLUGIN_EXT})
endif()

if(SWIFTLIB_SINGLE_TARGET_LIBRARY)
# Install runtime libraries to lib/swift instead of lib. This works around
# the fact that -isysroot prevents linking to libraries in the system
# /usr/lib if Swift is installed in /usr.
set_target_properties("${target}" PROPERTIES
LIBRARY_OUTPUT_DIRECTORY ${SWIFTLIB_DIR}/${SWIFTLIB_SINGLE_SUBDIR}
ARCHIVE_OUTPUT_DIRECTORY ${SWIFTLIB_DIR}/${SWIFTLIB_SINGLE_SUBDIR})
if(SWIFTLIB_SINGLE_SDK STREQUAL WINDOWS AND SWIFTLIB_SINGLE_IS_STDLIB_CORE
AND libkind STREQUAL SHARED)
add_custom_command(TARGET ${target} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different $<TARGET_FILE:${target}> ${SWIFTLIB_DIR}/${SWIFTLIB_SINGLE_SUBDIR})
endif()

foreach(config ${CMAKE_CONFIGURATION_TYPES})
string(TOUPPER ${config} config_upper)
escape_path_for_xcode("${config}" "${SWIFTLIB_DIR}" config_lib_dir)
set_target_properties(${target} PROPERTIES
LIBRARY_OUTPUT_DIRECTORY_${config_upper} ${config_lib_dir}/${SWIFTLIB_SINGLE_SUBDIR}
ARCHIVE_OUTPUT_DIRECTORY_${config_upper} ${config_lib_dir}/${SWIFTLIB_SINGLE_SUBDIR})
endforeach()
endif()
# Install runtime libraries to lib/swift instead of lib. This works around
# the fact that -isysroot prevents linking to libraries in the system
# /usr/lib if Swift is installed in /usr.
set_target_properties("${target}" PROPERTIES
LIBRARY_OUTPUT_DIRECTORY ${SWIFTLIB_DIR}/${SWIFTLIB_SINGLE_SUBDIR}
ARCHIVE_OUTPUT_DIRECTORY ${SWIFTLIB_DIR}/${SWIFTLIB_SINGLE_SUBDIR})
if(SWIFTLIB_SINGLE_SDK STREQUAL WINDOWS AND SWIFTLIB_SINGLE_IS_STDLIB_CORE
AND libkind STREQUAL SHARED)
add_custom_command(TARGET ${target} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different $<TARGET_FILE:${target}> ${SWIFTLIB_DIR}/${SWIFTLIB_SINGLE_SUBDIR})
endif()

foreach(config ${CMAKE_CONFIGURATION_TYPES})
string(TOUPPER ${config} config_upper)
escape_path_for_xcode("${config}" "${SWIFTLIB_DIR}" config_lib_dir)
set_target_properties(${target} PROPERTIES
LIBRARY_OUTPUT_DIRECTORY_${config_upper} ${config_lib_dir}/${SWIFTLIB_SINGLE_SUBDIR}
ARCHIVE_OUTPUT_DIRECTORY_${config_upper} ${config_lib_dir}/${SWIFTLIB_SINGLE_SUBDIR})
endforeach()

if(SWIFTLIB_SINGLE_SDK IN_LIST SWIFT_APPLE_PLATFORMS)
set(install_name_dir "@rpath")
Expand Down Expand Up @@ -993,9 +989,7 @@ function(_add_swift_target_library_single target name)
# for an Android cross-build from a macOS host. Construct the proper linker
# flags manually in add_swift_target_library instead, see there with
# variable `swiftlib_link_flags_all`.
if(SWIFTLIB_SINGLE_TARGET_LIBRARY)
set_target_properties("${target}" PROPERTIES NO_SONAME TRUE)
endif()
set_target_properties("${target}" PROPERTIES NO_SONAME TRUE)
# Only set the install RPATH if the toolchain and stdlib will be in Termux
# or some other native sysroot on Android.
if(NOT "${SWIFT_ANDROID_NATIVE_SYSROOT}" STREQUAL "")
Expand Down Expand Up @@ -1062,11 +1056,9 @@ function(_add_swift_target_library_single target name)

# Don't build standard libraries by default. We will enable building
# standard libraries that the user requested; the rest can be built on-demand.
if(SWIFTLIB_SINGLE_TARGET_LIBRARY)
foreach(t "${target}" ${target_static})
set_target_properties(${t} PROPERTIES EXCLUDE_FROM_ALL TRUE)
endforeach()
endif()
foreach(t "${target}" ${target_static})
set_target_properties(${t} PROPERTIES EXCLUDE_FROM_ALL TRUE)
endforeach()

# Handle linking and dependencies.
add_dependencies_multiple_targets(
Expand Down Expand Up @@ -1141,15 +1133,8 @@ function(_add_swift_target_library_single target name)
list(APPEND library_search_directories "${SWIFT_SDK_${sdk}_ARCH_${arch}_PATH}/usr/lib/swift")

# Add variant-specific flags.
if(SWIFTLIB_SINGLE_TARGET_LIBRARY)
set(build_type "${SWIFT_STDLIB_BUILD_TYPE}")
set(enable_assertions "${SWIFT_STDLIB_ASSERTIONS}")
else()
set(build_type "${CMAKE_BUILD_TYPE}")
set(enable_assertions "${LLVM_ENABLE_ASSERTIONS}")
set(analyze_code_coverage "${SWIFT_ANALYZE_CODE_COVERAGE}")
endif()

set(build_type "${SWIFT_STDLIB_BUILD_TYPE}")
set(enable_assertions "${SWIFT_STDLIB_ASSERTIONS}")
set(lto_type "${SWIFT_STDLIB_ENABLE_LTO}")

_add_target_variant_c_compile_flags(
Expand Down Expand Up @@ -1988,7 +1973,6 @@ function(add_swift_target_library name)
${SWIFTLIB_OBJECT_LIBRARY_keyword}
${SWIFTLIB_INSTALL_WITH_SHARED_keyword}
${SWIFTLIB_SOURCES}
TARGET_LIBRARY
MODULE_TARGETS ${module_variant_names}
SDK ${sdk}
ARCHITECTURE ${arch}
Expand Down
2 changes: 1 addition & 1 deletion stdlib/private/BlocksRuntimeStubs/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ foreach(SDK ${SWIFT_SDKS})
_add_swift_target_library_single(
BlocksRuntimeStub${VARIANT_SUFFIX}
BlocksRuntimeStub
SHARED
SHARED NOSWIFTRT
ARCHITECTURE ${ARCH}
SDK ${SDK}
INSTALL_IN_COMPONENT dev
Expand Down