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
`swift_install_in_component` does not create a dependency between its
`TARGETS` and the `COMPONENT`, so one has to be created manually.
The missing dependency might cause invocations to CMake/Ninja for the
`install-*` targets to not build the required files before the
installation is performed. Because the normal `build-script` builds the
`all` target, this kind of missing dependencies like this are common.
This bit of code appeared in #76497 some days ago.
* [CMake] Give a dedicated component to compiler swift-syntax libraries
'compiler-swift-syntax-lib' so projects statically link to compiler
libraries (libAST etc) can use the required shared libraries.
rdar://135923606
* Update cmake caches
* Add back implicit `swift-syntax-lib` to `compiler` component for now
Some clients doesn't specify `swift-syntax-lib`.
Separate swift-syntax libs for the compiler and for the library plugins.
Compiler communicates with library plugins using serialized messages
just like executable plugins.
* `lib/swift/host/compiler/lib_Compiler*.dylib`(`lib/CompilerSwiftSyntax`):
swift-syntax libraries for compiler. Library evolution is disabled.
* Compiler (`ASTGen` and `swiftIDEUtilsBridging`) only depends on
`lib/swift/host/compiler` libraries.
* `SwiftInProcPluginServer`: In-process plugin server shared library.
This has one `swift_inproc_plugins_handle_message` entry point that
receives a message and return the response.
* In the compiler
* Add `-in-process-plugin-server-path` front-end option, which specifies
the `SwiftInProcPluginServer` shared library path.
* Remove `LoadedLibraryPlugin`, because all library plugins are managed
by `SwiftInProcPluginServer`
* Introduce abstract `CompilerPlugin` class that has 2 subclasses:
* `LoadedExecutablePlugin` existing class that represents an
executable plugin
* `InProcessPlugins` wraps `dlopen`ed `SwiftInProcPluginServer`
* Unified the code path in `TypeCheckMacros.cpp` and `ASTGen`, the
difference between executable plugins and library plugins are now
abstracted by `CompilerPlugin`