Skip to content

Commit 263f7a6

Browse files
Merge remote-tracking branch 'apple/main' into katei/merge-main-2021-12-07
2 parents 6899f34 + 1eadd44 commit 263f7a6

File tree

152 files changed

+2716
-1126
lines changed

Some content is hidden

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

152 files changed

+2716
-1126
lines changed

CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,8 @@ cmake_dependent_option(LIBSWIFT_BUILD_MODE "How to build libswift. Possible valu
194194
BOOTSTRAPPING: libswift is built with a 2-stage bootstrapping process
195195
BOOTSTRAPPING-WITH-HOSTLIBS: libswift is built with a 2-stage bootstrapping process,
196196
but the compiler links against the host system swift libs (macOS only)
197+
CROSSCOMPILE: libswift is cross-compiled with a native host compiler, provided in
198+
`SWIFT_NATIVE_SWIFT_TOOLS_PATH` (non-Darwin only)
197199
CROSSCOMPILE-WITH-HOSTLIBS: libswift is built with a bootstrapping-with-hostlibs compiled
198200
compiler, provided in `SWIFT_NATIVE_SWIFT_TOOLS_PATH`"
199201
OFF "NOT CMAKE_GENERATOR STREQUAL \"Xcode\"" OFF)
@@ -625,6 +627,8 @@ elseif(LIBSWIFT_BUILD_MODE MATCHES "BOOTSTRAPPING.*")
625627
set(SWIFT_EXEC_FOR_LIBSWIFT "${SWIFT_NATIVE_SWIFT_TOOLS_PATH}/swiftc")
626628
if(LIBSWIFT_BUILD_MODE STREQUAL "BOOTSTRAPPING-WITH-HOSTLIBS")
627629
set(LIBSWIFT_BUILD_MODE "CROSSCOMPILE-WITH-HOSTLIBS")
630+
elseif(LIBSWIFT_BUILD_MODE STREQUAL "BOOTSTRAPPING")
631+
set(LIBSWIFT_BUILD_MODE "CROSSCOMPILE")
628632
else()
629633
set(LIBSWIFT_BUILD_MODE "HOSTTOOLS")
630634
endif()

