Skip to content

Commit 89fb5ff

Browse files
authored
Merge branch 'main' into es-param
2 parents 06683cd + 77040ef commit 89fb5ff

File tree

880 files changed

+47861
-11796
lines changed

Some content is hidden

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

880 files changed

+47861
-11796
lines changed

CHANGELOG.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,21 @@ Swift 5.5
8484

8585
### 2021-09-20 (Xcode 13.0)
8686

87+
* [SE-0323][]:
88+
89+
The main function is executed with `MainActor` isolation applied, so functions
90+
and variables with `MainActor` isolation may be called and modified
91+
synchronously from the main function. If the main function is annotated with a
92+
global actor explicitly, it must be the main actor or an error is emitted. If
93+
no global actor annotation is present, the main function is implicitly run on
94+
the main actor.
95+
96+
The main function is executed synchronously up to the first suspension point.
97+
Any tasks enqueued by initializers in Objective-C or C++ will run after the
98+
main function runs to the first suspension point. At the suspension point, the
99+
main function suspends and the tasks are executed according to the Swift
100+
concurrency mechanisms.
101+
87102
* [SE-0313][]:
88103

89104
Parameters of actor type can be declared as `isolated`, which means that they
@@ -8745,6 +8760,7 @@ Swift 1.0
87458760
[SE-0315]: <https://github.com/apple/swift-evolution/blob/main/proposals/0315-placeholder-types.md>
87468761
[SE-0316]: <https://github.com/apple/swift-evolution/blob/main/proposals/0316-global-actors.md>
87478762
[SE-0324]: <https://github.com/apple/swift-evolution/blob/main/proposals/0324-c-lang-pointer-arg-conversion.md>
8763+
[SE-0323]: <https://github.com/apple/swift-evolution/blob/main/proposals/0323-async-main-semantics.md>
87488764

87498765
[SR-75]: <https://bugs.swift.org/browse/SR-75>
87508766
[SR-106]: <https://bugs.swift.org/browse/SR-106>

CMakeLists.txt

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,9 @@ cmake_dependent_option(LIBSWIFT_BUILD_MODE "How to build libswift. Possible valu
204204
HOSTTOOLS: libswift is built with a pre-installed toolchain
205205
BOOTSTRAPPING: libswift is built with a 2-stage bootstrapping process
206206
BOOTSTRAPPING-WITH-HOSTLIBS: libswift is built with a 2-stage bootstrapping process,
207-
but the compiler links against the host system swift libs (macOS only)"
207+
but the compiler links against the host system swift libs (macOS only)
208+
CROSSCOMPILE-WITH-HOSTLIBS: libswift is built with a bootstrapping-with-hostlibs compiled
209+
compiler, provided in `SWIFT_NATIVE_SWIFT_TOOLS_PATH`"
208210
OFF "NOT CMAKE_GENERATOR STREQUAL \"Xcode\"" OFF)
209211

210212
# The following only works with the Ninja generator in CMake >= 3.0.
@@ -405,6 +407,18 @@ option(SWIFT_REPORT_STATISTICS
405407
"Create json files which contain internal compilation statistics"
406408
FALSE)
407409

410+
# Only Darwin platforms enable ObjC interop by default.
411+
if("${SWIFT_HOST_VARIANT_SDK}" MATCHES "(OSX|IOS*|TVOS*|WATCHOS*)")
412+
set(SWIFT_STDLIB_ENABLE_OBJC_INTEROP_default TRUE)
413+
else()
414+
set(SWIFT_STDLIB_ENABLE_OBJC_INTEROP_default FALSE)
415+
endif()
416+
417+
# Used by stdlib/toolchain as well, so this cannot be in stdlib/CMakeLists.txt
418+
option(SWIFT_STDLIB_ENABLE_OBJC_INTEROP
419+
"Should stdlib be built with Obj-C interop."
420+
"${SWIFT_STDLIB_ENABLE_OBJC_INTEROP_default}")
421+
408422
#
409423
# User-configurable experimental options. Do not use in production builds.
410424
#
@@ -513,6 +527,9 @@ if(SWIFT_ENABLE_DISPATCH AND NOT CMAKE_SYSTEM_NAME STREQUAL Darwin)
513527
endif()
514528
endif()
515529

