Add a new --enable-caching option that enables compilation caching for both
C/C++ (via clang-cache as compiler launcher) and Swift code (via
-cache-compile-job flags when bootstrapping=hosttools).
New options:
- --enable-caching: main toggle, incompatible with --sccache/--distcc
- --caching-cas-path: CAS directory (default: $BUILD_ROOT/cas)
- --caching-depscan-socket: depscan daemon socket path
- --caching-plugin-path: CAS plugin library path
- --caching-plugin-option: CAS plugin options (repeatable)
- --caching-prefix-map: enable source/SDK/toolchain prefix mapping
- --caching-remote-service-path: remote caching service with auto
plugin inference from Xcode and implied prefix mapping
The build script starts a clang-cache depscan daemon with reliable cleanup
via atexit and SIGTERM handlers. Per-product build directories get .cas-config
and compilation-prefix-map.json files written automatically.
Caching flags are applied to all Swift host compilation targets: compiler
sources, pure-swift host libraries (ASTGen, macros), swift-syntax, and
the new runtime build when --build-runtime-with-host-compiler is used.
When not using --caching-remote-service-path, enables CAS backend
(-Xfrontend -cas-backend -Xllvm -cas-friendly-debug-info) unless
SWIFT_CACHE_DISABLE_MCCAS is set.
A ninja wrapper is generated at build/<subdir>/build-utils/ninja for
cached incremental builds outside the build-script.
rdar://155876033
Assisted-By: Claude
Explanation: Documentation for WebAssembly: adjust WASI stdlib test execution command. Add `swift-*/bin` to `PATH`, since WASI tests require `sil-opt`.
Scope: documentation only
Risk: no risk, just updating documentation
Testing: Executed WASI stdlib tests locally on Ubuntu.
We cannot use spare bits or other overlapping storage layout tricks with fundamentally
address-only enums, and we can take advantage of this to do borrowing switches or other
in-place projections without copying the value. However, for resilient enums, the
implementation may use spare bit packing, but the type must be handled address-only
outside of its defining module, and we didn't have a way to express that with
borrowing switch. Optimization passes have also been running into problems with the
complexity that we were using `unchecked_take_enum_data_addr` sometimes as a pure
operation. This patch splits the instruction into three:
- `unchecked_inplace_enum_data_addr` represents a nondestructive in-place enum
projection. It is only allowed for enums whose projection operation is
nondestructive.
- `unchecked_take_enum_data_addr` represents a destructive enum projection,
invalidating the enum and leaving the payload to be further consumed.
This matches the current instruction's semantics.
- `unchecked_borrow_enum_data_addr` represents a borrowing enum projection.
The instruction takes a second operand for "scratch" space, which the
enum representation may be copied into in order to avoid invalidating the
enum value, so the result is dependent on the lifetime of both the
original enum and the scratch buffer. This allows for borrowing switches
over resilient enums.
`unchecked_borrow_enum_data_addr` is implemented by taking advantage of the
"address-only enums can't do spare bit optimization" property at runtime.
We inspect the operand type's bitwise-borrowability from its metadata. If
the type is bitwise-borrowable, then we are allowed to bitwise-copy the
enum to the scratch space and apply the projection to the scratch space,
preserving the original value. If the type is not bitwise-borrowable, then
we cannot use spare bit optimization in its layout, so we apply the
projection in-place.
Fixes rdar://174952822.
Ordinary base protocols use fixed-indexing to access the base index.
That means adding another base protocol to an existing protocol
can break the order of the entries, and thus clients, because we
otherwise order the base entires with TypeDecl::compare.
Reparentable protocols are meant to be resilient to that, so we
order them at the end of the base entries list, just before the
other resilient entries in the witness table.
This patch completes the picture, by having the reparentable
protocol entries be indexed resiliently, in the same manner as
associated conformances.
The difference is that we can skip the call to
`swift_getAssociatedConformanceWitness`
and compute the index directly by finding the distance of the
descriptors, because we know all base protocol witness table
entries are eagarly instantiated.
Using this distance protects us from the ordering problems
of entries among all of the reparentable base protocols.
resolves rdar://173409851
Disambiguation for future Emscripten support.
`grep -riI --exclude-dir=".git" "wasmstd" .`
and
`grep -riI --exclude-dir=".git" "wasm-std" .`
both did not find anything after these changes.
The `@export(interface)` and `@export(implementation)` attributes
SE-0497 are queried directly on AST nodes in several places within the
SIL pipeline. However, they don't persist when SIL functions are
serialized, meaning that clients of the original module might make
different assumptions about the availability of a given function's
definition.
Represent these attributes in a SIL function (as an optional
CodeGenerationModel), (de-)serialize them into the module, and add a
textual representation as SIL function attributes `[export_interface]`
and `[export_implementation]`.
Previously, it was possible to specify different debug formats for C/C++
and Swift code. In practice, binaries with both C/C++ and Swift code
would end up only having one format over the other, depending on the
exact project configuration. Since there is little value in having
separate debug information format, this changes the build configuration
to only have one debug format for both C/C++ and Swift code.
This also changes the default debug format to codeview. This is because
some of the toolchain binaries now exceed 4 GiB of dwarf debug
information, resulting in a build failure.
Conformance entries are used for fast conformance lookup, which doesn't need to query the runtime's conformance lookup table.
A conformance entry specifies if the class conforms or does not conform to a protocol.
At runtime, a type cast instruction to an existential can directly load the witness table pointer from the VTable.
If null, the class does not conform to the protocol.
Adjust compile command for building WebAssembly without building the
toolchain beforehand.
---------
Co-authored-by: Max Desiatov <m_desiatov@apple.com>
Add support for named location markers in the diagnostic verifier's
-verify mode. A marker is defined by placing `// #name` in a comment
and referenced with `@#name` in expected-diagnostic comments.
This enables stable references to diagnostic locations that don't break
when lines are added or removed, and supports cross-file references
where an expected-error in one file references a marker in another.
Also update to latest download URL, require a prebuilt compiler, and
remove a now unneeded bootstrapping flag.
These are flags I regularly use to build and test a trunk toolchain on
macOS, linux, and natively on Android, as can be seen in [step 4 of this
forum
post](https://forums.swift.org/t/building-a-linux-aarch64-toolchain-on-macos-with-containerization/84347),
though I left off the internal testing flags here.
Add an option so that when the backtracer starts in a crashing process
it will close all unnecessary file descriptors before it tries to start
gathering the backtrace as that may take time.
rdar://144402533
- Replace "Please feel free to add..." with professional contributor
guidance
- Replace "Well, this is not quite true..." aside with a clear note
about -Onone behavior
- Fix "When using swift LLDB REPL" to "When using the Swift REPL"
- Rewrite first-person informal narration in the LSAN section to
objective voice
Convert all 4-space-indented code blocks to fenced code blocks with
appropriate language tags:
- ```sh for shell commands
- ```lldb for LLDB sessions
- ```vim for vim configuration
- Plain ``` for output/logs and other content
This improves readability and enables syntax highlighting in
Markdown renderers.
- Add ### prefix to bare "Build inside the Container" text
- Standardize heading capitalization to Title Case
- Standardize double-backtick flags to single-backtick to match
the rest of the document
Fix mechanical typos and copy-paste errors throughout the document. E.x.:
- "we know to ignore swift_getGenericMetadata" → "we know to ignore
`GlobalARCOpts::run`" (copy-paste error; the example is about
GlobalARCOpts::run)
- "could the copy" → "could then copy"
- "Manually symbolication" → "Manual symbolication"
- "E.x."/"e.x." → "e.g." (standard abbreviation)