Skip to content

Commit 6eb688a

Browse files
authored
Merge pull request #4240 from swiftwasm/maxd/main-merge
Fix build issues with upstream `main`
2 parents 288a704 + 7300bc9 commit 6eb688a

File tree

192 files changed

+3991
-1903
lines changed

Some content is hidden

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

192 files changed

+3991
-1903
lines changed

CMakeLists.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,13 @@ set(SWIFT_TOOLS_ENABLE_LTO OFF CACHE STRING "Build Swift tools with LTO. One
192192
option only affects the tools that run on the host (the compiler), and has
193193
no effect on the target libraries (the standard library and the runtime).")
194194

195+
option(SWIFT_TOOLS_LD64_LTO_CODEGEN_ONLY_FOR_SUPPORTING_TARGETS
196+
"When building ThinLTO using ld64 on Darwin, controls whether to opt out of
197+
LLVM IR optimizations when linking targets that will get
198+
little benefit from it (e.g. tools for bootstrapping or
199+
debugging Swift)"
200+
FALSE)
201+
195202
option(BOOTSTRAPPING_MODE [=[
196203
How to build the swift compiler modules. Possible values are
197204
OFF: build without swift modules

cmake/modules/AddSwift.cmake

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -638,7 +638,7 @@ macro(add_swift_lib_subdirectory name)
638638
endmacro()
639639
640640
function(add_swift_host_tool executable)
641-
set(options HAS_SWIFT_MODULES)
641+
set(options HAS_SWIFT_MODULES THINLTO_LD64_ADD_FLTO_CODEGEN_ONLY)
642642
set(single_parameter_options SWIFT_COMPONENT BOOTSTRAPPING)
643643
set(multiple_parameter_options LLVM_LINK_COMPONENTS)
644644
@@ -861,6 +861,19 @@ function(add_swift_host_tool executable)
861861
endif()
862862
endif()
863863
864+
if(ASHT_THINLTO_LD64_ADD_FLTO_CODEGEN_ONLY)
865+
string(CONCAT lto_codegen_only_link_options
866+
"$<"
867+
"$<AND:"
868+
"$<BOOL:${LLVM_LINKER_IS_LD64}>,"
869+
"$<BOOL:${SWIFT_TOOLS_LD64_LTO_CODEGEN_ONLY_FOR_SUPPORTING_TARGETS}>,"
870+
"$<STREQUAL:${SWIFT_TOOLS_ENABLE_LTO},thin>"
871+
">:"
872+
"LINKER:-flto-codegen-only"
873+
">")
874+
target_link_options(${executable} PRIVATE "${lto_codegen_only_link_options}")
875+
endif()
876+
864877
if(NOT ${ASHT_SWIFT_COMPONENT} STREQUAL "no_component")
865878
add_dependencies(${ASHT_SWIFT_COMPONENT} ${executable})
866879
swift_install_in_component(TARGETS ${executable}

cmake/modules/UnixCompileRules.cmake

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,20 @@ set(CMAKE_C_ARCHIVE_FINISH "")
1111
set(CMAKE_CXX_ARCHIVE_CREATE "<CMAKE_AR> crs <TARGET> <LINK_FLAGS> <OBJECTS>")
1212
set(CMAKE_CXX_ARCHIVE_APPEND "<CMAKE_AR> qs <TARGET> <LINK_FLAGS> <OBJECTS>")
1313
set(CMAKE_CXX_ARCHIVE_FINISH "")
14+
15+
# When archiving LTO-based .o files with ar/ranlib/libtool on Darwin, the tools
16+
# use libLTO.dylib to inspect the bitcode files. However, by default the
17+
# "host" libLTO.dylib is loaded, which might be too old and not understand our
18+
# just-built bitcode format. So let's instead ask ar/ranlib/libtool to use the
19+
# just-built libLTO.dylib from the toolchain that we're using to build.
20+
if(APPLE AND SWIFT_NATIVE_CLANG_TOOLS_PATH)
21+
set(liblto_path "${SWIFT_NATIVE_CLANG_TOOLS_PATH}/../lib/libLTO.dylib")
22+
23+
set(CMAKE_C_ARCHIVE_CREATE "${CMAKE_COMMAND} -E env LIBLTO_PATH=${liblto_path} <CMAKE_AR> crs <TARGET> <LINK_FLAGS> <OBJECTS>")
24+
set(CMAKE_C_ARCHIVE_APPEND "${CMAKE_COMMAND} -E env LIBLTO_PATH=${liblto_path} <CMAKE_AR> qs <TARGET> <LINK_FLAGS> <OBJECTS>")
25+
set(CMAKE_C_ARCHIVE_FINISH "")
26+
27+
set(CMAKE_CXX_ARCHIVE_CREATE "${CMAKE_COMMAND} -E env LIBLTO_PATH=${liblto_path} <CMAKE_AR> crs <TARGET> <LINK_FLAGS> <OBJECTS>")
28+
set(CMAKE_CXX_ARCHIVE_APPEND "${CMAKE_COMMAND} -E env LIBLTO_PATH=${liblto_path} <CMAKE_AR> qs <TARGET> <LINK_FLAGS> <OBJECTS>")
29+
set(CMAKE_CXX_ARCHIVE_FINISH "")
30+
endif()

docs/ReferenceGuides/UnderscoredAttributes.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,15 @@ Most notably, default argument expressions are implicitly
3939
`@_alwaysEmitIntoClient`, which means that adding a default argument to a
4040
function which did not have one previously does not break ABI.
4141

42+
## `@_backDeploy(availabilitySpec ...)`
43+
44+
Causes the body of a function to be emitted into the module interface to be
45+
available for inlining in clients with deployment targets lower than the formal
46+
availability of the function. When inlined, the body of the function is
47+
transformed such that it calls the library's copy of the function if it is
48+
available at runtime. Otherwise, the copy of the original function body is
49+
executed.
50+
4251
## `@_assemblyVision`
4352

4453
Forces emission of assembly vision remarks for a function or method, showing

include/swift/ABI/ObjectFile.h

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,7 @@ class SwiftObjectFileFormatMachO : public SwiftObjectFileFormat {
6666
}
6767

6868
bool sectionContainsReflectionData(llvm::StringRef sectionName) override {
69-
// For Mach-O, the caller must call this function twice, once with just the
70-
// section name (ex `__swift5_fieldmd`), and again with the segment
71-
// qualified section name (ex `__DATA,__const`).
72-
return sectionName.startswith("__swift5_") ||
73-
sectionName == "__DATA_CONST,__const" ||
74-
sectionName == "__DATA,__const";
69+
return sectionName.startswith("__swift5_") || sectionName == "__const";
7570
}
7671
};
7772

include/swift/ABI/Task.h

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -290,23 +290,35 @@ class AsyncTask : public Job {
290290
return ResumeTask(ResumeContext); // 'return' forces tail call
291291
}
292292

293+
/// A task can have the following states:
294+
/// * suspended: In this state, a task is considered not runnable
295+
/// * enqueued: In this state, a task is considered runnable
296+
/// * running on a thread
297+
/// * completed
298+
///
299+
/// The following state transitions are possible:
300+
/// suspended -> enqueued
301+
/// suspended -> running
302+
/// enqueued -> running
303+
/// running -> suspended
304+
/// running -> completed
305+
/// running -> enqueued
306+
///
307+
/// The 4 methods below are how a task switches from one state to another.
308+
293309
/// Flag that this task is now running. This can update
294310
/// the priority stored in the job flags if the priority has been
295311
/// escalated.
296312
///
297313
/// Generally this should be done immediately after updating
298314
/// ActiveTask.
299315
void flagAsRunning();
300-
void flagAsRunning_slow();
301-
302-
/// Flag that this task is now suspended. This can update the
303-
/// priority stored in the job flags if the priority hsa been
304-
/// escalated. Generally this should be done immediately after
305-
/// clearing ActiveTask and immediately before enqueuing the task
306-
/// somewhere. TODO: record where the task is enqueued if
307-
/// possible.
316+
317+
/// Flag that this task is now suspended.
308318
void flagAsSuspended();
309-
void flagAsSuspended_slow();
319+
320+
/// Flag that the task is to be enqueued on the provided executor
321+
void flagAsEnqueuedOnExecutor(ExecutorRef newExecutor);
310322

311323
/// Flag that this task is now completed. This normally does not do anything
312324
/// but can be used to locally insert logging.

include/swift/AST/ArgumentList.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,11 +249,13 @@ class alignas(Argument) ArgumentList final
249249
static ArgumentList *
250250
createImplicit(ASTContext &ctx, SourceLoc lParenLoc, ArrayRef<Argument> args,
251251
SourceLoc rParenLoc,
252+
Optional<unsigned> firstTrailingClosureIndex = None,
252253
AllocationArena arena = AllocationArena::Permanent);
253254

254255
/// Create a new implicit ArgumentList with a set of \p args.
255256
static ArgumentList *
256257
createImplicit(ASTContext &ctx, ArrayRef<Argument> args,
258+
Optional<unsigned> firstTrailingClosureIndex = None,
257259
AllocationArena arena = AllocationArena::Permanent);
258260

259261
/// Create a new implicit ArgumentList with a single labeled argument

include/swift/AST/Attr.def

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -651,7 +651,7 @@ SIMPLE_DECL_ATTR(_inheritActorContext, InheritActorContext,
651651
// 117 was 'spawn' and is now unused
652652

653653
CONTEXTUAL_SIMPLE_DECL_ATTR(distributed, DistributedActor,
654-
DeclModifier | OnClass | OnFunc |
654+
DeclModifier | OnClass | OnFunc | OnVar |
655655
DistributedOnly |
656656
ABIBreakingToAdd | ABIBreakingToRemove |
657657
APIBreakingToAdd | APIBreakingToRemove,
@@ -713,6 +713,12 @@ DECL_ATTR(exclusivity, Exclusivity,
713713
ABIStableToAdd | ABIStableToRemove | APIStableToAdd | APIStableToRemove,
714714
128)
715715

716+
DECL_ATTR(_backDeploy, BackDeploy,
717+
OnAbstractFunction |
718+
AllowMultipleAttributes | LongAttribute | UserInaccessible |
719+
ABIStableToAdd | ABIStableToRemove | APIStableToAdd | APIBreakingToRemove,
720+
129)
721+
716722
// If you're adding a new underscored attribute here, please document it in
717723
// docs/ReferenceGuides/UnderscoredAttributes.md.
718724

include/swift/AST/Attr.h

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2172,6 +2172,30 @@ class UnavailableFromAsyncAttr : public DeclAttribute {
21722172
}
21732173
};
21742174

2175+
/// The @_backDeploy(...) attribute, used to make function declarations available
2176+
/// for back deployment to older OSes via emission into the client binary.
2177+
class BackDeployAttr: public DeclAttribute {
2178+
public:
2179+
BackDeployAttr(SourceLoc AtLoc, SourceRange Range,
2180+
PlatformKind Platform,
2181+
const llvm::VersionTuple Version,
2182+
bool Implicit)
2183+
: DeclAttribute(DAK_BackDeploy, AtLoc, Range, Implicit),
2184+
Platform(Platform),
2185+
Version(Version) {}
2186+
2187+
/// The platform the symbol is available for back deployment on.
2188+
const PlatformKind Platform;
2189+
2190+
/// The earliest platform version that may use the back deployed implementation.
2191+
const llvm::VersionTuple Version;
2192+
2193+
static bool classof(const DeclAttribute *DA) {
2194+
return DA->getKind() == DAK_BackDeploy;
2195+
}
2196+
};
2197+
2198+
21752199
/// Attributes that may be applied to declarations.
21762200
class DeclAttributes {
21772201
/// Linked list of declaration attributes.

include/swift/AST/Decl.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ enum class DescriptiveDeclKind : uint8_t {
144144
Property,
145145
StaticProperty,
146146
ClassProperty,
147+
DistributedProperty,
147148
InfixOperator,
148149
PrefixOperator,
149150
PostfixOperator,
@@ -5240,6 +5241,9 @@ class VarDecl : public AbstractStorageDecl {
52405241
/// Is this an "async let" property?
52415242
bool isAsyncLet() const;
52425243

5244+
/// Does this have a 'distributed' modifier?
5245+
bool isDistributed() const;
5246+
52435247
/// Is this a stored property that will _not_ trigger any user-defined code
52445248
/// upon any kind of access?
52455249
bool isOrdinaryStoredProperty() const;

0 commit comments

Comments
 (0)