Skip to content

Commit d57cedd

Browse files
authored
Merge branch 'main' into problem/63678072
2 parents d70e93b + 00a1e91 commit d57cedd

File tree

263 files changed

+9466
-4715
lines changed

Some content is hidden

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

263 files changed

+9466
-4715
lines changed

CMakeLists.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1042,7 +1042,11 @@ if(SWIFT_INCLUDE_TOOLS)
10421042
# "libswift" must come before "tools".
10431043
# It adds libswift module names to the global property "libswift_modules"
10441044
# which is used in add_swift_host_tool for the lldb workaround.
1045-
add_subdirectory(libswift)
1045+
#
1046+
# NOTE: We do not currently support libswift with the Xcode generator.
1047+
if (NOT CMAKE_GENERATOR STREQUAL "Xcode")
1048+
add_subdirectory(libswift)
1049+
endif()
10461050

10471051
# Always include this after including stdlib/!
10481052
# Refer to the large comment above the add_subdirectory(stdlib) call.

cmake/modules/AddSwift.cmake

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,36 @@ function(_set_target_prefix_and_suffix target kind sdk)
7575
endif()
7676
endfunction()
7777

78+
function(_add_host_variant_swift_sanitizer_flags target)
79+
if(LLVM_USE_SANITIZER)
80+
if(LLVM_USE_SANITIZER STREQUAL "Address")
81+
set(_Swift_SANITIZER_FLAGS "-sanitize=address")
82+
elseif(LLVM_USE_SANITIZER STREQUAL "HWAddress")
83+
# Not supported?
84+
elseif(LLVM_USE_SANITIZER MATCHES "Memory(WithOrigins)?")
85+
# Not supported
86+
if(LLVM_USE_SANITIZER STREQUAL "MemoryWithOrigins")
87+
# Not supported
88+
endif()
89+
elseif(LLVM_USE_SANITIZER STREQUAL "Undefined")
90+
set(_Swift_SANITIZER_FLAGS "-sanitize=undefined")
91+
elseif(LLVM_USE_SANITIZER STREQUAL "Thread")
92+
set(_Swift_SANITIZER_FLAGS "-sanitize=thread")
93+
elseif(LLVM_USE_SANITIZER STREQUAL "DataFlow")
94+
# Not supported
95+
elseif(LLVM_USE_SANITIZER STREQUAL "Address;Undefined" OR
96+
LLVM_USE_SANITIZER STREQUAL "Undefined;Address")
97+
set(_Swift_SANITIZER_FLAGS "-sanitize=address -sanitize=undefined")
98+
elseif(LLVM_USE_SANITIZER STREQUAL "Leaks")
99+
# Not supported
100+
else()
101+
message(SEND_ERROR "unsupported value for LLVM_USE_SANITIZER: ${LLVM_USE_SANITIZER}")
102+
endif()
103+
104+
target_compile_options(${name} PRIVATE $<$<COMPILE_LANGUAGE:Swift>:${_Swift_SANITIZER_FLAGS}>)
105+
endif()
106+
endfunction()
107+
78108
# Usage:
79109
# _add_host_variant_c_compile_link_flags(name)
80110
function(_add_host_variant_c_compile_link_flags name)
@@ -100,6 +130,8 @@ function(_add_host_variant_c_compile_link_flags name)
100130
MACCATALYST_BUILD_FLAVOR ""
101131
DEPLOYMENT_VERSION "${DEPLOYMENT_VERSION}")
102132
target_compile_options(${name} PRIVATE $<$<COMPILE_LANGUAGE:Swift>:-target;${target}>)
133+
134+
_add_host_variant_swift_sanitizer_flags(${name})
103135
endif()
104136