530+
file(STRINGS "utils/availability-macros.def" SWIFT_STDLIB_AVAILABILITY_DEFINITIONS)
531+
list(FILTER SWIFT_STDLIB_AVAILABILITY_DEFINITIONS EXCLUDE REGEX "^\\s*(#.*)?$")
532+
516533
#
517534
# Include CMake modules
518535
#
@@ -597,15 +614,19 @@ set(SWIFT_LIBRARY_OUTPUT_INTDIR "${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/lib")
597614
if("${SWIFT_NATIVE_SWIFT_TOOLS_PATH}" STREQUAL "")
598615
set(SWIFT_NATIVE_SWIFT_TOOLS_PATH "${SWIFT_RUNTIME_OUTPUT_INTDIR}")
599616
set(SWIFT_EXEC_FOR_LIBSWIFT "${CMAKE_Swift_COMPILER}")
600-
elseif(LIBSWIFT_BUILD_MODE STREQUAL "BOOTSTRAPPING" OR LIBSWIFT_BUILD_MODE STREQUAL "BOOTSTRAPPING-WITH-HOSTLIBS")
617+
elseif(LIBSWIFT_BUILD_MODE MATCHES "BOOTSTRAPPING.*")
601618
# If cross-compiling we don't have to bootstrap. We can just use the previously
602619
# built native swiftc to build libswift.
603-
message(STATUS "Building libswift with native host tools instead of bootstrapping")
604-
set(LIBSWIFT_BUILD_MODE "HOSTTOOLS")
620+
message(STATUS "Building libswift with previously built tools instead of bootstrapping")
605621
set(SWIFT_EXEC_FOR_LIBSWIFT "${SWIFT_NATIVE_SWIFT_TOOLS_PATH}/swiftc")
622+
if(LIBSWIFT_BUILD_MODE STREQUAL "BOOTSTRAPPING-WITH-HOSTLIBS")
623+
set(LIBSWIFT_BUILD_MODE "CROSSCOMPILE-WITH-HOSTLIBS")
624+
else()
625+
set(LIBSWIFT_BUILD_MODE "HOSTTOOLS")
626+
endif()
606627
endif()
607628

608-
if(LIBSWIFT_BUILD_MODE STREQUAL "HOSTTOOLS" OR LIBSWIFT_BUILD_MODE STREQUAL "BOOTSTRAPPING-WITH-HOSTLIBS")
629+
if(LIBSWIFT_BUILD_MODE MATCHES "HOSTTOOLS|.*-WITH-HOSTLIBS")
609630
if(SWIFT_ENABLE_ARRAY_COW_CHECKS)
610631
message(STATUS "array COW checks disabled when building libswift with host libraries")
611632
set(SWIFT_ENABLE_ARRAY_COW_CHECKS FALSE)
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
2+
set(SWIFT_HOST_VARIANT_SDK WINDOWS CACHE STRING "")
3+
set(SWIFT_HOST_VARIANT_ARCH aarch64 CACHE STRING "")
4+
5+
# NOTE(compnerd) disable the tools, we are trying to build just the standard
6+
# library.
7+
set(SWIFT_INCLUDE_TOOLS NO CACHE BOOL "")
8+
9+
# NOTE(compnerd) cannot build tests since the tests require the toolchain
10+
set(SWIFT_INCLUDE_TESTS NO CACHE BOOL "")
11+
12+
# NOTE(compnerd) cannot build docs since that requires perl
13+
set(SWIFT_INCLUDE_DOCS NO CACHE BOOL "")
14+
15+
# NOTE(compnerd) these are part of the toolchain, not the runtime.
16+
set(SWIFT_BUILD_SYNTAXPARSERLIB NO CACHE BOOL "")
17+
set(SWIFT_BUILD_SOURCEKIT NO CACHE BOOL "")
18+
19+
# NOTE(compnerd) build with the compiler specified, not a just built compiler.
20+
set(SWIFT_BUILD_RUNTIME_WITH_HOST_COMPILER YES CACHE BOOL "")
21+

