Skip to content

Commit df6e286

Browse files
authored
Merge branch 'main' into wip-concurrency-assert-dispatch
2 parents 84891f8 + 5806e7a commit df6e286

File tree

514 files changed

+9557
-3915
lines changed

Some content is hidden

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

514 files changed

+9557
-3915
lines changed

CMakeLists.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -979,6 +979,18 @@ endif()
979979
set(SWIFT_USE_LINKER ${SWIFT_USE_LINKER_default} CACHE STRING
980980
"Build Swift with a non-default linker")
981981

982+
include(CheckLinkerFlag)
983+
984+
# Apple's linker complains about duplicate libraries, which CMake likes to do
985+
# to support ELF platforms. To silence that warning, we can use
986+
# -no_warn_duplicate_libraries, but only in versions of the linker that
987+
# support that flag.
988+
if(NOT LLVM_USE_LINKER AND ${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
989+
check_linker_flag(C "-Wl,-no_warn_duplicate_libraries" SWIFT_LINKER_SUPPORTS_NO_WARN_DUPLICATE_LIBRARIES)
990+
else()
991+
set(SWIFT_LINKER_SUPPORTS_NO_WARN_DUPLICATE_LIBRARIES OFF CACHE INTERNAL "")
992+
endif()
993+
982994
#
983995
# Enable additional warnings.
984996
#

SwiftCompilerSources/CMakeLists.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,10 +155,9 @@ function(add_swift_compiler_modules_library name)
155155
list(APPEND sdk_option "-resource-dir" "${swift_exec_bin_dir}/../bootstrapping0/lib/swift")
156156
endif()
157157
elseif(BOOTSTRAPPING_MODE STREQUAL "CROSSCOMPILE")
158-
get_filename_component(swift_exec_bin_dir ${ALS_SWIFT_EXEC} DIRECTORY)
159158
# NOTE: prepending allows SWIFT_COMPILER_SOURCES_SDK_FLAGS to override the
160159
# resource directory if needed.
161-
list(PREPEND sdk_option "-resource-dir" "${swift_exec_bin_dir}/../lib/swift")
160+
list(PREPEND sdk_option "-resource-dir" "${SWIFTLIB_DIR}")
162161
endif()
163162
get_versioned_target_triple(target ${SWIFT_HOST_VARIANT_SDK}
164163
${SWIFT_HOST_VARIANT_ARCH} "${deployment_version}")
@@ -232,6 +231,9 @@ function(add_swift_compiler_modules_library name)
232231
importedHeaderDependencies
233232
COMMENT "Building swift module ${module}")
234233

234+
if(BOOTSTRAPPING_MODE STREQUAL "CROSSCOMPILE")
235+
add_dependencies(${dep_target} swift-stdlib-${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK}_LIB_SUBDIR}-${SWIFT_HOST_VARIANT_ARCH})
236+
endif()
235237
set("${module}_dep_target" ${dep_target})
236238
set(all_module_targets ${all_module_targets} ${dep_target})
237239
endforeach()

cmake/caches/Windows-x86_64.cmake

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,18 @@ set(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR YES CACHE BOOL "")
2828
set(LLVM_ENABLE_PYTHON YES CACHE BOOL "")
2929
set(LLVM_RUNTIME_TARGETS
3030
x86_64-unknown-windows-msvc
31+
aarch64-unknown-windows-msvc
3132
CACHE STRING "")
3233
foreach(target ${LLVM_RUNTIME_TARGETS})
3334
set(RUNTIMES_${target}_LLVM_ENABLE_RUNTIMES
3435
compiler-rt
3536
CACHE STRING "")
3637
set(RUNTIMES_${target}_CMAKE_MT mt CACHE STRING "")
37-
set(RUNTIMES_${target}_CMAKE_SYSTEM_NAME Windows CACHE STRING "")
38+
if(${target} MATCHES windows-msvc)
39+
set(RUNTIMES_${target}_CMAKE_SYSTEM_NAME Windows CACHE STRING "")
40+
endif()
3841
set(RUNTIMES_${target}_CMAKE_BUILD_TYPE Release CACHE STRING "")
42+
set(RUNTIMES_${target}_COMPILER_RT_BUILD_BUILTINS YES CACHE BOOL "")
3943
set(RUNTIMES_${target}_COMPILER_RT_BUILD_CRT NO CACHE BOOL "")
4044
set(RUNTIMES_${target}_COMPILER_RT_BUILD_LIBFUZZER NO CACHE BOOL "")
4145
set(RUNTIMES_${target}_COMPILER_RT_BUILD_ORC NO CACHE BOOL "")

