Runtimes: introduce SwiftOnoneSupport

The main goal for now is to have this building, with little
concern about matching the build flags used currently.

Keep it disabled by default on Apple platforms.

Addresses rdar://143151393
This commit is contained in:
Eric Miotto
2025-01-17 15:09:25 -08:00
parent 4306b57590
commit c1257eb4ef
4 changed files with 54 additions and 6 deletions

View File

@@ -118,6 +118,8 @@ option(SwiftCore_INSTALL_NESTED_SUBDIR "Install libraries under a platform and a
set(SwiftCore_INSTALL_LIBDIR "${CMAKE_INSTALL_LIBDIR}/swift$<$<NOT:$<BOOL:${BUILD_SHARED_LIBS}>>:_static>$<$<BOOL:${SwiftCore_INSTALL_NESTED_SUBDIR}>:/${SwiftCore_PLATFORM_SUBDIR}/${SwiftCore_ARCH_SUBDIR}>")
set(SwiftCore_INSTALL_SWIFTMODULEDIR "${CMAKE_INSTALL_LIBDIR}/swift$<$<NOT:$<BOOL:${BUILD_SHARED_LIBS}>>:_static>$<$<BOOL:${SwiftCore_INSTALL_NESTED_SUBDIR}>:/${SwiftCore_PLATFORM_SUBDIR}>")
option(SwiftCore_ENABLE_ONONESUPPORT "Enable Onone Support" YES)
# TODO: Most of these should be attached to specific targets rather than applied
# globally. They can be applied as part of the library interface if they
# affect the behavior of libraries that build against a given target.
@@ -193,3 +195,6 @@ add_subdirectory(runtime)
add_subdirectory(stubs)
add_subdirectory(CommandLineSupport)
add_subdirectory(core)
if(SwiftCore_ENABLE_ONONESUPPORT)
add_subdirectory(SwiftOnoneSupport)
endif()

View File

@@ -0,0 +1,45 @@
add_library(swiftSwiftOnoneSupport
SwiftOnoneSupport.swift
"${PROJECT_SOURCE_DIR}/linker-support/magic-symbols-for-install-name.c")
set_target_properties(swiftSwiftOnoneSupport PROPERTIES
Swift_MODULE_NAME SwiftOnoneSupport)
if(APPLE AND BUILD_SHARED_LIBS)
target_link_options(swiftSwiftOnoneSupport PRIVATE "SHELL:-Xlinker -headerpad_max_install_names")
endif()
target_compile_options(swiftSwiftOnoneSupport PRIVATE
$<$<COMPILE_LANGUAGE:Swift>:-parse-stdlib>
"$<$<COMPILE_LANGUAGE:Swift>:SHELL:-Xllvm -sil-inline-generics=false>"
# We have to disable validation of TBD files, because this module is
# _explicitly_ special-cased to result in extra symbols generated by the
# optimizer, meaning TBDGen can't (and shouldn't: it has to run
# pre-optimization for performance) list them.
# See also caa3dd4d291ec93c1a59f1db62604e703bff8468
"$<$<COMPILE_LANGUAGE:Swift>:SHELL:-Xfrontend -validate-tbd-against-ir=none>"
"$<$<COMPILE_LANGUAGE:Swift>:SHELL:-Xfrontend -check-onone-completeness>"
"$<$<COMPILE_LANGUAGE:Swift>:SHELL:-Xfrontend -disable-access-control>")
target_compile_definitions(swiftSwiftOnoneSupport PRIVATE
$<$<COMPILE_LANGUAGE:C,CXX>:-DSWIFT_TARGET_LIBRARY_NAME=swiftSwiftOnoneSupport>)
target_link_libraries(swiftSwiftOnoneSupport
PRIVATE
swiftShims
swiftCore)
install(TARGETS swiftSwiftOnoneSupport
ARCHIVE DESTINATION "${SwiftCore_INSTALL_LIBDIR}"
LIBRARY DESTINATION "${SwiftCore_INSTALL_LIBDIR}"
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}")
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/SwiftOnoneSupport.swiftmodule"
DESTINATION "${SwiftCore_INSTALL_SWIFTMODULEDIR}/SwiftOnoneSupport.swiftmodule"
RENAME "${SwiftCore_MODULE_TRIPLE}.swiftmodule")
emit_swift_interface(swiftSwiftOnoneSupport)
install_swift_interface(swiftSwiftOnoneSupport)
# Configure plist creation for Darwin platforms.
generate_plist("${CMAKE_PROJECT_NAME}" "${CMAKE_PROJECT_VERSION}" swiftSwiftOnoneSupport)

View File

@@ -13,6 +13,8 @@ set(SwiftCore_ENABLE_RUNTIME_FUNCTION_COUNTERS ON CACHE BOOL "")
set(SwiftCore_ENABLE_BACKDEPLOYMENT_SUPPORT ON CACHE BOOL "")
set(SwiftCore_ENABLE_FILESYSTEM_SUPPORT ON CACHE BOOL "")
set(SwiftCore_ENABLE_ONONESUPPORT OFF CACHE BOOL "")
set(SwiftCore_INSTALL_NESTED_SUBDIR OFF CACHE BOOL "")
set(CMAKE_CXX_FLAGS_MINSIZEREL "-Os -g -DNDEBUG" CACHE STRING "")

View File

@@ -78,15 +78,11 @@ set(CoreLibs
CompatibilityOverride
stubs
CommandLineSupport
core)
core
SwiftOnoneSupport)
# Add these as we get them building
# core
# Concurrency
# SwiftOnoneSUpport
# CommandLineSupport
# Demangling
# runtime)
foreach(library ${CoreLibs})
copy_library_sources(${library} "public" "Core")