cmake/caches/Windows-arm64.cmake

Lines changed: 164 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,164 @@
1+
set(LLVM_ENABLE_PROJECTS
2+
clang
3+
clang-tools-extra
4+
lld
5+
lldb
6+
CACHE STRING "")
7+
8+
set(LLVM_EXTERNAL_PROJECTS
9+
cmark
10+
swift
11+
CACHE STRING "")
12+
13+
set(LLVM_ENABLE_RUNTIMES
14+
compiler-rt
15+
CACHE STRING "")
16+
17+
# NOTE(compnerd) always enable assertions, the toolchain will not provide enough
18+
# context to resolve issues otherwise and may silently generate invalid output.
19+
set(LLVM_ENABLE_ASSERTIONS YES CACHE BOOL "")
20+
21+
set(ENABLE_X86_RELAX_RELOCATIONS YES CACHE BOOL "")
22+
23+
# NOTE(compnerd) we can hardcode the default target triple since the cache files
24+
# are target dependent.
25+
set(LLVM_DEFAULT_TARGET_TRIPLE aarch64-unknown-windows-msvc CACHE STRING "")
26+
27+
set(LLVM_APPEND_VC_REV NO CACHE BOOL "")
28+
set(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR YES CACHE BOOL "")
29+
set(LLVM_ENABLE_PYTHON YES CACHE BOOL "")
30+
set(LLVM_RUNTIME_TARGETS
31+
aarch64-unknown-windows-msvc
32+
CACHE STRING "")
33+
foreach(target ${LLVM_RUNTIME_TARGETS})
34+
set(RUNTIMES_${target}_LLVM_ENABLE_RUNTIMES
35+
compiler-rt
36+
CACHE STRING "")
37+
set(RUNTIMES_${target}_CMAKE_MT mt CACHE STRING "")
38+
set(RUNTIMES_${target}_CMAKE_SYSTEM_NAME Windows CACHE STRING "")
39+
set(RUNTIMES_${target}_CMAKE_BUILD_TYPE Release CACHE STRING "")
40+
set(RUNTIMES_${target}_COMPILER_RT_BUILD_CRT NO CACHE BOOL "")
41+
set(RUNTIMES_${target}_COMPILER_RT_BUILD_LIBFUZZER NO CACHE BOOL "")
42+
set(RUNTIMES_${target}_COMPILER_RT_BUILD_PROFILE YES CACHE BOOL "")
43+
set(RUNTIMES_${target}_COMPILER_RT_BUILD_SANITIZERS NO CACHE BOOL "")
44+
set(RUNTIMES_${target}_COMPILER_RT_BUILD_XRAY NO CACHE BOOL "")
45+
endforeach()
46+
47+
set(LLVM_TARGETS_TO_BUILD AArch64 ARM WebAssembly X86 CACHE STRING "")
48+
49+
# Disable certain targets to reduce the configure time or to avoid configuration
50+
# differences (and in some cases weird build errors on a complete build).
51+
set(LLVM_BUILD_LLVM_DYLIB NO CACHE BOOL "")
52+
set(LLVM_BUILD_LLVM_C_DYLIB NO CACHE BOOL "")
53+
set(LLVM_ENABLE_LIBEDIT NO CACHE BOOL "")
54+
set(LLVM_ENABLE_LIBXML2 NO CACHE BOOL "")
55+
set(LLVM_ENABLE_OCAMLDOC NO CACHE BOOL "")
56+
set(LLVM_ENABLE_TERMINFO NO CACHE BOOL "")
57+
set(LLVM_ENABLE_Z3_SOLVER NO CACHE BOOL "")
58+
set(LLVM_ENABLE_ZLIB NO CACHE BOOL "")
59+
set(LLVM_INCLUDE_BENCHMARKS NO CACHE BOOL "")
60+
set(LLVM_INCLUDE_DOCS NO CACHE BOOL "")
61+
set(LLVM_INCLUDE_EXAMPLES NO CACHE BOOL "")
62+
set(LLVM_INCLUDE_GO_TESTS NO CACHE BOOL "")
63+
set(LLVM_TOOL_GOLD_BUILD NO CACHE BOOL "")
64+
set(LLVM_TOOL_LLVM_SHLIB_BUILD NO CACHE BOOL "")
65+
66+
# Avoid swig dependency for lldb
67+
set(LLDB_ALLOW_STATIC_BINDINGS YES CACHE BOOL "")
68+
set(LLDB_USE_STATIC_BINDINGS YES CACHE BOOL "")
69+
70+
# This requires perl which may not be available on Windows
71+
set(SWIFT_INCLUDE_DOCS NO CACHE BOOL "")
72+
set(SWIFT_BUILD_ENABLE_PARSER_LIB YES CACHE BOOL "")
73+
# static linking is not supported on Windows yet
74+
set(SWIFT_BUILD_STATIC_STDLIB NO CACHE BOOL "")
75+
set(SWIFT_BUILD_STATIC_SDK_OVERLAY NO CACHE BOOL "")
76+
77+
set(LLVM_INSTALL_BINUTILS_SYMLINKS YES CACHE BOOL "")
78+
set(LLVM_INSTALL_TOOLCHAIN_ONLY YES CACHE BOOL "")
79+
set(LLVM_TOOLCHAIN_TOOLS
80+
addr2line
81+
ar
82+
c++filt
83+
dsymutil
84+
dwp
85+
# lipo
86+
llvm-ar
87+
llvm-cov
88+
llvm-cvtres
89+
llvm-cxxfilt
90+
llvm-dlltool
91+
llvm-dwarfdump
92+
llvm-dwp
93+
llvm-lib
94+
llvm-lipo
95+
llvm-mt
96+
llvm-nm
97+
llvm-objcopy
98+
llvm-objdump
99+
llvm-pdbutil
100+
llvm-profdata
101+
llvm-ranlib
102+
llvm-rc
103+
llvm-readelf
104+
llvm-readobj
105+
llvm-size
106+
llvm-strings
107+
llvm-strip
108+
llvm-symbolizer
109+
llvm-undname
110+
nm
111+
objcopy
112+
objdump
113+
ranlib
114+
readelf
115+
size
116+
strings
117+
CACHE STRING "")
118+
119+
set(CLANG_TOOLS
120+
clang
121+
clangd
122+
clang-format
123+
clang-resource-headers
124+
clang-tidy
125+
CACHE STRING "")
126+
127+
set(LLD_TOOLS
128+
lld
129+
CACHE STRING "")
130+
131+
set(LLDB_TOOLS
132+
liblldb
133+
lldb
134+
lldb-argdumper
135+
lldb-python-scripts
136+
lldb-server
137+
lldb-vscode
138+
repl_swift
139+
CACHE STRING "")
140+
141+
set(SWIFT_INSTALL_COMPONENTS
142+
autolink-driver
143+
compiler
144+
clang-builtin-headers
145+
editor-integration
146+
tools
147+
sourcekit-inproc
148+
swift-remote-mirror
149+
swift-remote-mirror-headers
150+
parser-lib
151+
CACHE STRING "")
152+
153+
set(LLVM_DISTRIBUTION_COMPONENTS
154+
IndexStore
155+
libclang
156+
libclang-headers
157+
LTO
158+
runtimes
159+
${LLVM_TOOLCHAIN_TOOLS}
160+
${CLANG_TOOLS}
161+
${LLD_TOOLS}
162+
${LLDB_TOOLS}
163+
${SWIFT_INSTALL_COMPONENTS}
164+
CACHE STRING "")