cmake/modules/AddPureSwift.cmake

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,16 @@ function(_add_host_swift_compile_options name)
6060
$<$<COMPILE_LANGUAGE:Swift>:none>)
6161

6262
target_compile_options(${name} PRIVATE $<$<COMPILE_LANGUAGE:Swift>:-target;${SWIFT_HOST_TRIPLE}>)
63+
if(BOOTSTRAPPING_MODE STREQUAL "CROSSCOMPILE")
64+
add_dependencies(${name} swift-stdlib-${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK}_LIB_SUBDIR}-${SWIFT_HOST_VARIANT_ARCH})
65+
target_compile_options(${name} PRIVATE
66+
$<$<COMPILE_LANGUAGE:Swift>:-sdk;${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK}_ARCH_${SWIFT_HOST_VARIANT_ARCH}_PATH};>
67+
$<$<COMPILE_LANGUAGE:Swift>:-resource-dir;${SWIFTLIB_DIR};>)
68+
if(SWIFT_HOST_VARIANT_SDK STREQUAL "ANDROID" AND NOT "${SWIFT_ANDROID_NDK_PATH}" STREQUAL "")
69+
swift_android_tools_path(${SWIFT_HOST_VARIANT_ARCH} tools_path)
70+
target_compile_options(${name} PRIVATE $<$<COMPILE_LANGUAGE:Swift>:-tools-directory;${tools_path};>)
71+
endif()
72+
endif()
6373
_add_host_variant_swift_sanitizer_flags(${name})
6474

6575
target_compile_options(${name} PRIVATE

cmake/modules/AddSwift.cmake

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -441,6 +441,12 @@ function(_add_host_variant_link_flags target)
441441
"SHELL:-Xlinker -dead_strip")
442442
endif()
443443
endif()
444+
445+
if(SWIFT_LINKER_SUPPORTS_NO_WARN_DUPLICATE_LIBRARIES)
446+
target_link_options(${target} PRIVATE
447+
"SHELL:-Xlinker -no_warn_duplicate_libraries")
448+
endif()
449+
444450
endfunction()
445451
446452
function(_add_swift_runtime_link_flags target relpath_to_lib_dir bootstrapping)
@@ -529,15 +535,19 @@ function(_add_swift_runtime_link_flags target relpath_to_lib_dir bootstrapping)
529535
elseif(SWIFT_HOST_VARIANT_SDK MATCHES "LINUX|ANDROID|OPENBSD|FREEBSD|WINDOWS")
530536
set(swiftrt "swiftImageRegistrationObject${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK}_OBJECT_FORMAT}-${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK}_LIB_SUBDIR}-${SWIFT_HOST_VARIANT_ARCH}")
531537
if(ASRLF_BOOTSTRAPPING_MODE MATCHES "HOSTTOOLS|CROSSCOMPILE")
532-
# At build time and run time, link against the swift libraries in the
533-
# installed host toolchain.
534-
if(SWIFT_PATH_TO_SWIFT_SDK)
535-
set(swift_dir "${SWIFT_PATH_TO_SWIFT_SDK}/usr")
538+
if(ASRLF_BOOTSTRAPPING_MODE STREQUAL "HOSTTOOLS")
539+
# At build time and run time, link against the swift libraries in the
540+
# installed host toolchain.
541+
if(SWIFT_PATH_TO_SWIFT_SDK)
542+
set(swift_dir "${SWIFT_PATH_TO_SWIFT_SDK}/usr")
543+
else()
544+
get_filename_component(swift_bin_dir ${SWIFT_EXEC_FOR_SWIFT_MODULES} DIRECTORY)
545+
get_filename_component(swift_dir ${swift_bin_dir} DIRECTORY)
546+
endif()
547+
set(host_lib_dir "${swift_dir}/lib/swift/${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK}_LIB_SUBDIR}")
536548
else()
537-
get_filename_component(swift_bin_dir ${SWIFT_EXEC_FOR_SWIFT_MODULES} DIRECTORY)
538-
get_filename_component(swift_dir ${swift_bin_dir} DIRECTORY)
549+
set(host_lib_dir "${SWIFTLIB_DIR}/${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK}_LIB_SUBDIR}")
539550
endif()
540-
set(host_lib_dir "${swift_dir}/lib/swift/${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK}_LIB_SUBDIR}")
541551
set(host_lib_arch_dir "${host_lib_dir}/${SWIFT_HOST_VARIANT_ARCH}")
542552
543553
set(swiftrt "${host_lib_arch_dir}/swiftrt${CMAKE_C_OUTPUT_EXTENSION}")

