Skip to content

Commit 9a948a9

Browse files
authored
Merge branch 'main' into mchiu/freebsd
2 parents ec41711 + c4ee4d9 commit 9a948a9

File tree

2,716 files changed

+109389
-42970
lines changed

Some content is hidden

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

2,716 files changed

+109389
-42970
lines changed

.github/CODEOWNERS

Lines changed: 69 additions & 62 deletions
Large diffs are not rendered by default.

CHANGELOG.md

Lines changed: 82 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,82 @@
55
66
## Swift 6.2
77

8+
* The Swift compiler no longer diagnoses references to declarations that are
9+
potentially unavailable because the platform version might not be new enough
10+
when those references occur inside of contexts that are also unavailable to
11+
that platform. This addresses a long-standing nuisance for multi-platform
12+
code. However, there is also a chance that existing source code may become
13+
ambiguous as a result:
14+
15+
```swift
16+
struct A {}
17+
struct B {}
18+
19+
func potentiallyAmbiguous(_: A) {}
20+
21+
@available(macOS 99, *)
22+
func potentiallyAmbiguous(_: B) {}
23+
24+
@available(macOS, unavailable)
25+
func unavailableOnMacOS() {
26+
potentiallyAmbiguous(.init()) // error: ambiguous use of 'init()'
27+
}
28+
```
29+
30+
Code that is now ambiguous as a result should likely be restructured since
31+
disambiguation based on platform introduction alone has never been a reliable
32+
strategy, given that the code would eventually become ambiguous anyways when
33+
the deployment target is raised.
34+
35+
* [SE-0470][]:
36+
A protocol conformance can be isolated to a specific global actor, meaning that the conformance can only be used by code running on that actor. Isolated conformances are expressed by specifying the global actor on the conformance itself:
37+
38+
```swift
39+
protocol P {
40+
func f()
41+
}
42+
43+
@MainActor
44+
class MyType: @MainActor P {
45+
/*@MainActor*/ func f() {
46+
// must be called on the main actor
47+
}
48+
}
49+
```
50+
51+
Swift will produce diagnostics if the conformance is directly accessed in code that isn't guaranteed to execute in the same global actor. For example:
52+
53+
```swift
54+
func acceptP<T: P>(_ value: T) { }
55+
56+
/*nonisolated*/ func useIsolatedConformance(myType: MyType) {
57+
acceptP(myType) // error: main actor-isolated conformance of 'MyType' to 'P' cannot be used in nonisolated context
58+
}
59+
```
60+
61+
To address such issues, only use an isolated conformance from code that executes on the same global actor.
62+
63+
* [SE-0419][]:
64+
Introduced the new `Runtime` module, which contains a public API that can
65+
generate backtraces, presently supported on macOS and Linux. Capturing a
66+
backtrace is as simple as
67+
68+
```swift
69+
import Runtime
70+
71+
func foo() {
72+
// Without symbols
73+
let backtrace = try! Backtrace.capture()
74+
75+
print(backtrace)
76+
77+
// With symbol lookup
78+
let symbolicated = backtrace.symbolicated()!
79+
80+
print(symbolicated)
81+
}
82+
```
83+
884
* [SE-0458][]:
985
Introduced an opt-in mode for strict checking of memory safety, which can be
1086
enabled with the compiler flag `-strict-memory-safety`. In this mode,
@@ -13,12 +89,12 @@
1389

1490
```swift
1591
func evilMalloc(size: Int) -> Int {
16-
// warning: call to global function 'malloc' involves unsafe type 'UnsafeMutableRawPointer'
92+
// use of global function 'malloc' involves unsafe type 'UnsafeMutableRawPointer'
1793
return Int(bitPattern: malloc(size))
1894
}
1995
```
2096

21-
These warnings are in their own diagnostic group (`Unsafe`) and can
97+
These warnings are in their own diagnostic group (`StrictMemorySafety`) and can
2298
be suppressed by ackwnowledging the memory-unsafe behavior, for
2399
example with an `unsafe` expression:
24100

@@ -371,7 +447,7 @@ And the module structure to support such applications looks like this:
371447