cmake/modules/AddSwift.cmake

Lines changed: 40 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -730,7 +730,8 @@ function(add_libswift name)
730730
731731
set(libswift_compile_options
732732
"-Xfrontend" "-validate-tbd-against-ir=none"
733-
"-Xfrontend" "-enable-cxx-interop")
733+
"-Xfrontend" "-enable-cxx-interop"
734+
"-Xcc" "-UIBOutlet" "-Xcc" "-UIBAction" "-Xcc" "-UIBInspectable")
734735
735736
if(CMAKE_BUILD_TYPE STREQUAL Debug)
736737
list(APPEND libswift_compile_options "-g")
@@ -740,9 +741,19 @@ function(add_libswift name)
740741
741742
get_bootstrapping_path(build_dir ${CMAKE_CURRENT_BINARY_DIR} "${ALS_BOOTSTRAPPING}")
742743
744+
set(sdk_option "")
745+
743746
if(SWIFT_HOST_VARIANT_SDK IN_LIST SWIFT_DARWIN_PLATFORMS)
744747
set(deployment_version "10.15") # TODO: once #38675 lands, replace this with
745748
# set(deployment_version "${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK}_DEPLOYMENT_VERSION}")
749+
set(sdk_option "-sdk" "${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK}_ARCH_${SWIFT_HOST_VARIANT_ARCH}_PATH}")
750+
if(${LIBSWIFT_BUILD_MODE} STREQUAL "CROSSCOMPILE-WITH-HOSTLIBS")
751+
# Let the cross-compiled compile don't pick up the compiled stdlib by providing
752+
# an (almost) empty resource dir.
753+
# The compiler will instead pick up the stdlib from the SDK.
754+
get_filename_component(swift_exec_bin_dir ${ALS_SWIFT_EXEC} DIRECTORY)
755+
set(sdk_option ${sdk_option} "-resource-dir" "${swift_exec_bin_dir}/../bootstrapping0/lib/swift")
756+
endif()
746757
endif()
747758
get_versioned_target_triple(target ${SWIFT_HOST_VARIANT_SDK}
748759
${SWIFT_HOST_VARIANT_ARCH} "${deployment_version}")
@@ -776,7 +787,7 @@ function(add_libswift name)
776787
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
777788
DEPENDS ${sources} ${deps} ${ALS_DEPENDS}
778789
COMMAND ${ALS_SWIFT_EXEC} "-c" "-o" ${module_obj_file}
779-
"-sdk" "${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK}_ARCH_${SWIFT_HOST_VARIANT_ARCH}_PATH}"
790+
${sdk_option}
780791
"-target" ${target}
781792
"-module-name" ${module} "-emit-module"
782793
"-emit-module-path" "${build_dir}/${module}.swiftmodule"
@@ -874,6 +885,7 @@ function(add_swift_host_tool executable)
874885
# Please add each rpath separately below to the list, explaining why you are
875886
# adding it.
876887
set(RPATH_LIST)
888+
set(sdk_dir "${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK}_ARCH_${SWIFT_HOST_VARIANT_ARCH}_PATH}/usr/lib/swift")
877889
878890
# If we found a swift compiler and are going to use swift code in swift
879891
# host side tools but link with clang, add the appropriate -L paths so we
@@ -886,9 +898,24 @@ function(add_swift_host_tool executable)
886898
get_filename_component(TOOLCHAIN_LIB_DIR "${TOOLCHAIN_BIN_DIR}/../lib/swift/macosx" ABSOLUTE)
887899
target_link_directories(${executable} PUBLIC ${TOOLCHAIN_LIB_DIR})
888900
889-
# Add in the SDK directory for the host platform.
890-
target_link_directories(${executable} PRIVATE
891-
${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK}_ARCH_${SWIFT_HOST_VARIANT_ARCH}_PATH}/usr/lib/swift)
901+
# Add the SDK directory for the host platform.
902+
target_link_directories(${executable} PRIVATE "${sdk_dir}")
903+
904+
# Include the abi stable system stdlib in our rpath.
905+
list(APPEND RPATH_LIST "/usr/lib/swift")
906+
907+
elseif(LIBSWIFT_BUILD_MODE STREQUAL "CROSSCOMPILE-WITH-HOSTLIBS")
908+
909+
# Intentinally don't add the lib dir of the cross-compiled compiler, so that
910+
# the stdlib is not picked up from there, but from the SDK.
911+
# This requires to explicitly add all the needed compatibility libraries. We
912+
# can take them from the current build.
913+
set(vsuffix "-${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK}_LIB_SUBDIR}-${SWIFT_HOST_VARIANT_ARCH}")
914+
set(conctarget "swiftCompatibilityConcurrency${vsuffix}")
915+
target_link_libraries(${executable} PUBLIC ${conctarget})
916+
917+
# Add the SDK directory for the host platform.
918+
target_link_directories(${executable} PRIVATE "${sdk_dir}")
892919
893920
# Include the abi stable system stdlib in our rpath.
894921
list(APPEND RPATH_LIST "/usr/lib/swift")
@@ -897,9 +924,8 @@ function(add_swift_host_tool executable)
897924
# Pick up the built libswiftCompatibility<n>.a libraries
898925
_link_built_compatibility_libs(${executable})
899926
900-
# Add in the SDK directory for the host platform.
901-
target_link_directories(${executable} PRIVATE
902-
${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK}_ARCH_${SWIFT_HOST_VARIANT_ARCH}_PATH}/usr/lib/swift)
927+
# Add the SDK directory for the host platform.
928+
target_link_directories(${executable} PRIVATE "${sdk_dir}")
903929
904930
# Include the abi stable system stdlib in our rpath.
905931
list(APPEND RPATH_LIST "/usr/lib/swift")
@@ -945,8 +971,7 @@ function(add_swift_host_tool executable)
945971
# NOTE: We do this /after/ target_link_directorying TOOLCHAIN_LIB_DIR to
946972
# ensure that we first find libraries from the toolchain, rather than from
947973
# the SDK.
948-
target_link_directories(${executable} PRIVATE
949-
${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK}_ARCH_${SWIFT_HOST_VARIANT_ARCH}_PATH}/usr/lib/swift)
974+
target_link_directories(${executable} PRIVATE "${sdk_dir}")
950975
951976
# We also want to be able to find libraries from the base toolchain
952977
# directory. This is so swiftc can rely on its own host side dylibs that may
@@ -979,8 +1004,11 @@ function(add_swift_host_tool executable)
9791004
elseif(LIBSWIFT_BUILD_MODE STREQUAL "BOOTSTRAPPING")
9801005
# At build time link against the built swift libraries from the
9811006
# previous bootstrapping stage.
982-
get_bootstrapping_swift_lib_dir(bs_lib_dir "${ASHT_BOOTSTRAPPING}")
983-
target_link_directories(${executable} PRIVATE ${bs_lib_dir})
1007+
if (NOT "${ASHT_BOOTSTRAPPING}" STREQUAL "0")
1008+
get_bootstrapping_swift_lib_dir(bs_lib_dir "${ASHT_BOOTSTRAPPING}")
1009+
target_link_directories(${executable} PRIVATE ${bs_lib_dir})
1010+
target_link_libraries(${executable} PRIVATE "swiftCore")
1011+
endif()
9841012
9851013
# At runtime link against the built swift libraries from the current
9861014
# bootstrapping stage.

0 commit comments

Comments
 (0)