docs/EmbeddedSwift/EmbeddedSwiftStatus.md

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,21 @@
66

77
For an introduction and motivation into Embedded Swift, please see "[A Vision for Embedded Swift](https://github.com/apple/swift-evolution/blob/main/visions/embedded-swift.md)", a Swift Evolution document highlighting the main goals and approaches.
88

9+
## Embedded Swift Language Features
10+
11+
| **Language Feature** | **Currently Supported In Embedded Swift** |
12+
|-------------------------------------------------------|-------------------------------------------|
13+
| *Anything not listed below* | Yes |
14+
| Library Evolution (resilience) | No, intentionally unsupported long-term |
15+
| Objective-C interoperability | No, intentionally unsupported long-term |
16+
| Non-WMO builds | No, intentionally unsupported long-term (WMO should be used) |
17+
| Existentials | No, currently disallowed |
18+
| Any, AnyObject | No, currently disallowed |
19+
| Metatypes | No, currently only allowed as unused arguments (type hints) |
20+
| Untyped throwing | No, intentionally unsupported long-term (typed throwing should be used instead) |
21+
| Weak references, unowned references | No |
22+
| Non-final generic class methods | No, intentionally unsupported long-term |
23+
924
## Embedded Standard Library Breakdown
1025

1126
This status table describes which of the following standard library features can be used in Embedded Swift:
@@ -27,7 +42,7 @@ This status table describes which of the following standard library features can
2742
| Integer parsing | No |
2843
| KeyPaths | No |
2944
| Lazy collections | No |
30-
| Mirror | No, intentionally unsupported long-term |
45+
| Mirror (runtime reflection) | No, intentionally unsupported long-term |
3146
| Objective-C bridging | No, intentionally unsupported long-term |
3247
| Optional | Yes |
3348
| print / debugPrint | Partial (only StaticStrings and integers) |
@@ -48,6 +63,7 @@ This status table describes which of the following Swift features can be used in
4863

4964
| **Swift Feature** | **Currently Supported In Embedded Swift?** |
5065
|------------------------------------------------------------|-----------------------------------------------------|
66+
| Synchronization module | Yes |
5167
| Swift Concurrency | Partial, experimental (basics of actors and tasks work in single-threaded concurrency mode) |
5268
| C interop | Yes |
5369
| C++ interop | Yes |

