Skip to content

Commit d681126

Browse files
committed
Merge commit '665515c781999a81094bbe4f8302a7cb1a6a6b39' into mchiu/freebsd
2 parents 84ee0af + 665515c commit d681126

File tree

670 files changed

+11254
-3959
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

670 files changed

+11254
-3959
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,3 +97,4 @@ Runtimes/**/*.inc
9797
Runtimes/**/*.json
9898
Runtimes/**/*.modulemap
9999
Runtimes/**/*.in
100+
!Runtimes/**/*.cmake.in

CMakeLists.txt

Lines changed: 15 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,10 @@ option(SWIFT_STDLIB_ASSERTIONS
464464
"Enable internal checks for the Swift standard library (useful for debugging the library itself, does not affect checks required for safety)"
465465
"${SWIFT_STDLIB_ASSERTIONS_default}")
466466

467+
option(SWIFT_STDLIB_ENABLE_STRICT_AVAILABILITY
468+
"Enable strict availability; this will cause things to break at desk or in CI if the host OS is a lower version than some `@availability` annotations in the runtime code"
469+
FALSE)
470+
467471
option(SWIFT_BUILD_RUNTIME_WITH_HOST_COMPILER
468472
"Use the host compiler and not the internal clang to build the swift runtime"
469473
FALSE)
@@ -870,12 +874,7 @@ include(CMakePushCheckState)
870874