cmake/modules/AddSwift.cmake

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -741,6 +741,10 @@ function(add_libswift name)
741741
get_filename_component(swift_exec_bin_dir ${ALS_SWIFT_EXEC} DIRECTORY)
742742
set(sdk_option ${sdk_option} "-resource-dir" "${swift_exec_bin_dir}/../bootstrapping0/lib/swift")
743743
endif()
744+
elseif(${LIBSWIFT_BUILD_MODE} STREQUAL "CROSSCOMPILE")
745+
set(sdk_option "-sdk" "${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK}_ARCH_${SWIFT_HOST_VARIANT_ARCH}_PATH}")
746+
get_filename_component(swift_exec_bin_dir ${ALS_SWIFT_EXEC} DIRECTORY)
747+
set(sdk_option ${sdk_option} "-resource-dir" "${swift_exec_bin_dir}/../lib/swift")
744748
endif()
745749
get_versioned_target_triple(target ${SWIFT_HOST_VARIANT_SDK}
746750
${SWIFT_HOST_VARIANT_ARCH} "${deployment_version}")
@@ -967,22 +971,28 @@ function(add_swift_host_tool executable)
967971
BUILD_WITH_INSTALL_RPATH YES
968972
INSTALL_RPATH "${RPATH_LIST}")
969973
970-
elseif(SWIFT_HOST_VARIANT_SDK STREQUAL "LINUX" AND ASHT_HAS_LIBSWIFT AND LIBSWIFT_BUILD_MODE)
974+
elseif(SWIFT_HOST_VARIANT_SDK MATCHES "LINUX|ANDROID|OPENBSD" AND ASHT_HAS_LIBSWIFT AND LIBSWIFT_BUILD_MODE)
971975
set(swiftrt "swiftImageRegistrationObject${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK}_OBJECT_FORMAT}-${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK}_LIB_SUBDIR}-${SWIFT_HOST_VARIANT_ARCH}")
972-
if(LIBSWIFT_BUILD_MODE STREQUAL "HOSTTOOLS")
976+
if(${LIBSWIFT_BUILD_MODE} MATCHES "HOSTTOOLS|CROSSCOMPILE")
973977
# At build time and and run time, link against the swift libraries in the
974978
# installed host toolchain.
975979
get_filename_component(swift_bin_dir ${SWIFT_EXEC_FOR_LIBSWIFT} DIRECTORY)
976980
get_filename_component(swift_dir ${swift_bin_dir} DIRECTORY)
977-
set(host_lib_dir "${swift_dir}/lib/swift/linux")
981+
set(host_lib_dir "${swift_dir}/lib/swift/${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK}_LIB_SUBDIR}")
978982
979983
target_link_libraries(${executable} PRIVATE ${swiftrt})
980984
target_link_libraries(${executable} PRIVATE "swiftCore")
981985
982986
target_link_directories(${executable} PRIVATE ${host_lib_dir})
983-
set_target_properties(${executable} PROPERTIES
984-
BUILD_WITH_INSTALL_RPATH YES
985-
INSTALL_RPATH "${host_lib_dir}")
987+
if(LIBSWIFT_BUILD_MODE STREQUAL "HOSTTOOLS")
988+
set_target_properties(${executable} PROPERTIES
989+
BUILD_WITH_INSTALL_RPATH YES
990+
INSTALL_RPATH "${host_lib_dir}")
991+
else()
992+
set_target_properties(${executable} PROPERTIES
993+
BUILD_WITH_INSTALL_RPATH YES
994+
INSTALL_RPATH "$ORIGIN/../lib/swift/${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK}_LIB_SUBDIR}")
995+
endif()
986996
987997
elseif(LIBSWIFT_BUILD_MODE STREQUAL "BOOTSTRAPPING")
988998
# At build time link against the built swift libraries from the
@@ -998,7 +1008,7 @@ function(add_swift_host_tool executable)
9981008
# bootstrapping stage.
9991009
set_target_properties(${executable} PROPERTIES
10001010
BUILD_WITH_INSTALL_RPATH YES
1001-
INSTALL_RPATH "$ORIGIN/../lib/swift/${SWIFT_SDK_LINUX_LIB_SUBDIR}")
1011+
INSTALL_RPATH "$ORIGIN/../lib/swift/${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK}_LIB_SUBDIR}")
10021012
10031013
elseif(LIBSWIFT_BUILD_MODE STREQUAL "BOOTSTRAPPING-WITH-HOSTLIBS")
10041014
message(FATAL_ERROR "LIBSWIFT_BUILD_MODE 'BOOTSTRAPPING-WITH-HOSTLIBS' not supported on Linux")

docs/ReferenceGuides/UnderscoredAttributes.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -634,3 +634,8 @@ calls a runtime function which allocates memory or locks, respectively.
634634
The `@_noLocks` attribute implies `@_noAllocation` because a memory allocation
635635
also locks.
636636

637+
## `@_unavailableFromAsync`
638+
639+
Marks a synchronous API as being unavailable from asynchronous contexts. Direct
640+
usage of annotated API from asynchronous contexts will result in a warning from
641+
the compiler.

include/swift/AST/Attr.def

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -699,6 +699,12 @@ CONTEXTUAL_SIMPLE_DECL_ATTR(_const, CompileTimeConst,
699699
ABIStableToAdd | ABIStableToRemove | APIBreakingToAdd | APIStableToRemove,
700700
126)
701701

702+
SIMPLE_DECL_ATTR(_unavailableFromAsync, UnavailableFromAsync,
703+
OnFunc | OnConstructor | UserInaccessible |
704+
ABIStableToAdd | ABIStableToRemove |
705+
APIBreakingToAdd | APIStableToRemove,
706+
127)
707+
702708
// If you're adding a new underscored attribute here, please document it in
703709
// docs/ReferenceGuides/UnderscoredAttributes.md.
704710

include/swift/AST/DeclContext.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,9 @@ class alignas(1 << DeclContextAlignInBits) DeclContext
296296
/// Returns the kind of context this is.
297297
DeclContextKind getContextKind() const;
298298

299+
/// Returns whether this context asynchronous
300+
bool isAsyncContext() const;
301+
299302
/// Returns whether this context has value semantics.
300303
bool hasValueSemantics() const;
301304

