Skip to content

Commit 5492814

Browse files
authored
Merge pull request #3889 from swiftwasm/maxd/main-merge
2 parents 2be3004 + 47e2219 commit 5492814

File tree

112 files changed

+1423
-467
lines changed

Some content is hidden

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

112 files changed

+1423
-467
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ docs/_build
4040
# Visual Studio metadata
4141
.vs
4242

43+
# Visual Studio Code Configurations
44+
.vscode
45+
4346
# clangd
4447
.cache
4548
.clangd

CMakeLists.txt

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -175,21 +175,6 @@ set(SWIFT_COMPILER_VERSION "" CACHE STRING
175175
set(CLANG_COMPILER_VERSION "" CACHE STRING
176176
"The internal version of the Clang compiler")
177177

178-
# Which default linker to use. Prefer LLVM_USE_LINKER if it set, otherwise use
179-
# our own defaults. This should only be possible in a unified (not stand alone)
180-
# build environment.
181-
if(LLVM_USE_LINKER)
182-
set(SWIFT_USE_LINKER_default "${LLVM_USE_LINKER}")
183-
elseif(CMAKE_SYSTEM_NAME STREQUAL Windows AND NOT CMAKE_HOST_SYSTEM_NAME STREQUAL Windows)
184-
set(SWIFT_USE_LINKER_default "lld")
185-
elseif(CMAKE_SYSTEM_NAME STREQUAL Darwin)
186-
set(SWIFT_USE_LINKER_default "")
187-
else()
188-
set(SWIFT_USE_LINKER_default "gold")
189-
endif()
190-
set(SWIFT_USE_LINKER ${SWIFT_USE_LINKER_default} CACHE STRING
191-
"Build Swift with a non-default linker")
192-
193178
option(SWIFT_DISABLE_DEAD_STRIPPING
194179
"Turn off Darwin-specific dead stripping for Swift host tools." FALSE)
195180

@@ -308,8 +293,8 @@ set(SWIFT_ANDROID_API_LEVEL "" CACHE STRING
308293

309294
set(SWIFT_ANDROID_NDK_PATH "" CACHE STRING
310295
"Path to the directory that contains the Android NDK tools that are executable on the build machine")
311-
set(SWIFT_ANDROID_NDK_GCC_VERSION "" CACHE STRING
312-
"The GCC version to use when building for Android. Currently only 4.9 is supported.")
296+
set(SWIFT_ANDROID_NDK_CLANG_VERSION "12.0.8" CACHE STRING
297+
"The Clang version to use when building for Android.")
313298
set(SWIFT_ANDROID_DEPLOY_DEVICE_PATH "" CACHE STRING
314299
"Path on an Android device where build products will be pushed. These are used when running the test suite against the device")
315300

@@ -753,6 +738,23 @@ set(SWIFT_HOST_VARIANT_SDK "${SWIFT_HOST_VARIANT_SDK_default}" CACHE STRING
753738
set(SWIFT_HOST_VARIANT_ARCH "${SWIFT_HOST_VARIANT_ARCH_default}" CACHE STRING
754739
"Deployment arch for Swift host tools (the compiler).")
755740

741+
# Which default linker to use. Prefer LLVM_USE_LINKER if it set, otherwise use
742+
# our own defaults. This should only be possible in a unified (not stand alone)
743+
# build environment.
744+
if(LLVM_USE_LINKER)
745+
set(SWIFT_USE_LINKER_default "${LLVM_USE_LINKER}")
746+
elseif(${SWIFT_HOST_VARIANT_SDK} STREQUAL ANDROID)
747+
set(SWIFT_USE_LINKER_default "lld")
748+
elseif(CMAKE_SYSTEM_NAME STREQUAL Windows AND NOT CMAKE_HOST_SYSTEM_NAME STREQUAL Windows)
749+
set(SWIFT_USE_LINKER_default "lld")
750+
elseif(CMAKE_SYSTEM_NAME STREQUAL Darwin)
751+
set(SWIFT_USE_LINKER_default "")
752+
else()
753+
set(SWIFT_USE_LINKER_default "gold")
754+
endif()
755+
set(SWIFT_USE_LINKER ${SWIFT_USE_LINKER_default} CACHE STRING
756+
"Build Swift with a non-default linker")
757+
756758
#
757759
# Enable additional warnings.
758760
#

cmake/modules/AddSwift.cmake

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -145,12 +145,9 @@ function(_add_host_variant_c_compile_link_flags name)
145145
endif()
146146

147147
if(SWIFT_HOST_VARIANT_SDK STREQUAL ANDROID)
148-
# lld can handle targeting the android build. However, if lld is not
149-
# enabled, then fallback to the linker included in the android NDK.
150-
if(NOT SWIFT_USE_LINKER STREQUAL "lld")
151-
swift_android_tools_path(${SWIFT_HOST_VARIANT_ARCH} tools_path)
152-
target_compile_options(${name} PRIVATE $<$<COMPILE_LANGUAGE:C,CXX,OBJC,OBJCXX>:-B${tools_path}>)
153-
endif()
148+
# Make sure the Android NDK lld is used.
149+
swift_android_tools_path(${SWIFT_HOST_VARIANT_ARCH} tools_path)
150+
target_compile_options(${name} PRIVATE $<$<COMPILE_LANGUAGE:C,CXX,OBJC,OBJCXX>:-B${tools_path}>)
154151
endif()
155152

156153
if(SWIFT_HOST_VARIANT_SDK IN_LIST SWIFT_DARWIN_PLATFORMS)
@@ -384,11 +381,6 @@ function(_add_host_variant_link_flags target)
384381
cxx_link_libraries)
385382
target_link_libraries(${target} PRIVATE
386383
${cxx_link_libraries})
387-
388-
swift_android_libgcc_for_arch_cross_compile(${SWIFT_HOST_VARIANT_ARCH}
389-
${SWIFT_HOST_VARIANT_ARCH}_LIB)
390-
target_link_directories(${target} PRIVATE
391-
${${SWIFT_HOST_VARIANT_ARCH}_LIB})
392384
elseif("${LFLAGS_SDK}" STREQUAL "WASI")
393385
list(APPEND result "-Wl,wasi-emulated-mman")
394386
else()

cmake/modules/AddSwiftUnittests.cmake

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,6 @@ function(add_swift_unittest test_dirname)
3232
COMMAND "${SWIFT_SOURCE_DIR}/utils/swift-rpathize.py"
3333
"$<TARGET_FILE:${test_dirname}>")
3434
elseif("${SWIFT_HOST_VARIANT}" STREQUAL "android")
35-
swift_android_libgcc_for_arch_cross_compile(${SWIFT_HOST_VARIANT_ARCH} android_system_libs)
36-
set_property(TARGET "${test_dirname}" APPEND PROPERTY LINK_DIRECTORIES
37-
"${android_system_libs}")
3835
set_property(TARGET "${test_dirname}" APPEND PROPERTY LINK_LIBRARIES "log")
3936
elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
4037
if(CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64|AMD64")

cmake/modules/SwiftAndroidSupport.cmake

Lines changed: 4 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,7 @@
1-
function(swift_android_prebuilt_host_name prebuilt_var_name)
2-
# Get the prebuilt suffix to create the correct toolchain path when using the NDK
3-
if(CMAKE_HOST_SYSTEM_NAME STREQUAL Darwin)
4-
set(${prebuilt_var_name} darwin-x86_64 PARENT_SCOPE)
5-
elseif(CMAKE_HOST_SYSTEM_NAME STREQUAL Linux)
6-
set(${prebuilt_var_name} linux-x86_64 PARENT_SCOPE)
7-
elseif(CMAKE_HOST_SYSTEM_NAME STREQUAL Windows)
8-
set(${prebuilt_var_name} Windows-x86_64 PARENT_SCOPE)
9-
else()
10-
message(SEND_ERROR "cannot cross-compile to android from ${CMAKE_HOST_SYSTEM_NAME}")
11-
endif()
12-
endfunction()
13-
14-
function(swift_android_libgcc_for_arch_cross_compile arch var)
15-
set(paths)
16-
if(NOT "${SWIFT_ANDROID_NDK_PATH}" STREQUAL "")
17-
list(APPEND paths "${SWIFT_SDK_ANDROID_ARCH_${arch}_PATH}/../lib/gcc/${SWIFT_SDK_ANDROID_ARCH_${arch}_NDK_TRIPLE}/${SWIFT_ANDROID_NDK_GCC_VERSION}.x")
18-
endif()
19-
set(${var} ${paths} PARENT_SCOPE)
20-
endfunction()
21-
221
function(swift_android_sysroot sysroot_var_name)
232
if(NOT "${SWIFT_ANDROID_NDK_PATH}" STREQUAL "")
24-
swift_android_prebuilt_host_name(prebuilt_build)
25-
set(${sysroot_var_name} "${SWIFT_ANDROID_NDK_PATH}/toolchains/llvm/prebuilt/${prebuilt_build}/sysroot" PARENT_SCOPE)
3+
string(TOLOWER ${CMAKE_HOST_SYSTEM_NAME} platform)
4+
set(${sysroot_var_name} "${SWIFT_ANDROID_NDK_PATH}/toolchains/llvm/prebuilt/${platform}-x86_64/sysroot" PARENT_SCOPE)
265
elseif(NOT "${SWIFT_ANDROID_NATIVE_SYSROOT}" STREQUAL "")
276
set(${sysroot_var_name} "${SWIFT_ANDROID_NATIVE_SYSROOT}" PARENT_SCOPE)
287
else()
@@ -32,19 +11,8 @@ endfunction()
3211

3312
function(swift_android_tools_path arch path_var_name)
3413
if(NOT "${SWIFT_ANDROID_NDK_PATH}" STREQUAL "")
35-
swift_android_prebuilt_host_name(prebuilt_build)
36-
if("${arch}" STREQUAL "i686")
37-
set(ndk_prebuilt_path
38-
"${SWIFT_ANDROID_NDK_PATH}/toolchains/x86-${SWIFT_ANDROID_NDK_GCC_VERSION}/prebuilt/${prebuilt_build}")
39-
elseif("${arch}" STREQUAL "x86_64")
40-
set(ndk_prebuilt_path
41-
"${SWIFT_ANDROID_NDK_PATH}/toolchains/x86_64-${SWIFT_ANDROID_NDK_GCC_VERSION}/prebuilt/${prebuilt_build}")
42-
else()
43-
set(ndk_prebuilt_path
44-
"${SWIFT_ANDROID_NDK_PATH}/toolchains/${SWIFT_SDK_ANDROID_ARCH_${arch}_NDK_TRIPLE}-${SWIFT_ANDROID_NDK_GCC_VERSION}/prebuilt/${prebuilt_build}")
45-
endif()
46-
47-
set(${path_var_name} "${ndk_prebuilt_path}/${SWIFT_SDK_ANDROID_ARCH_${arch}_NDK_TRIPLE}/bin" PARENT_SCOPE)
14+
string(TOLOWER ${CMAKE_HOST_SYSTEM_NAME} platform)
15+
set(${path_var_name} "${SWIFT_ANDROID_NDK_PATH}/toolchains/llvm/prebuilt/${platform}-x86_64/bin" PARENT_SCOPE)
4816
elseif(NOT "${SWIFT_ANDROID_NATIVE_SYSROOT}" STREQUAL "")
4917
set(${path_var_name} "${SWIFT_ANDROID_NATIVE_SYSROOT}/usr/bin" PARENT_SCOPE)
5018
else()

docs/Android.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ To follow along with this guide, you'll need:
3333
Ubuntu 18.04 or Ubuntu 16.04. Before attempting to build for Android,
3434
please make sure you are able to build for Linux by following the
3535
instructions in the Swift project README.
36-
2. The latest version of the Android NDK (r21e at the time of this writing,
37-
only r19 or later are supported), available to download here:
36+
2. The latest version of the Android NDK (r23b at the time of this writing),
37+
available to download here:
3838
https://developer.android.com/ndk/downloads/index.html.
3939
3. An Android device with remote debugging enabled or the emulator. We require
4040
remote debugging in order to deploy built stdlib products to the device. You
@@ -73,7 +73,7 @@ Android NDK, as well as the directories that contain the `libicuucswift.so` and
7373

7474
```
7575
$ ARM_DIR=path/to/libiconv-libicu-android/armeabi-v7a
76-
$ NDK_PATH=path/to/android-ndk-r21e
76+
$ NDK_PATH=path/to/android-ndk-r23b
7777
$ utils/build-script \
7878
-R \ # Build in ReleaseAssert mode.
7979
--android \ # Build for Android.
@@ -99,7 +99,7 @@ Then use the built Swift compiler from the previous step to compile a Swift
9999
source file, targeting Android:
100100

101101
```
102-
$ NDK_PATH="path/to/android-ndk-r21e"
102+
$ NDK_PATH="path/to/android-ndk-r23b"
103103
$ build/Ninja-ReleaseAssert/swift-linux-x86_64/bin/swiftc \ # The Swift compiler built in the previous step
104104
# The location of the tools used to build Android binaries
105105
-tools-directory ${NDK_PATH}/toolchains/llvm/prebuilt/linux-x86_64/bin/ \
@@ -153,7 +153,7 @@ adb push /path/to/libicu-android/armeabi-v7a/libicuucswift.so /data/local/tmp
153153
In addition, you'll also need to copy the Android NDK's libc++:
154154

155155
```
156-
$ adb push /path/to/android-ndk-r21e/sources/cxx-stl/llvm-libc++/libs/armeabi-v7a/libc++_shared.so /data/local/tmp
156+
$ adb push /path/to/android-ndk-r23b/sources/cxx-stl/llvm-libc++/libs/armeabi-v7a/libc++_shared.so /data/local/tmp
157157
```
158158

159159
Finally, you'll need to copy the `hello` executable you built in the
@@ -196,7 +196,7 @@ $ utils/build-script \
196196
-R \ # Build in ReleaseAssert mode.
197197
-T \ # Run all tests, including on the Android device (add --host-test to only run Android tests on the linux host).
198198
--android \ # Build for Android.
199-
--android-ndk ~/android-ndk-r21e \ # Path to an Android NDK.
199+
--android-ndk ~/android-ndk-r23b \ # Path to an Android NDK.
200200
--android-arch armv7 \ # Optionally specify Android architecture, alternately aarch64
201201
--android-ndk-version 21 \
202202
--android-icu-uc ~/libicu-android/armeabi-v7a/libicuuc.so \

include/swift/AST/DiagnosticsSema.def

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1191,6 +1191,10 @@ WARNING(coercion_may_fail_warning,none,
11911191
"coercion from %0 to %1 may fail; use 'as?' or 'as!' instead",
11921192
(Type, Type))
11931193

1194+
WARNING(tuple_label_mismatch_warning,none,
1195+
"tuple conversion from %0 to %1 mismatches labels",
1196+
(Type, Type))
1197+
11941198
ERROR(missing_explicit_conversion,none,
11951199
"%0 is not implicitly convertible to %1; "
11961200
"did you mean to use 'as' to explicitly convert?", (Type, Type))
@@ -4519,9 +4523,6 @@ ERROR(nonisolated_distributed_actor_storage,none,
45194523
ERROR(distributed_actor_func_nonisolated, none,
45204524
"cannot declare method %0 as both 'nonisolated' and 'distributed'",
45214525
(DeclName))
4522-
ERROR(distributed_actor_func_private, none,
4523-
"%0 %1 cannot be 'private'",
4524-
(DescriptiveDeclKind, DeclName))
45254526
ERROR(distributed_actor_func_inout, none,
45264527
"cannot declare 'inout' argument %0 in %1 %2",
45274528
(DeclName, DescriptiveDeclKind, DeclName))

include/swift/AST/TypeNodes.def

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,8 @@ ABSTRACT_TYPE(Substitutable, Type)
148148
ALWAYS_CANONICAL_TYPE(OpaqueTypeArchetype, ArchetypeType)
149149
ALWAYS_CANONICAL_TYPE(OpenedArchetype, ArchetypeType)
150150
ALWAYS_CANONICAL_TYPE(NestedArchetype, ArchetypeType)
151-
TYPE_RANGE(Archetype, PrimaryArchetype, NestedArchetype)
151+
ALWAYS_CANONICAL_TYPE(SequenceArchetype, ArchetypeType)
152+
TYPE_RANGE(Archetype, PrimaryArchetype, SequenceArchetype)
152153
TYPE(GenericTypeParam, SubstitutableType)
153154
TYPE_RANGE(Substitutable, PrimaryArchetype, GenericTypeParam)
154155
TYPE(DependentMember, Type)

include/swift/AST/Types.h

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,8 @@ class RecursiveTypeProperties {
124124
HasTypeVariable = 0x01,
125125

126126
/// This type expression contains a context-dependent archetype, either a
127-
/// PrimaryArchetypeType or OpenedArchetypeType.
127+
/// \c PrimaryArchetypeType, \c OpenedArchetypeType, or
128+
/// \c SequenceArchetype.
128129
HasArchetype = 0x02,
129130

130131
/// This type expression contains a GenericTypeParamType.
@@ -5683,6 +5684,50 @@ CanArchetypeType getParent() const {
56835684
}
56845685
END_CAN_TYPE_WRAPPER(NestedArchetypeType, ArchetypeType)
56855686

5687+
/// An archetype that represents an opaque element of a type sequence in context.
5688+
///
5689+
/// \code
5690+
/// struct Foo<@_typeSequence Ts> { var xs: @_typeSequence Ts }
5691+
/// func foo<@_typeSequence T>(_ xs: T...) where T: P { }
5692+
/// \endcode
5693+
class SequenceArchetypeType final
5694+
: public ArchetypeType,
5695+
private ArchetypeTrailingObjects<SequenceArchetypeType> {
5696+
friend TrailingObjects;
5697+
friend ArchetypeType;
5698+
5699+
GenericEnvironment *Environment;
5700+
5701+
public:
5702+
/// getNew - Create a new sequence archetype with the given name.
5703+
///
5704+
/// The ConformsTo array will be minimized then copied into the ASTContext
5705+
/// by this routine.
5706+
static CanTypeWrapper<SequenceArchetypeType>
5707+
get(const ASTContext &Ctx, GenericEnvironment *GenericEnv,
5708+
GenericTypeParamType *InterfaceType,
5709+
SmallVectorImpl<ProtocolDecl *> &ConformsTo, Type Superclass,
5710+
LayoutConstraint Layout);
5711+
5712+
/// Retrieve the generic environment in which this archetype resides.
5713+
GenericEnvironment *getGenericEnvironment() const { return Environment; }
5714+
5715+
GenericTypeParamType *getInterfaceType() const {
5716+
return cast<GenericTypeParamType>(InterfaceType.getPointer());
5717+
}
5718+
5719+
static bool classof(const TypeBase *T) {
5720+
return T->getKind() == TypeKind::SequenceArchetype;
5721+
}
5722+
5723+
private:
5724+
SequenceArchetypeType(const ASTContext &Ctx, GenericEnvironment *GenericEnv,
5725+
Type InterfaceType, ArrayRef<ProtocolDecl *> ConformsTo,
5726+
Type Superclass, LayoutConstraint Layout);
5727+
};
5728+
BEGIN_CAN_TYPE_WRAPPER(SequenceArchetypeType, ArchetypeType)
5729+
END_CAN_TYPE_WRAPPER(SequenceArchetypeType, ArchetypeType)
5730+
56865731
template<typename Type>
56875732
const Type *ArchetypeType::getSubclassTrailingObjects() const {
56885733
if (auto contextTy = dyn_cast<PrimaryArchetypeType>(this)) {
@@ -5697,6 +5742,9 @@ const Type *ArchetypeType::getSubclassTrailingObjects() const {
56975742
if (auto childTy = dyn_cast<NestedArchetypeType>(this)) {
56985743
return childTy->getTrailingObjects<Type>();
56995744
}
5745+
if (auto childTy = dyn_cast<SequenceArchetypeType>(this)) {
5746+
return childTy->getTrailingObjects<Type>();
5747+
}
57005748
llvm_unreachable("unhandled ArchetypeType subclass?");
57015749
}
57025750

include/swift/Basic/LangOptions.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -682,7 +682,7 @@ namespace swift {
682682

683683
/// Enable experimental support for type inference through multi-statement
684684
/// closures.
685-
bool EnableMultiStatementClosureInference = false;
685+
bool EnableMultiStatementClosureInference = true;
686686

687687
/// See \ref FrontendOptions.PrintFullConvention
688688
bool PrintFullConvention = false;

0 commit comments

Comments
 (0)