xcache (pronounced 'ten cache')

A remote content-addressable store for swiftc's compilation caching, hosted on Cloudflare Workers.

Native clients (castool, the swiftc plugin) speak to /__rpc over a WebSocket.

Install the prebuilt plugin (macOS arm64, Linux x86_64) and point it at this cache:

curl --proto '=https' --tlsv1.2 -sSf https://xcache.devtoo.ls/setup | sh

swiftc

swift build --product CASPlugin

swiftc -c main.swift -explicit-module-build -cache-compile-job \
  -cas-path ~/.cache/llbuild-cas \
  -cas-plugin-path .build/debug/libCASPlugin.so \
  -cas-plugin-option remote-url=https://xcache.devtoo.ls \
  -Rcache-compile-job

Without remote-url the plugin is a plain local CAS. Build the plugin in release (swift build -c release --product CASPlugin) for real use.

Xcode / Swift Build

Swift Build loads a CAS plugin from COMPILATION_CACHE_PLUGIN_PATH and reads COMPILATION_CACHE_REMOTE_SERVICE_PATH as a path to a file holding the Worker's URL (or the URL itself):

echo https://xcache.devtoo.ls > ~/.config/llbuild-cas-remote
swift build -c release --product CASPlugin   # libCASPlugin.dylib on macOS, .so on Linux
COMPILATION_CACHE_ENABLE_CACHING = YES
SWIFT_ENABLE_EXPLICIT_MODULES = YES
SWIFT_USE_INTEGRATED_DRIVER = YES
COMPILATION_CACHE_ENABLE_PLUGIN = YES
COMPILATION_CACHE_PLUGIN_PATH = /path/to/libCASPlugin.dylib
COMPILATION_CACHE_REMOTE_SERVICE_PATH = /Users/you/.config/llbuild-cas-remote