From 228aecd0f6e8983914592d0daed76c0787642f04 Mon Sep 17 00:00:00 2001 From: Eric Miotto Date: Thu, 6 Nov 2025 09:00:10 -0800 Subject: [PATCH 1/3] Runtimes: allow to link SwiftDirectRetainRelease in swiftCore At the moment we are not building that natively in the new build system, so find the copy built by the legacy one using a find module. Keep this disabled for the time being. Addresses rdar://164174616 --- Runtimes/Core/CMakeLists.txt | 6 ++ Runtimes/Core/Concurrency/CMakeLists.txt | 1 + Runtimes/Core/Core/CMakeLists.txt | 1 + .../Core/SwiftOnoneSupport/CMakeLists.txt | 3 +- .../cmake/interface/SwiftCoreConfig.cmake.in | 2 + .../Core/cmake/modules/DefaultSettings.cmake | 2 + .../modules/FindSwiftSwiftDirectRuntime.cmake | 74 +++++++++++++++++++ 7 files changed, 88 insertions(+), 1 deletion(-) create mode 100644 Runtimes/cmake/modules/FindSwiftSwiftDirectRuntime.cmake diff --git a/Runtimes/Core/CMakeLists.txt b/Runtimes/Core/CMakeLists.txt index d5d24536b9828..ff22720b053f2 100644 --- a/Runtimes/Core/CMakeLists.txt +++ b/Runtimes/Core/CMakeLists.txt @@ -109,6 +109,7 @@ defaulted_option(SwiftCore_ENABLE_BACKDEPLOYMENT_SUPPORT "Add symbols for runtim defaulted_option(SwiftCore_ENABLE_STDLIB_TRACING "Enable tracing in the runtime. Assumes the presence of os_log(3) and the os_signpost(3) API.") defaulted_option(SwiftCore_ENABLE_CONCURRENCY "Enable Concurrency runtime support") defaulted_option(SwiftCore_ENABLE_REMOTE_MIRROR "Enable RemoteMirror runtime support") +defaulted_option(SwiftCore_ENABLE_DIRECT_RETAIN_RELEASE "Use direct retain release in the runtime/stdlib") defaulted_set(SwiftCore_CONCURRENCY_GLOBAL_EXECUTOR STRING "Default Concurrency global executor implementation") option(SwiftCore_ENABLE_COMMANDLINE_SUPPORT "Enable command line argument support" ON) option(SwiftCore_ENABLE_UNICODE_DATA "Include unicode data in Swift runtimes" ON) @@ -196,6 +197,11 @@ add_compile_options( "$<$,$>:-enable-library-evolution>" "$<$,$>:SHELL:-Xfrontend -prespecialize-generic-metadata>") +if(SwiftCore_ENABLE_DIRECT_RETAIN_RELEASE) + find_package(SwiftSwiftDirectRuntime REQUIRED) + add_compile_options("$<$:SHELL:-Xfrontend -enable-direct-retain-release>") +endif() + include(ExperimentalFeatures) include_directories(include) diff --git a/Runtimes/Core/Concurrency/CMakeLists.txt b/Runtimes/Core/Concurrency/CMakeLists.txt index 6ea008aecdd73..5c6d845d2544a 100644 --- a/Runtimes/Core/Concurrency/CMakeLists.txt +++ b/Runtimes/Core/Concurrency/CMakeLists.txt @@ -139,6 +139,7 @@ target_link_libraries(swift_Concurrency PRIVATE $<$:log> $<$:Synchronization> $<$:mincore> + $<$:swiftSwiftDirectRuntime> # Link to the runtime that we are just building. swiftCore) set_target_properties(swift_Concurrency PROPERTIES diff --git a/Runtimes/Core/Core/CMakeLists.txt b/Runtimes/Core/Core/CMakeLists.txt index 023c23fe9e433..bf549e65af664 100644 --- a/Runtimes/Core/Core/CMakeLists.txt +++ b/Runtimes/Core/Core/CMakeLists.txt @@ -337,6 +337,7 @@ target_link_libraries(swiftCore swiftStdlibStubs swiftThreading $<$>:swiftrt$<$:T>> + $<$:swiftSwiftDirectRuntime> PUBLIC swiftShims INTERFACE diff --git a/Runtimes/Core/SwiftOnoneSupport/CMakeLists.txt b/Runtimes/Core/SwiftOnoneSupport/CMakeLists.txt index 41005c11d5b37..1e011304a99a1 100644 --- a/Runtimes/Core/SwiftOnoneSupport/CMakeLists.txt +++ b/Runtimes/Core/SwiftOnoneSupport/CMakeLists.txt @@ -29,7 +29,8 @@ target_compile_definitions(swiftSwiftOnoneSupport PRIVATE target_link_libraries(swiftSwiftOnoneSupport PRIVATE swiftShims - swiftCore) + swiftCore + $<$:swiftSwiftDirectRuntime>) install(TARGETS swiftSwiftOnoneSupport EXPORT SwiftCoreTargets diff --git a/Runtimes/Core/cmake/interface/SwiftCoreConfig.cmake.in b/Runtimes/Core/cmake/interface/SwiftCoreConfig.cmake.in index f6e2f73333873..8a0e8c8bd6f96 100644 --- a/Runtimes/Core/cmake/interface/SwiftCoreConfig.cmake.in +++ b/Runtimes/Core/cmake/interface/SwiftCoreConfig.cmake.in @@ -6,3 +6,5 @@ set(SwiftCore_ENABLE_LIBRARY_EVOLUTION @SwiftCore_ENABLE_LIBRARY_EVOLUTION@) set(SwiftCore_ENABLE_VECTOR_TYPES @SwiftCore_ENABLE_VECTOR_TYPES@) set(SwiftCore_ENABLE_BACKDEPLOYMENT_SUPPORT @SwiftCore_ENABLE_BACKDEPLOYMENT_SUPPORT@) + +set(SwiftCore_ENABLE_DIRECT_RETAIN_RELEASE @SwiftCore_ENABLE_DIRECT_RETAIN_RELEASE@) diff --git a/Runtimes/Core/cmake/modules/DefaultSettings.cmake b/Runtimes/Core/cmake/modules/DefaultSettings.cmake index e7a590054857f..ee43e7cc2f0a9 100644 --- a/Runtimes/Core/cmake/modules/DefaultSettings.cmake +++ b/Runtimes/Core/cmake/modules/DefaultSettings.cmake @@ -46,6 +46,8 @@ if(APPLE) set(SwiftCore_THREADING_PACKAGE_default "DARWIN") set(SwiftCore_ENABLE_PRESPECIALIZATION_default ON) set(SwiftCore_CONCURRENCY_GLOBAL_EXECUTOR_default "dispatch") + # TODO we are not ready to enable it here + set(SwiftCore_ENABLE_DIRECT_RETAIN_RELEASE_default OFF) elseif(CMAKE_SYSTEM_NAME STREQUAL "WASM") set(SwiftCore_OBJECT_FORMAT_default "elf") set(SwiftCore_THREADING_PACKAGE_default "NONE") diff --git a/Runtimes/cmake/modules/FindSwiftSwiftDirectRuntime.cmake b/Runtimes/cmake/modules/FindSwiftSwiftDirectRuntime.cmake new file mode 100644 index 0000000000000..2c416735a9f1e --- /dev/null +++ b/Runtimes/cmake/modules/FindSwiftSwiftDirectRuntime.cmake @@ -0,0 +1,74 @@ +#[=======================================================================[.rst: +FindSwiftSwiftDirectRuntime +------------ + +Find swiftSwiftDirectRuntime, deferring to the associated SwiftSwiftDirectRuntimeConfig.cmake when requested. +This is meant to be linked in swiftCore. + +Imported Targets +^^^^^^^^^^^^^^^^ + +The following :prop_tgt:`IMPORTED` TARGETS may be defined: + + ``swiftSwiftDirectRuntime`` + +#]=======================================================================] + +include_guard(GLOBAL) + +if(SwiftSwiftDirectRuntime_DIR) + if(${CMAKE_FIND_PACKAGE_NAME}_FIND_REQUIRED) + list(APPEND args REQUIRED) + endif() + if(${CMAKE_FIND_PACKAGE_NAME}_FIND_QUIETLY) + list(APPEND args QUIET) + endif() + find_package(SwiftSwiftDirectRuntime CONFIG ${args}) + return() +endif() + +include(FindPackageHandleStandardArgs) +include(PlatformInfo) + +if(APPLE) + # SwiftDirectRuntime is not installed in the SDKs, but in the + # toolchain next to the compiler + set(target_info_command "${CMAKE_Swift_COMPILER}" -print-target-info) + if(CMAKE_Swift_COMPILER_TARGET) + list(APPEND target_info_command -target ${CMAKE_Swift_COMPILER_TARGET}) + endif() + execute_process(COMMAND ${target_info_command} OUTPUT_VARIABLE target_info_json) + message(CONFIGURE_LOG "Swift target info: ${target_info_command}\n" + "${target_info_json}") + + string(JSON runtime_library_import_paths_json GET "${target_info_json}" "paths" "runtimeLibraryImportPaths") + message(CONFIGURE_LOG "runtime_library_import_paths_json ${runtime_library_import_paths_json}") + + string(JSON number_of_runtime_library_import_paths LENGTH "${runtime_library_import_paths_json}") + math(EXPR index_of_last_runtime_library_import_path "${number_of_runtime_library_import_paths} - 1") + foreach(index RANGE 0 ${index_of_last_runtime_library_import_path}) + string(JSON runtime_library_import_path GET "${runtime_library_import_paths_json}" ${index}) + + list(APPEND swiftSwiftDirectRuntime_LIBRARY_HINTS + "${runtime_library_import_path}") + endforeach() + + list(APPEND swiftSwiftDirectRuntime_NAMES libswiftSwiftDirectRuntime.a) +else() + message(WARNING "SwiftDirectRuntime is only available for Apple platforms at the moment.\n") + return() +endif() + +find_library(swiftSwiftDirectRuntime_LIBRARY + NAMES + ${swiftSwiftDirectRuntime_NAMES} + NO_CMAKE_FIND_ROOT_PATH + HINTS + ${swiftSwiftDirectRuntime_LIBRARY_HINTS}) + +add_library(swiftSwiftDirectRuntime STATIC IMPORTED GLOBAL) +set_target_properties(swiftSwiftDirectRuntime PROPERTIES + IMPORTED_LOCATION "${swiftSwiftDirectRuntime_LIBRARY}") + +find_package_handle_standard_args(SwiftSwiftDirectRuntime DEFAULT_MSG + swiftSwiftDirectRuntime_LIBRARY) From 139c4e0fc8f7841e09404c705d59b52850c19221 Mon Sep 17 00:00:00 2001 From: Eric Miotto Date: Mon, 10 Nov 2025 12:22:10 -0800 Subject: [PATCH 2/3] Add support for linking SwiftSwiftDirectRuntime in Overlay build system Addresses rdar://164174616 --- Runtimes/Overlay/CMakeLists.txt | 7 +++++++ Runtimes/Overlay/Cxx/CMakeLists.txt | 1 + Runtimes/Overlay/Cxx/std/CMakeLists.txt | 1 + Runtimes/Overlay/clang/CMakeLists.txt | 1 + 4 files changed, 10 insertions(+) diff --git a/Runtimes/Overlay/CMakeLists.txt b/Runtimes/Overlay/CMakeLists.txt index 7fc69762c77e5..68ce41599808f 100644 --- a/Runtimes/Overlay/CMakeLists.txt +++ b/Runtimes/Overlay/CMakeLists.txt @@ -59,6 +59,8 @@ option(SwiftOverlay_ENABLE_LIBRARY_EVOLUTION "Generate ABI resilient runtime lib ${SwiftCore_ENABLE_LIBRARY_EVOLUTION}) option(SwiftOverlay_ENABLE_BACKDEPLOYMENT_SUPPORT "Add symbols for runtime backdeployment" ${SwiftCore_ENABLE_BACKDEPLOYMENT_SUPPORT}) +option(${PROJECT_NAME}_ENABLE_DIRECT_RETAIN_RELEASE "Use direct retain release in overlays" + ${SwiftCore_ENABLE_DIRECT_RETAIN_RELEASE}) add_compile_definitions( $<$:SWIFT_STDLIB_SUPPORT_BACK_DEPLOYMENT>) @@ -74,6 +76,11 @@ add_compile_options( "$<$,$>:-enable-library-evolution>" "$<$,$>:SHELL:-Xfrontend -prespecialize-generic-metadata>") +if(${PROJECT_NAME}_ENABLE_DIRECT_RETAIN_RELEASE) + find_package(SwiftSwiftDirectRuntime REQUIRED) + add_compile_options("$<$:SHELL:-Xfrontend -enable-direct-retain-release>") +endif() + include(ExperimentalFeatures) # LNK4049: symbol 'symbol' defined in 'filename.obj' is imported diff --git a/Runtimes/Overlay/Cxx/CMakeLists.txt b/Runtimes/Overlay/Cxx/CMakeLists.txt index f14292bb58d0d..5f41ab1cc04da 100644 --- a/Runtimes/Overlay/Cxx/CMakeLists.txt +++ b/Runtimes/Overlay/Cxx/CMakeLists.txt @@ -36,6 +36,7 @@ target_compile_options(swiftCxx PRIVATE "$<$:SHELL:-enable-experimental-feature BuiltinModule>" "$<$:SHELL:-enable-experimental-feature Lifetimes>") target_link_libraries(swiftCxx PRIVATE + $<$:swiftSwiftDirectRuntime> swiftCore) install(TARGETS swiftCxx diff --git a/Runtimes/Overlay/Cxx/std/CMakeLists.txt b/Runtimes/Overlay/Cxx/std/CMakeLists.txt index 5de16af81f823..4ac3ca825af92 100644 --- a/Runtimes/Overlay/Cxx/std/CMakeLists.txt +++ b/Runtimes/Overlay/Cxx/std/CMakeLists.txt @@ -25,6 +25,7 @@ target_compile_options(swiftCxxStdlib PRIVATE target_link_libraries(swiftCxxStdlib PRIVATE $<$:libstdcxx> $<$>:cxxshim> + $<$:swiftSwiftDirectRuntime> swiftCxx swiftCore swift_Builtin_float diff --git a/Runtimes/Overlay/clang/CMakeLists.txt b/Runtimes/Overlay/clang/CMakeLists.txt index 3be1089f19847..0c3057f339912 100644 --- a/Runtimes/Overlay/clang/CMakeLists.txt +++ b/Runtimes/Overlay/clang/CMakeLists.txt @@ -12,6 +12,7 @@ target_compile_options(swift_Builtin_float PRIVATE $<$:-autolink-force-load>) target_link_libraries(swift_Builtin_float PRIVATE $<$:ClangModules> + $<$:swiftSwiftDirectRuntime> swiftCore) install(TARGETS swift_Builtin_float From 97e4ea354ff7beda0ac03cb3208b159f4d22a99c Mon Sep 17 00:00:00 2001 From: Eric Miotto Date: Mon, 10 Nov 2025 13:27:26 -0800 Subject: [PATCH 3/3] Allow to link SwiftSwiftDirectRuntime in Supplemental build system Addresses rdar://164174616 --- Runtimes/Supplemental/Differentiation/CMakeLists.txt | 10 +++++++++- Runtimes/Supplemental/Distributed/CMakeLists.txt | 11 ++++++++++- Runtimes/Supplemental/Observation/CMakeLists.txt | 11 ++++++++++- Runtimes/Supplemental/Runtime/CMakeLists.txt | 11 ++++++++++- Runtimes/Supplemental/StringProcessing/CMakeLists.txt | 8 ++++++++ .../StringProcessing/RegexBuilder/CMakeLists.txt | 3 ++- .../StringProcessing/_RegexParser/CMakeLists.txt | 3 ++- .../StringProcessing/_StringProcessing/CMakeLists.txt | 3 ++- Runtimes/Supplemental/Synchronization/CMakeLists.txt | 11 ++++++++++- Runtimes/Supplemental/Volatile/CMakeLists.txt | 11 ++++++++++- 10 files changed, 73 insertions(+), 9 deletions(-) diff --git a/Runtimes/Supplemental/Differentiation/CMakeLists.txt b/Runtimes/Supplemental/Differentiation/CMakeLists.txt index 3e0b42124aeff..caa4eb611d2ec 100644 --- a/Runtimes/Supplemental/Differentiation/CMakeLists.txt +++ b/Runtimes/Supplemental/Differentiation/CMakeLists.txt @@ -61,6 +61,8 @@ option(${PROJECT_NAME}_ENABLE_LIBRARY_EVOLUTION "Generate ABI resilient runtime option(${PROJECT_NAME}_ENABLE_VECTOR_TYPES "Enable vector support" ${SwiftCore_ENABLE_VECTOR_TYPES}) +option(${PROJECT_NAME}_ENABLE_DIRECT_RETAIN_RELEASE "Use direct retain release" + ${SwiftCore_ENABLE_DIRECT_RETAIN_RELEASE}) add_compile_options( $<$:-explicit-module-build> @@ -77,6 +79,11 @@ add_compile_options( "$<$:SHELL:-Xfrontend -target-min-inlining-version -Xfrontend min>" $<$,$>:-enable-library-evolution>) +if(${PROJECT_NAME}_ENABLE_DIRECT_RETAIN_RELEASE) + find_package(SwiftSwiftDirectRuntime REQUIRED) + add_compile_options("$<$:SHELL:-Xfrontend -enable-direct-retain-release>") +endif() + # LNK4049: symbol 'symbol' defined in 'filename.obj' is imported # LNK4286: symbol 'symbol' defined in 'filename_1.obj' is imported by 'filename_2.obj' # LNK4217: symbol 'symbol' defined in 'filename_1.obj' is imported by 'filename_2.obj' in function 'function' @@ -120,7 +127,8 @@ set_target_properties(swift_Differentiation PROPERTIES target_link_libraries(swift_Differentiation PRIVATE swiftCore $<$:swiftAndroid> - $<$:swiftCRT>) + $<$:swiftCRT> + $<$:swiftSwiftDirectRuntime>) install(TARGETS swift_Differentiation diff --git a/Runtimes/Supplemental/Distributed/CMakeLists.txt b/Runtimes/Supplemental/Distributed/CMakeLists.txt index a802147d72c7e..88129bf15d3dd 100644 --- a/Runtimes/Supplemental/Distributed/CMakeLists.txt +++ b/Runtimes/Supplemental/Distributed/CMakeLists.txt @@ -65,6 +65,9 @@ option(${PROJECT_NAME}_ENABLE_LIBRARY_EVOLUTION "Generate ABI resilient runtime option(${PROJECT_NAME}_ENABLE_PRESPECIALIZATION "Enable generic metadata prespecialization" ${SwiftCore_ENABLE_PRESPECIALIZATION}) +option(${PROJECT_NAME}_ENABLE_DIRECT_RETAIN_RELEASE "Use direct retain release" + ${SwiftCore_ENABLE_DIRECT_RETAIN_RELEASE}) + add_compile_options( $<$:-explicit-module-build> $<$:-nostdlibimport> @@ -84,6 +87,11 @@ add_compile_options( "$<$,$>:-enable-library-evolution>" "$<$,$>:SHELL:-Xfrontend -prespecialize-generic-metadata>") +if(${PROJECT_NAME}_ENABLE_DIRECT_RETAIN_RELEASE) + find_package(SwiftSwiftDirectRuntime REQUIRED) + add_compile_options("$<$:SHELL:-Xfrontend -enable-direct-retain-release>") +endif() + # LNK4049: symbol 'symbol' defined in 'filename.obj' is imported # LNK4286: symbol 'symbol' defined in 'filename_1.obj' is imported by 'filename_2.obj' # LNK4217: symbol 'symbol' defined in 'filename_1.obj' is imported by 'filename_2.obj' in function 'function' @@ -146,7 +154,8 @@ target_link_libraries(swiftDistributed PRIVATE swift_Concurrency swift_Builtin_float $<$:swiftAndroid> - $<$:swiftWinSDK>) + $<$:swiftWinSDK> + $<$:swiftSwiftDirectRuntime>) install(TARGETS swiftDistributed EXPORT SwiftDistributedTargets diff --git a/Runtimes/Supplemental/Observation/CMakeLists.txt b/Runtimes/Supplemental/Observation/CMakeLists.txt index 98ce40a292f5e..fde605d1fa868 100644 --- a/Runtimes/Supplemental/Observation/CMakeLists.txt +++ b/Runtimes/Supplemental/Observation/CMakeLists.txt @@ -61,6 +61,9 @@ option(${PROJECT_NAME}_ENABLE_LIBRARY_EVOLUTION "Generate ABI resilient runtime option(${PROJECT_NAME}_ENABLE_PRESPECIALIZATION "Enable generic metadata prespecialization" ${SwiftCore_ENABLE_PRESPECIALIZATION}) +option(${PROJECT_NAME}_ENABLE_DIRECT_RETAIN_RELEASE "Use direct retain release" + ${SwiftCore_ENABLE_DIRECT_RETAIN_RELEASE}) + add_compile_options( $<$:-explicit-module-build> $<$:-nostdlibimport> @@ -82,6 +85,11 @@ add_compile_options( "$<$,$>:-enable-library-evolution>" "$<$,$>:SHELL:-Xfrontend -prespecialize-generic-metadata>") +if(${PROJECT_NAME}_ENABLE_DIRECT_RETAIN_RELEASE) + find_package(SwiftSwiftDirectRuntime REQUIRED) + add_compile_options("$<$:SHELL:-Xfrontend -enable-direct-retain-release>") +endif() + # LNK4049: symbol 'symbol' defined in 'filename.obj' is imported # LNK4286: symbol 'symbol' defined in 'filename_1.obj' is imported by 'filename_2.obj' # LNK4217: symbol 'symbol' defined in 'filename_1.obj' is imported by 'filename_2.obj' in function 'function' @@ -116,7 +124,8 @@ target_link_libraries(swiftObservation PRIVATE swift_Concurrency $<$:swiftAndroid> $<$:swiftGlibc> - $<$:swiftWinSDK>) + $<$:swiftWinSDK> + $<$:swiftSwiftDirectRuntime>) install(TARGETS swiftObservation EXPORT SwiftObservationTargets diff --git a/Runtimes/Supplemental/Runtime/CMakeLists.txt b/Runtimes/Supplemental/Runtime/CMakeLists.txt index 91579b8c79a41..b77e32668b8ae 100644 --- a/Runtimes/Supplemental/Runtime/CMakeLists.txt +++ b/Runtimes/Supplemental/Runtime/CMakeLists.txt @@ -68,6 +68,9 @@ option(${PROJECT_NAME}_ENABLE_LIBRARY_EVOLUTION "Generate ABI resilient runtime option(${PROJECT_NAME}_ENABLE_PRESPECIALIZATION "Enable generic metadata prespecialization" ${SwiftCore_ENABLE_PRESPECIALIZATION}) +option(${PROJECT_NAME}_ENABLE_DIRECT_RETAIN_RELEASE "Use direct retain release" + ${SwiftCore_ENABLE_DIRECT_RETAIN_RELEASE}) + add_compile_options( $<$:-explicit-module-build> $<$:-nostdlibimport> @@ -92,6 +95,11 @@ add_compile_options( "$<$,$>:-enable-library-evolution>" "$<$,$>:SHELL:-Xfrontend -prespecialize-generic-metadata>") +if(${PROJECT_NAME}_ENABLE_DIRECT_RETAIN_RELEASE) + find_package(SwiftSwiftDirectRuntime REQUIRED) + add_compile_options("$<$:SHELL:-Xfrontend -enable-direct-retain-release>") +endif() + # LNK4049: symbol 'symbol' defined in 'filename.obj' is imported # LNK4286: symbol 'symbol' defined in 'filename_1.obj' is imported by 'filename_2.obj' # LNK4217: symbol 'symbol' defined in 'filename_1.obj' is imported by 'filename_2.obj' in function 'function' @@ -157,7 +165,8 @@ target_link_libraries(swiftRuntime PRIVATE $<$:swiftAndroid> $<$:swiftDarwin> $<$:swiftGlibc> - $<$:swiftWinSDK>) + $<$:swiftWinSDK> + $<$:swiftSwiftDirectRuntime>) install(TARGETS swiftRuntime EXPORT SwiftRuntimeTargets diff --git a/Runtimes/Supplemental/StringProcessing/CMakeLists.txt b/Runtimes/Supplemental/StringProcessing/CMakeLists.txt index 709ba16918411..81861e8c9a2df 100644 --- a/Runtimes/Supplemental/StringProcessing/CMakeLists.txt +++ b/Runtimes/Supplemental/StringProcessing/CMakeLists.txt @@ -50,6 +50,9 @@ option(${PROJECT_NAME}_ENABLE_LIBRARY_EVOLUTION "Generate ABI resilient runtime option(${PROJECT_NAME}_ENABLE_PRESPECIALIZATION "Enable generic metadata prespecialization" ${SwiftCore_ENABLE_PRESPECIALIZATION}) +option(${PROJECT_NAME}_ENABLE_DIRECT_RETAIN_RELEASE "Use direct retain release" + ${SwiftCore_ENABLE_DIRECT_RETAIN_RELEASE}) + add_compile_options( $<$:-explicit-module-build> $<$:-nostdlibimport> @@ -59,6 +62,11 @@ add_compile_options( "$<$,$>:-enable-library-evolution>" "$<$,$>:SHELL:-Xfrontend -prespecialize-generic-metadata>") +if(${PROJECT_NAME}_ENABLE_DIRECT_RETAIN_RELEASE) + find_package(SwiftSwiftDirectRuntime REQUIRED) + add_compile_options("$<$:SHELL:-Xfrontend -enable-direct-retain-release>") +endif() + # LNK4049: symbol 'symbol' defined in 'filename.obj' is imported # LNK4286: symbol 'symbol' defined in 'filename_1.obj' is imported by 'filename_2.obj' # LNK4217: symbol 'symbol' defined in 'filename_1.obj' is imported by 'filename_2.obj' in function 'function' diff --git a/Runtimes/Supplemental/StringProcessing/RegexBuilder/CMakeLists.txt b/Runtimes/Supplemental/StringProcessing/RegexBuilder/CMakeLists.txt index a76f8550d2bf5..80d8923907c05 100644 --- a/Runtimes/Supplemental/StringProcessing/RegexBuilder/CMakeLists.txt +++ b/Runtimes/Supplemental/StringProcessing/RegexBuilder/CMakeLists.txt @@ -12,7 +12,8 @@ set_target_properties(swiftRegexBuilder PROPERTIES target_link_libraries(swiftRegexBuilder PRIVATE swift_RegexParser swift_StringProcessing - swiftCore) + swiftCore + $<$:swiftSwiftDirectRuntime>) install(TARGETS swiftRegexBuilder ARCHIVE DESTINATION "${SwiftStringProcessing_INSTALL_LIBDIR}" diff --git a/Runtimes/Supplemental/StringProcessing/_RegexParser/CMakeLists.txt b/Runtimes/Supplemental/StringProcessing/_RegexParser/CMakeLists.txt index 0fed65de6ceb5..e431544c46012 100644 --- a/Runtimes/Supplemental/StringProcessing/_RegexParser/CMakeLists.txt +++ b/Runtimes/Supplemental/StringProcessing/_RegexParser/CMakeLists.txt @@ -32,7 +32,8 @@ add_library(swift_RegexParser Utility/MissingUnicode.swift) target_link_libraries(swift_RegexParser PRIVATE - swiftCore) + swiftCore + $<$:swiftSwiftDirectRuntime>) set_target_properties(swift_RegexParser PROPERTIES Swift_MODULE_NAME _RegexParser) diff --git a/Runtimes/Supplemental/StringProcessing/_StringProcessing/CMakeLists.txt b/Runtimes/Supplemental/StringProcessing/_StringProcessing/CMakeLists.txt index 99a0420852532..d2a4e67bb2718 100644 --- a/Runtimes/Supplemental/StringProcessing/_StringProcessing/CMakeLists.txt +++ b/Runtimes/Supplemental/StringProcessing/_StringProcessing/CMakeLists.txt @@ -77,7 +77,8 @@ set_target_properties(swift_StringProcessing PROPERTIES target_link_libraries(swift_StringProcessing PRIVATE swift_RegexParser - swiftCore) + swiftCore + $<$:swiftSwiftDirectRuntime>) install(TARGETS swift_StringProcessing ARCHIVE DESTINATION "${SwiftStringProcessing_INSTALL_LIBDIR}" diff --git a/Runtimes/Supplemental/Synchronization/CMakeLists.txt b/Runtimes/Supplemental/Synchronization/CMakeLists.txt index 2ab0500c53d94..c6bd55ab15a0e 100644 --- a/Runtimes/Supplemental/Synchronization/CMakeLists.txt +++ b/Runtimes/Supplemental/Synchronization/CMakeLists.txt @@ -65,6 +65,9 @@ option(${PROJECT_NAME}_ENABLE_LIBRARY_EVOLUTION "Generate ABI resilient runtime option(${PROJECT_NAME}_ENABLE_PRESPECIALIZATION "Enable generic metadata prespecialization" ${SwiftCore_ENABLE_PRESPECIALIZATION}) +option(${PROJECT_NAME}_ENABLE_DIRECT_RETAIN_RELEASE "Use direct retain release" + ${SwiftCore_ENABLE_DIRECT_RETAIN_RELEASE}) + option(${PROJECT_NAME}_SINGLE_THREADED_MODE "Build Synchronization assuming it will be used in an environment with only a single thread" OFF) add_compile_options( @@ -95,6 +98,11 @@ add_compile_options( "$<$,$>:-enable-library-evolution>" "$<$,$>:SHELL:-Xfrontend -prespecialize-generic-metadata>") +if(${PROJECT_NAME}_ENABLE_DIRECT_RETAIN_RELEASE) + find_package(SwiftSwiftDirectRuntime REQUIRED) + add_compile_options("$<$:SHELL:-Xfrontend -enable-direct-retain-release>") +endif() + # LNK4049: symbol 'symbol' defined in 'filename.obj' is imported # LNK4286: symbol 'symbol' defined in 'filename_1.obj' is imported by 'filename_2.obj' # LNK4217: symbol 'symbol' defined in 'filename_1.obj' is imported by 'filename_2.obj' in function 'function' @@ -143,7 +151,8 @@ target_link_libraries(swiftSynchronization PRIVATE swiftCore $<$:swiftAndroid> $<$:swiftDarwin> - $<$:ClangModules>) + $<$:ClangModules> + $<$:swiftSwiftDirectRuntime>) if(WIN32 AND CMAKE_SYSTEM_PROCESSOR STREQUAL i686) # FIXME(#83765) `-whole-module-optimization` should not be needed. However, diff --git a/Runtimes/Supplemental/Volatile/CMakeLists.txt b/Runtimes/Supplemental/Volatile/CMakeLists.txt index ad8fc2428852a..dbb4c14302dd9 100644 --- a/Runtimes/Supplemental/Volatile/CMakeLists.txt +++ b/Runtimes/Supplemental/Volatile/CMakeLists.txt @@ -63,6 +63,9 @@ option(${PROJECT_NAME}_ENABLE_LIBRARY_EVOLUTION "Generate ABI resilient runtime option(${PROJECT_NAME}_ENABLE_PRESPECIALIZATION "Enable generic metadata prespecialization" ${SwiftCore_ENABLE_PRESPECIALIZATION}) +option(${PROJECT_NAME}_ENABLE_DIRECT_RETAIN_RELEASE "Use direct retain release" + ${SwiftCore_ENABLE_DIRECT_RETAIN_RELEASE}) + add_compile_options( $<$:-explicit-module-build> $<$:-nostdlibimport> @@ -70,6 +73,11 @@ add_compile_options( "$<$,$>:-enable-library-evolution>" "$<$,$>:SHELL:-Xfrontend -prespecialize-generic-metadata>") +if(${PROJECT_NAME}_ENABLE_DIRECT_RETAIN_RELEASE) + find_package(SwiftSwiftDirectRuntime REQUIRED) + add_compile_options("$<$:SHELL:-Xfrontend -enable-direct-retain-release>") +endif() + # LNK4049: symbol 'symbol' defined in 'filename.obj' is imported # LNK4286: symbol 'symbol' defined in 'filename_1.obj' is imported by 'filename_2.obj' # LNK4217: symbol 'symbol' defined in 'filename_1.obj' is imported by 'filename_2.obj' in function 'function' @@ -88,7 +96,8 @@ set_target_properties(swift_Volatile PROPERTIES target_compile_options(swift_Volatile PRIVATE -parse-stdlib) target_link_libraries(swift_Volatile PRIVATE - swiftCore) + swiftCore + $<$:swiftSwiftDirectRuntime>) install(TARGETS swift_Volatile EXPORT SwiftVolatileTargets