105137
set(_sysroot

docs/ABI/OldMangling.rst

Lines changed: 548 additions & 0 deletions
Large diffs are not rendered by default.

docs/Diagnostics.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ Clang also has a kind of diagnostic called a "remark", which represents informat
5151
- "...to silence this warning"
5252
- "...here" (for a purely locational note)
5353

54+
- If possible, it is best to include the name of the type or function that has the error, e.g. "non-actor type 'Nope' cannot ..." is better than "non-actor type cannot ...". It helps developers relate the error message to the specific type the error is about, even if the error would highlight the appropriate line / function in other ways.
5455

5556
### Locations and Highlights ###
5657

docs/HowToGuides/GettingStarted.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,7 @@ Phew, that's a lot to digest! Now let's proceed to the actual build itself!
246246
[using both Ninja and Xcode](#using-both-ninja-and-xcode).
247247
3. Build the toolchain with optimizations, debuginfo, and assertions and run
248248
the tests.
249+
macOS:
249250
- Via Ninja:
250251
```sh
251252
utils/build-script --skip-build-benchmarks \
@@ -259,10 +260,14 @@ Phew, that's a lot to digest! Now let's proceed to the actual build itself!
259260
--sccache --release-debuginfo --swift-disable-dead-stripping --test \
260261
--xcode
261262
```
263+
Linux (uses Ninja):
264+
```sh
265+
utils/build-script --release-debuginfo --test --skip-early-swift-driver
266+
```
262267
This will create a directory
263268
`swift-project/build/Ninja-RelWithDebInfoAssert`
264269
(with `Xcode` instead of `Ninja` if you used `--xcode`)
265-
containing the build artifacts.
270+
containing the Swift compiler and standard library and clang/LLVM build artifacts.
266271
- If the build succeeds: Once the build is complete, the tests will run.
267272
- If the tests are passing: Great! We can go to the next step.
268273
- If some tests are failing:
@@ -272,6 +277,10 @@ Phew, that's a lot to digest! Now let's proceed to the actual build itself!
272277
- If the build fails:
273278
See [Troubleshooting build issues](#troubleshooting-build-issues).
274279

280+
If you would like to additionally build the Swift corelibs,
281+
ie swift-corelibs-libdispatch, swift-corelibs-foundation, and swift-corelibs-xctest,
282+
on Linux, add the `--xctest` flag to `build-script`.
283+
275284
In the following sections, for simplicity, we will assume that you are using a
276285
`Ninja-RelWithDebInfoAssert` build on macOS running on an Intel-based Mac,
277286
unless explicitly mentioned otherwise. You will need to slightly tweak the paths

docs/RequestEvaluator.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ All existing requests inherit the [`SimpleRequest`](https://github.com/apple/swi
2121

2222
Each request can issue other requests, also through the evaluator. The evaluator automatically tracks such dependencies (by keeping a stack of the currently-active request evaluations). This information is valuable for a few reasons. First, it can help with debugging both correctness and performance, allowing one to visualize the dependencies evaluated when compiling a program. The current protocol has both full-graph visualization (via GraphViz output) and dependencies-for-a-single-request visualization (via a tree-like dump). Second, it ensures that we can detect cyclic dependencies (e.g., a cyclic inheritance hierarchy) correctly, because they show up as cycles in the dependency graph, allowing for proper diagnostics (for the user) and recovery (in the compiler). Third, it can eventually be leveraged to enable better incremental compilation--providing the ability to discover what information affected a particular type-checking decision, and propagate the effects of a specific change through the dependency graph.
2323

24-
The complete dependency graph formed by processing a source file can be visualized by passing the frontend option `-output-request-graphviz <filename>`. The dependency graph will be emitted using the [GraphViz](https://www.graphviz.org) format.
25-
2624
The frontend option `-debug-cycles` will provide debugging output for any cycle detected while processing the given source files. For example, running the [`circular_inheritance.swift` test](https://github.com/apple/swift/blob/main/test/decl/class/circular_inheritance.swift) from the Swift repository using this flag, e.g.,
2725

2826
```

docs/WindowsBuild.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,10 +135,12 @@ cmake -B "S:\b\1" ^
135135
ninja -C S:\b\1
136136
```
137137

138+
> **NOTE:** Linking with debug information (`-D LLVM_ENABLE_PDB=YES`) is very memory intensive. When building with parallel jobs, it is possible to consume upwards of 32 GiB of RAM. You can append `-D LLVM_PARALLEL_LINK_JOBS=N -D DLLVM_PARALLEL_LINK_JOBS=N` to reduce the number of parallel link operations to `N` which should help reduce the memory pressure. You may need to set this to a low number (e.g. 1) if you see build failures due to memory exhaustion.
139+
138140
## Running Swift tests on Windows
139141

140142
```cmd
141-
path S:\Library\icu-67\usr\bin;S:\b\1\bin;S:\b\1\tools\swift\libdispatch-prefix\bin;%PATH%;%ProgramFiles%\Git\usr\bin
143+
path S:\Library\icu-67\usr\bin;S:\b\1\bin;S:\b\1\tools\swift\libdispatch-windows-x86_64-prefix\bin;%PATH%;%ProgramFiles%\Git\usr\bin
142144
ninja -C S:\b\1 check-swift
143145
```
144146

include/swift/ABI/Executor.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,15 @@ class ExecutorRef {
8282
return ExecutorRef(actor, 0);
8383
}
8484

85+
/// Given a pointer to a serial executor and its SerialExecutor
86+
/// conformance, return an executor reference for it.
87+
static ExecutorRef forOrdinary(HeapObject *identity,
88+
const SerialExecutorWitnessTable *witnessTable) {
89+
assert(identity);
90+
assert(witnessTable);
91+
return ExecutorRef(identity, reinterpret_cast<uintptr_t>(witnessTable));
92+
}
93+
8594
HeapObject *getIdentity() const {
8695
return Identity;
8796
}
@@ -112,6 +121,9 @@ class ExecutorRef {
112121
return Identity != newExecutor.Identity;
113122
}
114123

124+
/// Is this executor the main executor?
125+
bool isMainExecutor() const;
126+
115127
bool operator==(ExecutorRef other) const {
116128
return Identity == other.Identity;
117129
}

include/swift/ABI/MetadataValues.h

Lines changed: 73 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2022,6 +2022,43 @@ enum class JobPriority : size_t {
20222022
Unspecified = 0x00,
20232023
};
20242024

2025+
/// Flags for task creation.
2026+
class TaskCreateFlags : public FlagSet<size_t> {
2027+
public:
2028+
enum {
2029+
Priority = 0,
2030+
Priority_width = 8,
2031+
2032+
Task_IsChildTask = 8,
2033+
// bit 9 is unused
2034+
Task_CopyTaskLocals = 10,
2035+
Task_InheritContext = 11,
2036+
Task_EnqueueJob = 12,
2037+
Task_AddPendingGroupTaskUnconditionally = 13,
2038+
};
2039+
2040+
explicit constexpr TaskCreateFlags(size_t bits) : FlagSet(bits) {}
2041+
constexpr TaskCreateFlags() {}
2042+
2043+
FLAGSET_DEFINE_FIELD_ACCESSORS(Priority, Priority_width, JobPriority,
2044+
getPriority, setPriority)
2045+
FLAGSET_DEFINE_FLAG_ACCESSORS(Task_IsChildTask,
2046+
isChildTask,
2047+
setIsChildTask)
2048+
FLAGSET_DEFINE_FLAG_ACCESSORS(Task_CopyTaskLocals,
2049+
copyTaskLocals,
2050+
setCopyTaskLocals)
2051+
FLAGSET_DEFINE_FLAG_ACCESSORS(Task_InheritContext,
2052+
inheritContext,
2053+
setInheritContext)
2054+
FLAGSET_DEFINE_FLAG_ACCESSORS(Task_EnqueueJob,
2055+
enqueueJob,
2056+
setEnqueueJob)
2057+
FLAGSET_DEFINE_FLAG_ACCESSORS(Task_AddPendingGroupTaskUnconditionally,
2058+
addPendingGroupTaskUnconditionally,
2059+
setAddPendingGroupTaskUnconditionally)
2060+
};
2061+
20252062
/// Flags for schedulable jobs.
20262063
class JobFlags : public FlagSet<uint32_t> {
20272064
public:
@@ -2036,10 +2073,11 @@ class JobFlags : public FlagSet<uint32_t> {
20362073

20372074
// Kind-specific flags.
20382075

2039-
Task_IsChildTask = 24,
2040-
Task_IsFuture = 25,
2041-
Task_IsGroupChildTask = 26,
2042-
Task_IsContinuingAsyncTask = 27,
2076+
Task_IsChildTask = 24,
2077+
Task_IsFuture = 25,
2078+
Task_IsGroupChildTask = 26,
2079+
// 27 is currently unused
2080+
Task_IsAsyncLetTask = 28,
20432081
};
20442082

20452083
explicit JobFlags(uint32_t bits) : FlagSet(bits) {}
@@ -2069,9 +2107,9 @@ class JobFlags : public FlagSet<uint32_t> {
20692107
FLAGSET_DEFINE_FLAG_ACCESSORS(Task_IsGroupChildTask,
20702108
task_isGroupChildTask,
20712109
task_setIsGroupChildTask)
2072-
FLAGSET_DEFINE_FLAG_ACCESSORS(Task_IsContinuingAsyncTask,
2073-
task_isContinuingAsyncTask,
2074-
task_setIsContinuingAsyncTask)
2110+
FLAGSET_DEFINE_FLAG_ACCESSORS(Task_IsAsyncLetTask,
2111+
task_isAsyncLetTask,
2112+
task_setIsAsyncLetTask)
20752113
};
20762114

20772115
/// Kinds of task status record.
@@ -2101,6 +2139,16 @@ enum class TaskStatusRecordKind : uint8_t {
21012139
Private_RecordLock = 192
21022140
};
21032141

2142+
/// Kinds of option records that can be passed to creating asynchronous tasks.
2143+
enum class TaskOptionRecordKind : uint8_t {
2144+
/// Request a task to be kicked off, or resumed, on a specific executor.
2145+
Executor = 0,
2146+
/// Request a child task to be part of a specific task group.
2147+
TaskGroup = 1,
2148+
/// Request a child task for an 'async let'.
2149+
AsyncLet = 2,
2150+
};
2151+
21042152
/// Flags for cancellation records.
21052153
class TaskStatusRecordFlags : public FlagSet<size_t> {
21062154
public:
@@ -2119,6 +2167,24 @@ class TaskStatusRecordFlags : public FlagSet<size_t> {
21192167
getKind, setKind)
21202168
};
21212169

2170+
/// Flags for task option records.
2171+
class TaskOptionRecordFlags : public FlagSet<size_t> {
2172+
public:
2173+
enum {
2174+
Kind = 0,
2175+
Kind_width = 8,
2176+
};
2177+
2178+
explicit TaskOptionRecordFlags(size_t bits) : FlagSet(bits) {}
2179+
constexpr TaskOptionRecordFlags() {}
2180+
TaskOptionRecordFlags(TaskOptionRecordKind kind) {
2181+
setKind(kind);
2182+
}
2183+
2184+
FLAGSET_DEFINE_FIELD_ACCESSORS(Kind, Kind_width, TaskOptionRecordKind,
2185+
getKind, setKind)
2186+
};
2187+
21222188
/// Kinds of async context.
21232189
enum class AsyncContextKind {
21242190
/// An ordinary asynchronous function.

include/swift/ABI/Task.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ class Job;
3434
struct OpaqueValue;
3535
struct SwiftError;
3636
class TaskStatusRecord;
37+
class TaskOptionRecord;
3738
class TaskGroup;
3839

3940
extern FullMetadata<DispatchClassMetadata> jobHeapMetadata;
@@ -537,6 +538,8 @@ inline void Job::runInFullyEstablishedContext() {
537538
return runSimpleInFullyEstablishedContext(); // 'return' forces tail call
538539
}
539540

541+
// ==== ------------------------------------------------------------------------
542+
540543
/// An asynchronous context within a task. Generally contexts are
541544
/// allocated using the task-local stack alloc/dealloc operations, but
542545
/// there's no guarantee of that, and the ABI is designed to permit

include/swift/ABI/TaskGroup.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ class alignas(Alignment_TaskGroup) TaskGroup {
3939

4040
/// Upon a future task's completion, offer it to the task group it belongs to.
4141
void offer(AsyncTask *completed, AsyncContext *context);
42+
43+
/// Checks the cancellation status of the group.
44+
bool isCancelled();
4245
};
4346

4447
} // end namespace swift

include/swift/ABI/TaskLocal.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
//
1111
//===----------------------------------------------------------------------===//
1212
//
13-
// Swift ABI describing tasks.
13+
// Swift ABI describing task locals.
1414
//
1515
//===----------------------------------------------------------------------===//
1616

0 commit comments

Comments
 (0)