871875
# Print out path and version of any installed commands
872876
message(STATUS "CMake (${CMAKE_COMMAND}) Version: ${CMAKE_VERSION}")
873-
if(XCODE)
874-
set(version_flag -version)
875-
else()
876-
set(version_flag --version)
877-
endif()
878-
execute_process(COMMAND ${CMAKE_MAKE_PROGRAM} ${version_flag}
877+
execute_process(COMMAND ${CMAKE_MAKE_PROGRAM} --version
879878
OUTPUT_VARIABLE _CMAKE_MAKE_PROGRAM_VERSION
880879
OUTPUT_STRIP_TRAILING_WHITESPACE)
881880
message(STATUS "CMake Make Program (${CMAKE_MAKE_PROGRAM}) Version: ${_CMAKE_MAKE_PROGRAM_VERSION}")
@@ -1145,14 +1144,6 @@ endif()
11451144
# Configure SDKs.
11461145
#
11471146

1148-
if(XCODE)
1149-
# FIXME: It used to be the case that Xcode would force
1150-
# -m${platform}-version-min flags that would conflict with those computed
1151-
# by build-script. version-min flags are deprecated in favor of -target since
1152-
# clang-11, so we might be able to undo this.
1153-
set(SWIFT_SDKS "OSX")
1154-
endif()
1155-
11561147
# FIXME: the parameters we specify in SWIFT_SDKS are lacking architecture specifics,
11571148
# so we need to hard-code it. For example, the SDK for Android is just 'ANDROID',
11581149
# and we have to specify SWIFT_SDK_ANDROID_ARCHITECTURES separately.
@@ -1408,8 +1399,9 @@ endif()
14081399

14091400
if(SWIFT_BUILD_STDLIB OR SWIFT_BUILD_SDK_OVERLAY)
14101401
message(STATUS "Building Swift standard library and overlays for SDKs: ${SWIFT_SDKS}")
1411-
message(STATUS " Build type: ${SWIFT_STDLIB_BUILD_TYPE}")
1412-
message(STATUS " Assertions: ${SWIFT_STDLIB_ASSERTIONS}")
1402+
message(STATUS " Build type: ${SWIFT_STDLIB_BUILD_TYPE}")
1403+
message(STATUS " Assertions: ${SWIFT_STDLIB_ASSERTIONS}")
1404+
message(STATUS " Strict availability: ${SWIFT_STDLIB_ENABLE_STRICT_AVAILABILITY}")
14131405
message(STATUS "")
14141406

14151407
message(STATUS "Building Swift runtime with:")
@@ -1594,22 +1586,6 @@ swift_install_in_component(FILES "LICENSE.txt"
15941586
DESTINATION "share/swift"
15951587
COMPONENT license)
15961588

1597-
# Add a documentation target so that documentation shows up in the
1598-
# Xcode project.
1599-
if(XCODE)
1600-
add_custom_target(Documentation
1601-
SOURCES
1602-
README.md
1603-
docs)
1604-
1605-
file(GLOB SWIFT_TOPLEVEL_HEADERS
1606-
${CMAKE_CURRENT_SOURCE_DIR}/include/swift${dir}/*.h
1607-
${CMAKE_CURRENT_SOURCE_DIR}/include/swift${dir}/*.td
1608-
${CMAKE_CURRENT_SOURCE_DIR}/include/swift${dir}/*.def)
1609-
add_custom_target(Miscellaneous
1610-
SOURCES ${SWIFT_TOPLEVEL_HEADERS})
1611-
endif()
1612-
16131589
# New standard library build
16141590
option(SWIFT_ENABLE_NEW_RUNTIME_BUILD "Build Swift runtimes with new build system" OFF)
16151591
if(SWIFT_ENABLE_NEW_RUNTIME_BUILD)
@@ -1637,6 +1613,12 @@ if(SWIFT_ENABLE_NEW_RUNTIME_BUILD)
16371613
set(stdlib_deployment_version_flag -DCMAKE_OSX_DEPLOYMENT_TARGET=${SWIFT_SDK_${sdk}_DEPLOYMENT_VERSION})
16381614
endif()
16391615

1616+
if(sdk STREQUAL "OSX" AND SWIFT_SDK_${sdk}_DEPLOYMENT_VERSION VERSION_LESS "10.15")
1617+
set(build_concurrency NO)
1618+
else()
1619+
set(build_concurrency YES)
1620+
endif()
1621+
16401622
ExternalProject_Add("${stdlib_target}-core"
16411623
SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/Runtimes/Core"
16421624
# TODO: Add this once we're ready to start swapping out the libraries
@@ -1662,7 +1644,7 @@ if(SWIFT_ENABLE_NEW_RUNTIME_BUILD)
16621644
-DCMAKE_COLOR_DIAGNOSTICS:BOOLEAN=${CMAKE_COLOR_DIAGNOSTICS}
16631645
-DCMAKE_MAKE_PROGRAM=${CMAKE_MAKE_PROGRAM}
16641646
-DSwiftCore_INSTALL_NESTED_SUBDIR=YES
1665-
-DSwiftCore_ENABLE_CONCURRENCY=YES)
1647+
-DSwiftCore_ENABLE_CONCURRENCY=${build_concurrency})
16661648
if(NOT ${CMAKE_CROSSCOMPILING})
16671649
add_dependencies("${stdlib_target}-core" swift-frontend)
16681650
endif()

Runtimes/Core/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ set(SwiftCore_VENDOR_MODULE_DIR "${SwiftCore_CMAKE_MODULES_DIR}/vendor"
7878
include(GNUInstallDirs)
7979
include(CheckSymbolExists)
8080
include(CheckIncludeFileCXX)
81-
include(AvailabilityMacros)
8281
include(CompilerSettings)
8382
include(DefaultSettings)
8483
include(EmitSwiftInterface)
@@ -87,6 +86,7 @@ include(PlatformInfo)
8786
include(gyb)
8887
include(ResourceEmbedding)
8988
include(CatalystSupport)
89+
include(AvailabilityMacros)
9090

9191
check_symbol_exists("asl_log" "asl.h" SwiftCore_HAS_ASL)
9292
check_symbol_exists("dladdr" "dlfcn.h" SwiftCore_HAS_DLADDR)
@@ -126,6 +126,7 @@ defaulted_option(SwiftCore_ENABLE_BACKTRACING "Enable backtracing runtime suppor
126126
defaulted_set(SwiftCore_BACKTRACER_PATH STRING "Set a fixed path to the Swift backtracer")
127127
defaulted_option(SwiftCore_ENABLE_FATALERROR_BACKTRACE "Build stdlib fatalError with backtrace output")
128128
defaulted_option(SwiftCore_ENABLE_PRESPECIALIZATION "Enable generic metadata prespecialization")
129+
defaulted_option(SwiftCore_ENABLE_STRICT_AVAILABILITY "Enable strict availability; this will cause things to break at desk or in CI if the host OS is a lower version than some `@availability` annotations in the runtime code")
129130

130131
option(SwiftCore_ENABLE_CLOBBER_FREED_OBJECTS "" OFF)
131132
option(SwiftCore_ENABLE_RUNTIME_LEAK_CHECKER "" OFF)

Runtimes/Core/cmake/caches/Vendors/Apple/apple-common.cmake

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ set(SwiftCore_ENABLE_VECTOR_TYPES ON CACHE BOOL "")
1212
set(SwiftCore_ENABLE_RUNTIME_FUNCTION_COUNTERS ON CACHE BOOL "")
1313
set(SwiftCore_ENABLE_BACKDEPLOYMENT_SUPPORT ON CACHE BOOL "")
1414
set(SwiftCore_ENABLE_FILESYSTEM_SUPPORT ON CACHE BOOL "")
15+
set(SwiftCore_ENABLE_STRICT_AVAILABILITY ON CACHE BOOL "")
16+
1517
set(SwiftCore_OPTIMIZATION_REMARKS "bitstream" CACHE STRING "")
1618

1719
set(SwiftCore_INSTALL_NESTED_SUBDIR OFF CACHE BOOL "")

Runtimes/Core/cmake/modules/AvailabilityMacros.cmake

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,39 @@ configure_file("${SwiftCore_SWIFTC_SOURCE_DIR}/utils/availability-macros.def"
44
file(STRINGS "${CMAKE_CURRENT_BINARY_DIR}/availability-macros.def" availability_defs)
55
list(FILTER availability_defs EXCLUDE REGEX "^\\s*(#.*)?$")
66
foreach(def ${availability_defs})
7-
add_compile_options("$<$<COMPILE_LANGUAGE:Swift>:SHELL:-Xfrontend -define-availability -Xfrontend \"${def}\">")
7+
list(APPEND availability_definitions "-Xfrontend -define-availability -Xfrontend \"${def}\"")
8+
9+
if("${def}" MATCHES "SwiftStdlib .*")
10+
# For each SwiftStdlib x.y, also define StdlibDeploymentTarget x.y, which,
11+
# will expand to the current `-target` platform if the macro defines a
12+
# newer platform as its availability.
13+
#
14+
# There is a setting, SwiftCore_ENABLE_STRICT_AVAILABILITY, which if set
15+
# ON will cause us to use the "proper" availability instead.
16+
string(REPLACE "SwiftStdlib" "StdlibDeploymentTarget" current "${def}")
17+
if(NOT SwiftCore_ENABLE_STRICT_AVAILABILITY AND SwiftCore_SWIFT_AVAILABILITY_PLATFORM)
18+
if("${SwiftCore_SWIFT_AVAILABILITY_PLATFORM}" STREQUAL "macOS" AND "${SwiftCore_VARIANT_AVAILABILITY_PLATFORM}" STREQUAL "iOS")
19+
string(REGEX MATCH "iOS ([0-9]+(\.[0-9]+)+)" ios_platform_version "${def}")
20+
string(REGEX MATCH "[0-9]+(\.[0-9]+)+" ios_version "${ios_platform_version}")
21+
string(REGEX MATCH "macOS ([0-9]+(\.[0-9]+)+)" macos_platform_version "${def}")
22+
string(REGEX MATCH "[0-9]+(\.[0-9]+)+" macos_version "${macos_platform_version}")
23+
if((NOT macos_version STREQUAL "9999" OR NOT ios_version STREQUAL "9999") AND (macos_version VERSION_GREATER CMAKE_OSX_DEPLOYMENT_TARGET OR ios_version VERSION_GREATER SwiftCore_VARIANT_DEPLOYMENT_VERSION))
24+
string(REGEX REPLACE ":.*" ": macOS ${CMAKE_OSX_DEPLOYMENT_VERSION}, iOS ${SwiftCore_VARIANT_DEPLOYMENT_VERSION}" current "${current}")
25+
endif()
26+
else()
27+
string(REGEX MATCH "${SwiftCore_SWIFT_AVAILABILITY_PLATFORM} ([0-9]+(\.[0-9]+)+)" platform_version "${def}")
28+
string(REGEX MATCH "[0-9]+(\.[0-9]+)+" version "${platform_version}")
29+
if(NOT version STREQUAL "9999" AND version VERSION_GREATER CMAKE_OSX_DEPLOYMENT_TARGET)
30+
string(REGEX REPLACE ":.*" ":${SwiftCore_SWIFT_AVAILABILITY_PLATFORM} ${CMAKE_OSX_DEPLOYMENT_TARGET}" current "${current}")
31+
endif()
32+
endif()
33+
endif()
34+
list(APPEND availability_definitions "-Xfrontend -define-availability -Xfrontend \"${current}\"")
35+
endif()
836
endforeach()
37+
38+
list(JOIN availability_definitions "\n" availability_definitions)
39+
file(GENERATE
40+
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/availability-macros.rsp"
41+
CONTENT "${availability_definitions}")
42+
add_compile_options("$<$<COMPILE_LANGUAGE:Swift>:SHELL:${CMAKE_Swift_RESPONSE_FILE_FLAG}${CMAKE_CURRENT_BINARY_DIR}/availability-macros.rsp>")

Runtimes/Core/cmake/modules/CatalystSupport.cmake

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,12 @@ if(SwiftCore_COMPILER_VARIANT_TARGET)
3434
set(SwiftCore_VARIANT_MODULE_TRIPLE "${module_triple}" CACHE STRING "Triple used for installed swift{module,interface} files for the target variant")
3535
mark_as_advanced(SwiftCore_VARIANT_MODULE_TRIPLE)
3636
message(CONFIGURE_LOG "Swift target variant module triple: ${module_triple}")
37+
38+
string(JSON triple GET "${target_info_json}" "target" "triple")
39+
if(triple MATCHES "apple-([a-zA-Z]+)([0-9]+[.0-9]*)-macabi")
40+
set(SwiftCore_VARIANT_DEPLOYMENT_VERSION "${CMAKE_MATCH_2}")
41+
mark_as_advanced(SwiftCore_VARIANT_DEPLOYMENT_VERSION)
42+
message(CONFIGURE_LOG "Swift target variant deployment version: ${SwiftCore_VARIANT_DEPLOYMENT_VERSION}")
43+
endif()
3744
endif()
3845
endif()

Runtimes/Core/cmake/modules/DefaultSettings.cmake

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ set(SwiftCore_ENABLE_BACKTRACING_default OFF) # TODO: enable this by default
1010
set(SwiftCore_ENABLE_STDIN_default ON)
1111
set(SwiftCore_ENABLE_TYPE_PRINTING_default ON)
1212

13+
set(SwiftCore_ENABLE_STRICT_AVAILABILITY_default OFF)
14+
1315
set(SwiftCore_BACKTRACER_PATH_default "")
1416

1517
# Provide a boolean option that a user can optionally enable.
@@ -19,7 +21,7 @@ macro(defaulted_option variable helptext)
1921
if(NOT DEFINED ${variable}_default)
2022
set(${variable}_default OFF)
2123
endif()
22-
option(${variable} ${helptext} ${${variable}_default})
24+
option(${variable} "${helptext}" ${${variable}_default})
2325
endmacro()
2426

2527
# Create a defaulted cache entry
@@ -50,6 +52,8 @@ elseif(CMAKE_SYSTEM_NAME STREQUAL "WASM")
5052
set(SwiftCore_CONCURRENCY_GLOBAL_EXECUTOR_default "none")
5153
elseif(LINUX OR ANDROID OR BSD)
5254
set(SwiftCore_OBJECT_FORMAT_default "elf")
55+
56+
set(SwiftCore_ENABLE_REFLECTION_default ON)
5357
set(SwiftCore_ENABLE_FATALERROR_BACKTRACE_default ON)
5458
if(LINUX)
5559
set(SwiftCore_THREADING_PACKAGE_default "LINUX")
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
set(SwiftCore_SIZEOF_POINTER @SwiftCore_SIZEOF_POINTER@)
2+
set(SwiftCore_MODULE_TRIPLE @SwiftCore_MODULE_TRIPLE@)
3+
set(SwiftCore_PLATFORM_SUBIDR @SwiftCore_PLATFORM_SUBIDR@)
4+
set(SwiftCore_ARCH_SUBDIR @SwiftCore_ARCH_SUBDIR@)
5+
6+
set(SwiftCore_SWIFT_AVAILABILITY_PLATFORM @SwiftCore_SWIFT_AVAILABILITY_PLATFORM@)
7+
8+
set(SwiftCore_PLATFORM_INFO_SET 1)

Runtimes/Core/cmake/modules/ExperimentalFeatures.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ add_compile_options(
44
"$<$<COMPILE_LANGUAGE:Swift>:SHELL:-enable-experimental-feature SE427NoInferenceOnExtension>"
55
"$<$<COMPILE_LANGUAGE:Swift>:SHELL:-enable-experimental-feature NonescapableTypes>"
66
"$<$<COMPILE_LANGUAGE:Swift>:SHELL:-enable-experimental-feature LifetimeDependence>"
7+
"$<$<COMPILE_LANGUAGE:Swift>:SHELL:-enable-experimental-feature InoutLifetimeDependence>"
78
"$<$<COMPILE_LANGUAGE:Swift>:SHELL:-enable-experimental-feature LifetimeDependenceMutableAccessors>"
89
"$<$<COMPILE_LANGUAGE:Swift>:SHELL:-enable-experimental-feature MemberImportVisibility>"
910
"$<$<COMPILE_LANGUAGE:Swift>:SHELL:-enable-experimental-feature TypedThrows>"

Runtimes/Core/cmake/modules/PlatformInfo.cmake

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
include("${PROJECT_BINARY_DIR}/build/DetectedPlatformInfo.cmake" OPTIONAL)
2+
3+
if(SwiftCore_PLATFORM_INFO_SET)
4+
return()
5+
endif()
6+
17
if(NOT SwiftCore_SIZEOF_POINTER)
28
set(SwiftCore_SIZEOF_POINTER "${CMAKE_SIZEOF_VOID_P}" CACHE STRING "Size of a pointer in bytes")
39
message(CONFIGURE_LOG "Stdlib Pointer size: ${CMAKE_SIZEOF_VOID_P}")
@@ -36,3 +42,51 @@ if(NOT SwiftCore_ARCH_SUBDIR)
3642

3743
message(CONFIGURE_LOG "Swift Arch: ${arch}")
3844
endif()
45+
46+
# Note: *moduleTriple* doesn't have an "x" on the end of "macos"; just to be
47+
# safe, we support both cases here.
48+
set(availability_platform_macos "macOS")
49+
set(availaiblity_platform_macosx "macOS")
50+
set(availability_platform_ios "iOS")
51+
set(availability_platform_watchos "watchOS")
52+
set(availability_platform_tvos "tvOS")
53+
set(availability_platform_xros "visionOS")
54+
set(availability_platform_bridgeos "bridgeOS")
55+
56+
if(NOT SwiftCore_SWIFT_AVAILABILITY_PLATFORM)
57+
if(SwiftCore_MODULE_TRIPLE MATCHES ".*-([^-]+)-simulator$")
58+
set(platform "${CMAKE_MATCH_1}")
59+
elseif(SwiftCore_MODULE_TRIPLE MATCHES ".*-([^-]+)-msvc$")
60+
set(platform "${CMAKE_MATCH_1}")
61+
elseif(SwiftCore_MODULE_TRIPLE MATCHES ".*-([^-]+)$")
62+
set(platform "${CMAKE_MATCH_1}")
63+
else()
64+
message(WARNING "Unable to extract platform name from triple ${SwiftCore_MODULE_TRIPLE}")
65+
endif()
66+
67+
if(availability_platform_${platform})
68+
set(SwiftCore_SWIFT_AVAILABILITY_PLATFORM "${availability_platform_${platform}}")
69+
else()
70+
set(SwiftCore_SWIFT_AVAILABILITY_PLATFORM "unknown")
71+
message(WARNING "Unknown platform ${platform} for availability")
72+
endif()
73+
endif()
74+
75+
set(SwiftCore_VARIANT_AVAILABILITY_PLATFORM "none")
76+
if(SwiftCore_VARIANT_MODULE_TRIPLE)
77+
if(SwiftCore_VARIANT_MODULE_TRIPLE MATCHES ".*-([^-]+)$")
78+
set(platform "${CMAKE_MATCH_1}")
79+
else()
80+
message(FATAL_ERROR "Unable to extract platform name from triple ${SwiftCore_VARIANT_MODULE_TRIPLE}")
81+
endif()
82+
83+
if(availability_platform_${platform})
84+
set(SwiftCore_VARIANT_AVAILABILITY_PLATFORM "${availability_platform_${platform}}")
85+
else()
86+
message(WARNING "Unknown platform ${platform} for variant availability")
87+
endif()
88+
endif()
89+
90+
configure_file("${CMAKE_CURRENT_LIST_DIR}/DetectedPlatformInfo.cmake.in"
91+
"${PROJECT_BINARY_DIR}/build/DetectedPlatformInfo.cmake"
92+
@ONLY)

0 commit comments

Comments
 (0)