372448
* [SE-0430][]:
373449

374-
Region Based Isolation is now extended to enable the application of an
450+
Region-Based Isolation is now extended to enable the application of an
375451
explicit `sending` annotation to function parameters and results. A function
376452
parameter or result that is annotated with `sending` is required to be
377453
disconnected at the function boundary and thus possesses the capability of
@@ -409,7 +485,7 @@ And the module structure to support such applications looks like this:
409485

410486
func useValue() {
411487
let x = NonSendableType()
412-
let a = await MyActor(x) // Error without Region Based Isolation!
488+
let a = await MyActor(x) // Error without Region-Based Isolation!
413489
}
414490
```
415491

@@ -10703,13 +10779,15 @@ using the `.dynamicType` member to retrieve the type of an expression should mig
1070310779
[SE-0432]: https://github.com/apple/swift-evolution/blob/main/proposals/0432-noncopyable-switch.md
1070410780
[SE-0430]: https://github.com/apple/swift-evolution/blob/main/proposals/0430-transferring-parameters-and-results.md
1070510781
[SE-0418]: https://github.com/apple/swift-evolution/blob/main/proposals/0418-inferring-sendable-for-methods.md
10782+
[SE-0419]: https://github.com/swiftlang/swift-evolution/blob/main/proposals/0419-backtrace-api.md
1070610783
[SE-0423]: https://github.com/apple/swift-evolution/blob/main/proposals/0423-dynamic-actor-isolation.md
1070710784
[SE-0424]: https://github.com/apple/swift-evolution/blob/main/proposals/0424-custom-isolation-checking-for-serialexecutor.md
1070810785
[SE-0428]: https://github.com/apple/swift-evolution/blob/main/proposals/0428-resolve-distributed-actor-protocols.md
1070910786
[SE-0431]: https://github.com/apple/swift-evolution/blob/main/proposals/0431-isolated-any-functions.md
1071010787
[SE-0442]: https://github.com/swiftlang/swift-evolution/blob/main/proposals/0442-allow-taskgroup-childtaskresult-type-to-be-inferred.md
1071110788
[SE-0444]: https://github.com/swiftlang/swift-evolution/blob/main/proposals/0444-member-import-visibility.md
1071210789
[SE-0458]: https://github.com/swiftlang/swift-evolution/blob/main/proposals/0458-strict-memory-safety.md
10790+
[SE-0470]: https://github.com/swiftlang/swift-evolution/blob/main/proposals/0470-isolated-conformances.md
1071310791
[#64927]: <https://github.com/apple/swift/issues/64927>
1071410792
[#42697]: <https://github.com/apple/swift/issues/42697>
1071510793
[#42728]: <https://github.com/apple/swift/issues/42728>

CMakeLists.txt

Lines changed: 40 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -487,6 +487,9 @@ set(SWIFT_NATIVE_CLANG_TOOLS_PATH "" CACHE STRING
487487
set(SWIFT_NATIVE_SWIFT_TOOLS_PATH "" CACHE STRING
488488
"Path to the directory that contains Swift tools that are executable on the build machine")
489489

490+
set(SWIFT_WASI_SYSROOT_PATH "" CACHE PATH
491+
"Path to the directory that contains WASI Sysroot")
492+
490493
option(SWIFT_STDLIB_ENABLE_SIB_TARGETS
491494
"Should we generate sib targets for the stdlib or not?"
492495
FALSE)
@@ -572,6 +575,17 @@ set(SWIFT_DARWIN_XCRUN_TOOLCHAIN "XcodeDefault" CACHE STRING
572575
set(SWIFT_DARWIN_STDLIB_INSTALL_NAME_DIR "/usr/lib/swift" CACHE STRING
573576
"The directory of the install_name for standard library dylibs")
574577

578+
#
579+
# User-configurable OpenBSD-specific options.
580+
#
581+
582+
option(SWIFT_OPENBSD_BTCFI
583+
"Emit branch target identification instructions and sign return addresses when available"
584+
FALSE)
585+
if(SWIFT_OPENBSD_BTCFI)
586+
add_definitions("-DSWIFT_OPENBSD_BTCFI")
587+
endif()
588+
575589
# We don't want to use the same install_name_dir as the standard library which
576590
# will be installed in /usr/lib/swift. These private libraries should continue
577591
# to use @rpath for now.
@@ -1629,7 +1643,7 @@ if(SWIFT_ENABLE_NEW_RUNTIME_BUILD)
16291643

16301644
DEPENDS PopulateRuntimeSourceDir
16311645
CMAKE_ARGS
1632-
-DCMAKE_INSTALL_LIBDIR:FILEPATH=lib/swift/${SWIFT_SDK_${sdk}_LIB_SUBDIR}/${arch}
1646+
-DCMAKE_INSTALL_LIBDIR:FILEPATH=lib
16331647
# Compiler will see mismatched swift modules and fail initial checks
16341648
-DCMAKE_Swift_COMPILER_WORKS:BOOLEAN=YES
16351649
-DBUILD_SHARED_LIBS:BOOLEAN=YES # TODO: Make this configurable
@@ -1645,12 +1659,34 @@ if(SWIFT_ENABLE_NEW_RUNTIME_BUILD)
16451659
-DCMAKE_CXX_COMPILER_TARGET:STRING=${stdlib_target_triple}
16461660
-DCMAKE_COLOR_DIAGNOSTICS:BOOLEAN=${CMAKE_COLOR_DIAGNOSTICS}
16471661
-DCMAKE_MAKE_PROGRAM=${CMAKE_MAKE_PROGRAM}
1648-
-DSwiftCore_PLATFORM_SUBDIR=${SWIFT_SDK_${sdk}_LIB_SUBDIR}
1649-
-DSwiftCore_ARCH_SUBDIR=${arch}
1662+
-DSwiftCore_INSTALL_NESTED_SUBDIR=YES
16501663
-DSwiftCore_ENABLE_CONCURRENCY=YES)
16511664
if(NOT ${CMAKE_CROSSCOMPILING})
1652-
add_dependencies("${stdlib_target}" swift-frontend)
1665+
add_dependencies("${stdlib_target}-core" swift-frontend)
16531666
endif()
1667+
1668+
ExternalProject_Get_Property("${stdlib_target}-core" INSTALL_DIR)
1669+
1670+
ExternalProject_Add("${stdlib_target}-Supplemental"
1671+
SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/Runtimes/Supplemental"
1672+
DEPENDS "${stdlib_target}-core"
1673+
INSTALL_DIR "${INSTALL_DIR}"
1674+
INSTALL_COMMAND ""
1675+
LIST_SEPARATOR "|"
1676+
CMAKE_ARGS
1677+
-DSwift_ENABLE_RUNTIMES=StringProcessing
1678+
-DBUILD_SHARED_LIBS=YES
1679+
-DCMAKE_Swift_COMPILER_WORKS:BOOLEAN=YES
1680+
-DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE}
1681+
-DCMAKE_INSTALL_PREFIX:FILEPATH=${INSTALL_DIR}
1682+
-DCMAKE_Swift_COMPILER:FILEPATH=$<IF:$<BOOL:${CMAKE_CROSSCOMPILING}>,${CMAKE_Swift_COMPILER},$<PATH:REPLACE_FILENAME,$<TARGET_FILE:swift-frontend>,swiftc>>
1683+
-DCMAKE_C_COMPILER:FILEPATH=${CMAKE_C_COMPILER}
1684+
-DCMAKE_CXX_COMPILER:FILEPATH=${CMAKE_CXX_COMPILER}
1685+
-DCMAKE_Swift_COMPILER_TARGET:STRING=${stdlib_target_triple}
1686+
-DCMAKE_C_COMPILER_TARGET:STRING=${stdlib_target_triple}
1687+
-DCMAKE_CXX_COMPILER_TARGET:STRING=${stdlib_target_triple}
1688+
-DCMAKE_COLOR_DIAGNOSTICS:BOOLEAN=${CMAKE_COLOR_DIAGNOSTICS}
1689+
-DCMAKE_MAKE_PROGRAM=${CMAKE_MAKE_PROGRAM})
16541690
endforeach()
16551691
endforeach()
16561692
endif()

README.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
| | **Architecture** | **Build** |
1010
|---|:---:|:---:|
11-
| **macOS** | x86_64 |[![Build Status](https://ci.swift.org/job/oss-swift-package-macos/lastCompletedBuild/badge/icon)](https://ci.swift.org/job/oss-swift-package-macos)|
11+
| **macOS** | Universal |[![Build Status](https://ci.swift.org/job/oss-swift-package-macos/lastCompletedBuild/badge/icon)](https://ci.swift.org/job/oss-swift-package-macos)|
1212
| **Ubuntu 20.04** | x86_64 |[![Build Status](https://ci.swift.org/job/oss-swift-package-ubuntu-20_04/lastCompletedBuild/badge/icon)](https://ci.swift.org/job/oss-swift-package-ubuntu-20_04)|
1313
| **Ubuntu 20.04** | AArch64 |[![Build Status](https://ci.swift.org/job/oss-swift-package-ubuntu-20_04-aarch64/lastCompletedBuild/badge/icon)](https://ci.swift.org/job/oss-swift-package-ubuntu-20_04-aarch64)|
1414
| **Ubuntu 22.04** | x86_64 |[![Build Status](https://ci.swift.org/job/oss-swift-package-ubuntu-22_04/lastCompletedBuild/badge/icon)](https://ci.swift.org/job/oss-swift-package-ubuntu-22_04)|
@@ -20,8 +20,6 @@
2020
| **Universal Base Image 9** | x86_64 |[![Build Status](https://ci.swift.org/job/oss-swift-package-ubi-9/lastCompletedBuild/badge/icon)](https://ci.swift.org/job/oss-swift-package-ubi-9)|
2121
| **Debian 12** | x86_64 |[![Build Status](https://ci.swift.org/job/oss-swift-package-debian-12/lastCompletedBuild/badge/icon)](https://ci.swift.org/job/oss-swift-package-debian-12)|
2222
| **Debian 12** | AArch64 |[![Build Status](https://ci.swift.org/job/oss-swift-package-debian-12-aarch64/lastCompletedBuild/badge/icon)](https://ci.swift.org/job/oss-swift-package-debian-12-aarch64)|
23-
| **Fedora 39** | x86_64 |[![Build Status](https://ci.swift.org/job/oss-swift-package-fedora-39/lastCompletedBuild/badge/icon)](https://ci.swift.org/job/oss-swift-package-fedora-39)|
24-
| **Fedora 39** | AArch64 |[![Build Status](https://ci.swift.org/job/oss-swift-package-fedora-39-aarch64/lastCompletedBuild/badge/icon)](https://ci.swift.org/job/oss-swift-package-fedora-39-aarch64)|
2523
| **Windows 10** | x86_64 |[![Build Status](https://ci-external.swift.org/job/swift-main-windows-toolchain/lastCompletedBuild/badge/icon)](https://ci-external.swift.org/job/swift-main-windows-toolchain)|
2624
| **Windows 10** | ARM64 |[![Build Status](https://ci-external.swift.org/job/swift-main-windows-toolchain-arm64/lastCompletedBuild/badge/icon)](https://ci-external.swift.org/job/swift-main-windows-toolchain-arm64)|
2725

Runtimes/Core/CMakeLists.txt

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,14 @@
2929
# -- Will need shadow invocations to generate swiftmodules for Swift parts
3030
# Install *.abi.json, swiftdoc, and swiftsourceinfo
3131

32-
cmake_minimum_required(VERSION 3.26...3.29)
32+
cmake_minimum_required(VERSION 3.29)
3333

3434
set(CMAKE_C_VISIBILITY_PRESET "hidden")
3535
set(CMAKE_CXX_VISIBILITY_PRESET "hidden")
3636
set(CMAKE_VISIBILITY_INLINES_HIDDEN YES)
3737

38+
set(CMAKE_POSITION_INDEPENDENT_CODE YES)
39+
3840
set(SwiftCore_CMAKE_MODULES_DIR "${CMAKE_SOURCE_DIR}/cmake/modules")
3941
list(APPEND CMAKE_MODULE_PATH ${SwiftCore_CMAKE_MODULES_DIR})
4042

@@ -80,6 +82,7 @@ include(AvailabilityMacros)
8082
include(CompilerSettings)
8183
include(DefaultSettings)
8284
include(EmitSwiftInterface)
85+
include(InstallSwiftInterface)
8386
include(PlatformInfo)
8487
include(gyb)
8588
include(ResourceEmbedding)
@@ -101,7 +104,6 @@ defaulted_option(SwiftCore_ENABLE_OBJC_INTEROP "Enable runtime ObjC interop")
101104
defaulted_option(SwiftCore_ENABLE_TYPE_PRINTING "Enable printing type names")
102105
defaulted_option(SwiftCore_ENABLE_VECTOR_TYPES "Enable vector support")
103106
defaulted_option(SwiftCore_ENABLE_REFLECTION "Enable runtime support for mirrors and reflection support")
104-
defaulted_option(SwiftCore_ENABLE_COMMANDLINE_SUPPORT "Enable command line argument support")
105107
defaulted_option(SwiftCore_ENABLE_RUNTIME_FUNCTION_COUNTERS "Enable runtime function counter support")
106108
defaulted_option(SwiftCore_ENABLE_STDIN "Enable functions that use stdin support")
107109
defaulted_option(SwiftCore_ENABLE_ENVIRONMENT "Enable environment variable support")
@@ -113,6 +115,7 @@ defaulted_option(SwiftCore_ENABLE_BACKDEPLOYMENT_SUPPORT "Add symbols for runtim
113115
defaulted_option(SwiftCore_ENABLE_STDLIB_TRACING "Enable tracing in the runtime. Assumes the presence of os_log(3) and the os_signpost(3) API.")
114116
defaulted_option(SwiftCore_ENABLE_CONCURRENCY "Enable Concurrency runtime support")
115117
defaulted_set(SwiftCore_CONCURRENCY_GLOBAL_EXECUTOR STRING "Default Concurrency global executor implementation")
118+
option(SwiftCore_ENABLE_COMMANDLINE_SUPPORT "Enable command line argument support" ON)
116119
option(SwiftCore_ENABLE_UNICODE_DATA "Include unicode data in Swift runtimes" ON)
117120
option(SwiftCore_ENABLE_SHORT_MANGLING_LOOKUPS "Build with fast-path context descriptor lookups based on well-known short manglings." ON)
118121
option(SwiftCore_ENABLE_FILESYSTEM_SUPPORT "Build for systems that have a filesystem" ON)
@@ -157,7 +160,7 @@ add_compile_definitions(
157160
$<$<BOOL:${SwiftCore_HAS_DARWIN_LIBMALLOC}>:-DSWIFT_STDLIB_HAS_DARWIN_LIBMALLOC> # Anything that includes include/swift/Runtime/Config.h
158161
$<$<COMPILE_LANGUAGE:C,CXX>:-DSWIFT_THREADING_${SwiftCore_THREADING_PACKAGE}>
159162
$<$<COMPILE_LANGUAGE:C,CXX>:-DSWIFT_RUNTIME_ENABLE_LEAK_CHECKER=$<BOOL:${SwiftCore_ENABLE_RUNTIME_LEAK_CHECKER}>>
160-
$<$<COMPILE_LANGUAGE:C,CXX>:-DSWIFT_RUNTIME_CLOBBER_FREED_OBJECTS=$<BOOL:${SwiftCore_ENABLE_CLOBBER_FREED_OBJECTS}>>)
163+
$<$<BOOL:${SwiftCore_ENABLE_CLOBBER_FREED_OBJECTS}>:-DSWIFT_RUNTIME_CLOBBER_FREED_OBJECTS>)
161164

162165
add_compile_options(
163166
$<$<COMPILE_LANGUAGE:CXX>:-fno-rtti>
@@ -174,6 +177,7 @@ add_compile_options(
174177
add_link_options($<$<PLATFORM_ID:Windows>:LINKER:/WX>)
175178

176179
add_compile_options(
180+
$<$<COMPILE_LANGUAGE:Swift>:-explicit-module-build>
177181
"$<$<COMPILE_LANGUAGE:Swift>:-nostdlibimport>"
178182
"$<$<COMPILE_LANGUAGE:Swift>:SHELL:-library-level api>"
179183
"$<$<COMPILE_LANGUAGE:Swift>:SHELL:-runtime-compatibility-version none>"
@@ -205,8 +209,10 @@ add_subdirectory(Demangling)
205209
add_subdirectory(Threading)
206210
add_subdirectory(runtime)
207211
add_subdirectory(stubs)
208-
add_subdirectory(CommandLineSupport)
209212
add_subdirectory(core)
213+
if(SwiftCore_ENABLE_COMMANDLINE_SUPPORT)
214+
add_subdirectory(CommandLineSupport)
215+
endif()
210216
if(SwiftCore_ENABLE_ONONESUPPORT)
211217
add_subdirectory(SwiftOnoneSupport)
212218
endif()
@@ -223,12 +229,12 @@ install(EXPORT SwiftCoreTargets
223229
COMPONENT SwiftCore_cmake)
224230
include(CMakePackageConfigHelpers)
225231
configure_package_config_file("${CMAKE_CURRENT_SOURCE_DIR}/cmake/interface/SwiftCoreConfig.cmake.in"
226-
"${CMAKE_CURRENT_BINARY_DIR}/cmake/SwiftCoreConfig.cmake"
232+
"${CMAKE_CURRENT_BINARY_DIR}/cmake/SwiftCore/SwiftCoreConfig.cmake"
227233
INSTALL_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/SwiftCore")
228-
write_basic_package_version_file("${CMAKE_CURRENT_BINARY_DIR}/cmake/SwiftCoreConfigVersion.cmake"
234+
write_basic_package_version_file("${CMAKE_CURRENT_BINARY_DIR}/cmake/SwiftCore/SwiftCoreConfigVersion.cmake"
229235
VERSION "${PROJECT_VERSION}"
230236
COMPATIBILITY ExactVersion)
231237
install(FILES
232-
"${CMAKE_CURRENT_BINARY_DIR}/cmake/SwiftCoreConfig.cmake"
233-
"${CMAKE_CURRENT_BINARY_DIR}/cmake/SwiftCoreConfigVersion.cmake"
238+
"${CMAKE_CURRENT_BINARY_DIR}/cmake/SwiftCore/SwiftCoreConfig.cmake"
239+
"${CMAKE_CURRENT_BINARY_DIR}/cmake/SwiftCore/SwiftCoreConfigVersion.cmake"
234240
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/SwiftCore")
Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,9 @@
1-
if(SwiftCore_ENABLE_COMMANDLINE_SUPPORT)
2-
add_library(swiftCommandLineSupport STATIC CommandLine.cpp)
3-
target_include_directories(swiftCommandLineSupport PRIVATE
4-
"${SwiftCore_SWIFTC_SOURCE_DIR}/include"
5-
"${PROJECT_BINARY_DIR}/include")
6-
target_compile_definitions(swiftCommandLineSupport PUBLIC
7-
-DSWIFT_STDLIB_HAS_COMMANDLINE)
8-
9-
target_link_libraries(swiftCommandLineSupport PRIVATE
10-
swiftShims)
11-
12-
if(NOT BUILD_SHARED_LIBS)
13-
install(TARGETS swiftCommandLineSupport
14-
EXPORT SwiftCoreTargets
15-
COMPONENT SwiftCore_runtime)
16-
endif()
17-
endif()
1+
# TODO(etcwilde) migrate this into subdir subdirectory once the migration is
2+
# completed.
3+
target_sources(swiftCore PRIVATE
4+
CommandLine.cpp)
5+
target_compile_definitions(swiftCore PUBLIC
6+
-DSWIFT_STDLIB_HAS_COMMANDLINE)
7+
target_include_directories(swiftCore PRIVATE
8+
"${SwiftCore_SWIFTC_SOURCE_DIR}/include"
9+
"${PROJECT_BINARY_DIR}/include")

0 commit comments

Comments
 (0)