include/swift/AST/DiagnosticsSIL.def

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -741,7 +741,7 @@ NOTE(sil_movekillscopyablevalue_use_here, none,
741741
NOTE(sil_movekillscopyablevalue_value_consumed_in_loop, none,
742742
"cyclic move here. move will occur multiple times in the loop", ())
743743
ERROR(sil_movekillscopyablevalue_move_applied_to_unsupported_move, none,
744-
"_move applied to value that the compiler does not supporting checking.",
744+
"_move applied to value that the compiler does not support checking",
745745
())
746746

747747
#define UNDEFINE_DIAGNOSTIC_MACROS

include/swift/AST/DiagnosticsSema.def

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4491,6 +4491,10 @@ ERROR(concurrent_access_of_local_capture,none,
44914491
"%select{mutation of|reference to}0 captured %1 %2 in "
44924492
"concurrently-executing code",
44934493
(bool, DescriptiveDeclKind, DeclName))
4494+
ERROR(non_sendable_capture,none,
4495+
"capture of %1 with non-sendable type %0 in a `@Sendable` closure",
4496+
(Type, DeclName))
4497+
44944498
NOTE(actor_isolated_sync_func,none,
44954499
"calls to %0 %1 from outside of its actor context are "
44964500
"implicitly asynchronous",
@@ -4705,6 +4709,15 @@ ERROR(actor_isolation_superclass_mismatch,none,
47054709
"%0 class %1 has different actor isolation from %2 superclass %3",
47064710
(ActorIsolation, DeclName, ActorIsolation, DeclName))
47074711

4712+
ERROR(async_decl_must_be_available_from_async,none,
4713+
"asynchronous %0 must be available from asynchronous contexts",
4714+
(DescriptiveDeclKind))
4715+
ERROR(async_named_decl_must_be_available_from_async,none,
4716+
"asynchronous %0 %1 must be available from asynchronous contexts",
4717+
(DescriptiveDeclKind, DeclName))
4718+
ERROR(async_unavailable_decl,none,
4719+
"%0 %1 is unavailable from asynchronous contexts", (DescriptiveDeclKind, DeclBaseName))
4720+
47084721
//------------------------------------------------------------------------------
47094722
// MARK: Type Check Types
47104723
//------------------------------------------------------------------------------

include/swift/AST/Expr.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3601,6 +3601,13 @@ class AbstractClosureExpr : public DeclContext, public Expr {
36013601
/// Only valid when \c hasSingleExpressionBody() is true.
36023602
Expr *getSingleExpressionBody() const;
36033603

3604+
/// Whether this closure has a body
3605+
bool hasBody() const;
3606+
3607+
/// Returns the body of closures that have a body
3608+
/// returns nullptr if the closure doesn't have a body
3609+
BraceStmt *getBody() const;
3610+
36043611
ClosureActorIsolation getActorIsolation() const { return actorIsolation; }
36053612

36063613
void setActorIsolation(ClosureActorIsolation actorIsolation) {

include/swift/Option/FrontendOptions.td

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -262,12 +262,12 @@ def enable_experimental_concurrency :
262262
def disable_lexical_lifetimes :
263263
Flag<["-"], "disable-lexical-lifetimes">,
264264
HelpText<"Disables early lexical lifetimes. Mutually exclusive with "
265-
"-enable-experimental-lexical-lifetimes">;
265+
"-enable-lexical-lifetimes">;
266266

267-
def enable_experimental_lexical_lifetimes :
268-
Flag<["-"], "enable-experimental-lexical-lifetimes">,
269-
HelpText<"Enable experimental lexical lifetimes. Mutually exclusive with "
270-
"-disable-early-lexical-lifetimes">;
267+
def enable_lexical_lifetimes :
268+
Flag<["-"], "enable-lexical-lifetimes">,
269+
HelpText<"Enable lexical lifetimes. Mutually exclusive with "
270+
"-disable-lexical-lifetimes">;
271271

272272
def enable_experimental_move_only :
273273
Flag<["-"], "enable-experimental-move-only">,

include/swift/SIL/BasicBlockDatastructures.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ class BasicBlockSetVector {
4343
iterator begin() const { return vector.begin(); }
4444
iterator end() const { return vector.end(); }
4545

46+
llvm::iterator_range<iterator> getRange() const {
47+
return llvm::make_range(begin(), end());
48+
}
49+
4650
bool empty() const { return vector.empty(); }
4751

4852
bool contains(SILBasicBlock *block) const { return set.contains(block); }

0 commit comments

Comments
 (0)