docs/EmbeddedSwift/UserManual.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@ For (2), external dependencies are also triggered by specific code needing them,
197197
- **atomics instrinsics**
198198
- on CPU architectures that don't have direct load-acquire/store-release support in the ISA, LLVM calls helper functions for atomic operations
199199
- needed by refcounting in the Embedded Swift runtime (so any class usage will trigger this dependency)
200+
- also needed when using atomics from the Synchronization module
200201
- **multiplication/division/modulo instrinsics**
201202
- on CPU architectures that don't have direct support for the math operations in the ISA
202203
- dependency (on Mach-O): `__divti3`

include/swift/ABI/MetadataValues.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1119,7 +1119,7 @@ class TargetFunctionTypeFlags {
11191119
}
11201120

11211121
constexpr TargetFunctionTypeFlags<int_type>
1122-
withConcurrent(bool isSendable) const {
1122+
withSendable(bool isSendable) const {
11231123
return TargetFunctionTypeFlags<int_type>(
11241124
(Data & ~SendableMask) |
11251125
(isSendable ? SendableMask : 0));

include/swift/ABI/ObjectFile.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ class SwiftObjectFileFormatMachO : public SwiftObjectFileFormat {
6060
}
6161

6262
bool sectionContainsReflectionData(llvm::StringRef sectionName) override {
63-
return sectionName.startswith("__swift5_") || sectionName == "__const";
63+
return sectionName.starts_with("__swift5_") || sectionName == "__const";
6464
}
6565
};
6666

@@ -79,7 +79,7 @@ class SwiftObjectFileFormatELF : public SwiftObjectFileFormat {
7979
}
8080

8181
bool sectionContainsReflectionData(llvm::StringRef sectionName) override {
82-
return sectionName.startswith("swift5_");
82+
return sectionName.starts_with("swift5_");
8383
}
8484
};
8585

@@ -98,7 +98,7 @@ class SwiftObjectFileFormatCOFF : public SwiftObjectFileFormat {
9898
}
9999

100100
bool sectionContainsReflectionData(llvm::StringRef sectionName) override {
101-
return sectionName.startswith(".sw5");
101+
return sectionName.starts_with(".sw5");
102102
}
103103
};
104104
} // namespace swift

include/swift/APIDigester/ModuleAnalyzerNodes.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ class SDKNodeDecl: public SDKNode {
382382
swift::ReferenceOwnership getReferenceOwnership() const {
383383
return swift::ReferenceOwnership(ReferenceOwnership);
384384
}
385-
bool isObjc() const { return Usr.startswith("c:"); }
385+
bool isObjc() const { return Usr.starts_with("c:"); }
386386
static bool classof(const SDKNode *N);
387387
DeclKind getDeclKind() const { return DKind; }
388388
void printFullyQualifiedName(llvm::raw_ostream &OS) const;

include/swift/AST/ASTBridging.h

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,10 +126,12 @@ BridgedDeclNameRef
126126
BridgedDeclNameRef_createParsed(BridgedDeclBaseName cBaseName);
127127

128128
class BridgedDeclNameLoc {
129-
const void *_Nonnull LocationInfo;
129+
const void *_Nullable LocationInfo;
130130
size_t NumArgumentLabels;
131131

132132
public:
133+
BridgedDeclNameLoc() : LocationInfo(nullptr), NumArgumentLabels(0) {}
134+
133135
#ifdef USED_IN_CPP_SOURCE
134136
BridgedDeclNameLoc(swift::DeclNameLoc loc)
135137
: LocationInfo(loc.LocationInfo),
@@ -1033,6 +1035,10 @@ BridgedSubscriptDecl_asAbstractStorageDecl(BridgedSubscriptDecl decl);
10331035
// MARK: VarDecl
10341036
//===----------------------------------------------------------------------===//
10351037

1038+
SWIFT_NAME("BridgedVarDecl.createImplicitStringInterpolationVar(_:)")
1039+
BridgedVarDecl BridgedVarDec_createImplicitStringInterpolationVar(
1040+
BridgedDeclContext cDeclContext);
1041+
10361042
SWIFT_NAME("BridgedVarDecl.getSourceLocation(self:)")
10371043
BRIDGED_INLINE BridgedSourceLoc BridgedVarDecl_getSourceLocation(BridgedVarDecl decl);
10381044

@@ -1062,6 +1068,11 @@ struct BridgedCallArgument {
10621068
#endif
10631069
};
10641070

1071+
SWIFT_NAME("BridgedArgumentList.createImplicitUnlabeled(_:exprs:)")
1072+
BridgedArgumentList
1073+
BridgedArgumentList_createImplicitUnlabeled(BridgedASTContext cContext,
1074+
BridgedArrayRef cExprs);
1075+
10651076
SWIFT_NAME("BridgedArgumentList.createParsed(_:lParenLoc:args:rParenLoc:"
10661077
"firstTrailingClosureIndex:)")
10671078
BridgedArgumentList BridgedArgumentList_createParsed(
@@ -1137,6 +1148,12 @@ BridgedCopyExpr BridgedCopyExpr_createParsed(BridgedASTContext cContext,
11371148
BridgedSourceLoc cCopyLoc,
11381149
BridgedExpr cSubExpr);
11391150

1151+
SWIFT_NAME("BridgedDeclRefExpr.create(_:decl:loc:isImplicit:)")
1152+
BridgedDeclRefExpr BridgedDeclRefExpr_create(BridgedASTContext cContext,
1153+
BridgedDecl cDecl,
1154+
BridgedDeclNameLoc cLoc,
1155+
bool IsImplicit);
1156+
11401157
SWIFT_NAME("BridgedDictionaryExpr.createParsed(_:lBracketLoc:elements:"
11411158
"colonLocs:rBracketLoc:)")
11421159
BridgedDictionaryExpr BridgedDictionaryExpr_createParsed(
@@ -1173,6 +1190,13 @@ BridgedIntegerLiteralExpr_createParsed(BridgedASTContext cContext,
11731190
BridgedStringRef cStr,
11741191
BridgedSourceLoc cTokenLoc);
11751192

1193+
SWIFT_NAME("BridgedInterpolatedStringLiteralExpr.createParsed(_:loc:"
1194+
"literalCapacity:interpolationCount:appendingExpr:)")
1195+
BridgedInterpolatedStringLiteralExpr
1196+
BridgedInterpolatedStringLiteralExpr_createParsed(
1197+
BridgedASTContext cContext, BridgedSourceLoc cLoc, size_t literalCapacity,
1198+
size_t interpolationCount, BridgedTapExpr cAppendingExpr);
1199+
11761200
SWIFT_NAME("BridgedIsExpr.createParsed(_:isLoc:type:)")
11771201
BridgedIsExpr BridgedIsExpr_createParsed(BridgedASTContext cContext,
11781202
BridgedSourceLoc cIsLoc,
@@ -1226,6 +1250,10 @@ BridgedStringLiteralExpr_createParsed(BridgedASTContext cContext,
12261250
BridgedStringRef cStr,
12271251
BridgedSourceLoc cTokenLoc);
12281252

1253+
SWIFT_NAME("BridgedTapExpr.create(_:body:)")
1254+
BridgedTapExpr BridgedTapExpr_create(BridgedASTContext cContext,
1255+
BridgedBraceStmt cBody);
1256+
12291257
SWIFT_NAME("BridgedTernaryExpr.createParsed(_:questionLoc:thenExpr:colonLoc:)")
12301258
BridgedTernaryExpr BridgedTernaryExpr_createParsed(
12311259
BridgedASTContext cContext, BridgedSourceLoc cQuestionLoc,

include/swift/AST/ASTDemangler.h

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ class ASTBuilder {
8383
using BuiltProtocolDecl = swift::ProtocolDecl *;
8484
using BuiltGenericSignature = swift::GenericSignature;
8585
using BuiltRequirement = swift::Requirement;
86+
using BuiltInverseRequirement = swift::InverseRequirement;
8687
using BuiltSubstitutionMap = swift::SubstitutionMap;
8788

8889
static constexpr bool needsToPrecomputeParentGenericContextShapes = false;
@@ -161,8 +162,10 @@ class ASTBuilder {
161162

162163
Type createProtocolTypeFromDecl(ProtocolDecl *protocol);
163164

164-
Type createConstrainedExistentialType(Type base,
165-
ArrayRef<BuiltRequirement> constraints);
165+
Type createConstrainedExistentialType(
166+
Type base,
167+
ArrayRef<BuiltRequirement> constraints,
168+
ArrayRef<BuiltInverseRequirement> inverseRequirements);
166169

167170
Type createSymbolicExtendedExistentialType(NodePointer shapeNode,
168171
ArrayRef<Type> genArgs);
@@ -193,9 +196,11 @@ class ASTBuilder {
193196
using BuiltSILBoxField = llvm::PointerIntPair<Type, 1>;
194197
using BuiltSubstitution = std::pair<Type, Type>;
195198
using BuiltLayoutConstraint = swift::LayoutConstraint;
196-
Type createSILBoxTypeWithLayout(ArrayRef<BuiltSILBoxField> Fields,
197-
ArrayRef<BuiltSubstitution> Substitutions,
198-
ArrayRef<BuiltRequirement> Requirements);
199+
Type createSILBoxTypeWithLayout(
200+
ArrayRef<BuiltSILBoxField> Fields,
201+
ArrayRef<BuiltSubstitution> Substitutions,
202+
ArrayRef<BuiltRequirement> Requirements,
203+
ArrayRef<BuiltInverseRequirement> inverseRequirements);
199204

200205
bool isExistential(Type type) {
201206
return type->isExistentialType();
@@ -238,6 +243,9 @@ class ASTBuilder {
238243
unsigned size,
239244
unsigned alignment);
240245

246+
InverseRequirement createInverseRequirement(
247+
Type subject, InvertibleProtocolKind kind);
248+
241249
private:
242250
bool validateParentType(TypeDecl *decl, Type parent);
243251
CanGenericSignature demangleGenericSignature(

include/swift/AST/ASTMangler.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -461,12 +461,24 @@ class ASTMangler : public Mangler {
461461
bool innermostTypeDecl;
462462
bool extension;
463463
std::optional<unsigned> mangledDepth; // for inverses
464+
std::optional<unsigned> suppressedInnermostDepth;
464465
public:
465466
bool reachedInnermostTypeDecl() {
466467
bool answer = innermostTypeDecl;
467468
innermostTypeDecl = false;
468469
return answer;
469470
}
471+
472+
/// Whether inverses of the innermost declaration's generic parameters
473+
/// should be suppressed.
474+
///
475+
/// This makes sense only for entities that can only ever be defined
476+
/// within the primary type, such as enum cases and the stored properties
477+
/// of struct and class types.
478+
std::optional<unsigned> getSuppressedInnermostInversesDepth() const {
479+
return suppressedInnermostDepth;
480+
}
481+
470482
bool reachedExtension() const { return extension; }
471483
void setReachedExtension() { assert(!extension); extension = true; }
472484
GenericSignature getSignature() const { return sig; }

include/swift/AST/ASTPrinter.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ class ASTPrinter {
232232
void printKeyword(StringRef name,
233233
const PrintOptions &Opts,
234234
StringRef Suffix = "") {
235-
if (Opts.SkipUnderscoredKeywords && name.startswith("_"))
235+
if (Opts.SkipUnderscoredKeywords && name.starts_with("_"))
236236
return;
237237
assert(!name.empty() && "Tried to print empty keyword");
238238
callPrintNamePre(PrintNameContext::Keyword);

0 commit comments

Comments
 (0)