<!-- Verbatim copy of `~/gainfx-toolchain/BUILD.md` from the build Mac (outside the repo), copied 2026-11-29. Everything below the line after this comment is that file, unchanged. -->
<!-- It records how the libfaust and LLVM inside the released gAIn FX app were built. If the original changes, copy it again; do not edit this copy by hand. -->

# gAIn FX toolchain: libfaust 2.88.0 + LLVM 23.1.6 for macOS 14.0 (arm64)

Built 2026-11-28 on macOS 27.2 with Xcode 27.2 (Apple clang 21.0.0, clang-2100.4.1.1), macOS SDK 27.2, CMake 4.5.0, Ninja 1.13.2.
Purpose: the gAIn FX release bundle carries this libfaust instead of Homebrew's (which is built for macOS 27.2 and needs
Homebrew's libLLVM, libz3 and libzstd). Use it with `GAINFX_TOOLCHAIN=$HOME/gainfx-toolchain/prefix` (see the repo's `docs/RELEASE.md`).

## Layout

```
~/gainfx-toolchain/
  src/      the two source tarballs and what was unpacked from them
  build/    build trees and logs (safe to delete; nothing in prefix/ points here)
  config/   gainfx-backends.cmake (the Faust backend selection)
  prefix/   the result: lib/libfaust.2.88.0.dylib (+ libfaust.2.dylib, libfaust.dylib), include/faust, share/faust/*.lib
            (also LLVM's static libraries lib/libLLVM*.a, include/llvm*, lib/cmake/llvm and bin/llvm-config, used only to link libfaust)
```

## Sources (official release archives, nothing else was downloaded)

| What | URL | SHA-256 |
|---|---|---|
| LLVM 23.1.6 | https://github.com/llvm/llvm-project/releases/download/llvmorg-23.1.6/llvm-project-23.1.6.src.tar.xz | `d3b86ab29cfb4445a6652e5c2642ccc75e04e38084dde3701d323320f35a31da` |
| Faust 2.88.0 (includes its `libraries/`) | https://github.com/grame-cncm/faust/releases/download/2.88.0/faust-2.88.0.tar.gz | `e4e175cf236924b5b7d4784cbb8c50cc01e211159e169655dd9e6d8f92b871d9` |

The Faust archive is the same file Homebrew's `faust` 2.88.0 formula builds from (same SHA-256). LLVM 23.1.6 is the version
Homebrew's `llvm` was at on this Mac (`/opt/homebrew/opt/llvm -> Cellar/llvm/23.1.6`), i.e. the LLVM the Homebrew libfaust loaded.
No source file was changed.

## What is built, and how it differs from Homebrew's

- LLVM: static libraries only, AArch64 target only, Release, RTTI and exceptions on (as Homebrew), assertions off.
  Off: clang/lld and every other project, tools, tests, examples, benchmarks, docs, Z3, zstd, zlib, libxml2, libedit, libffi, curl.
- Faust: only the dynamic library, only the LLVM backend (`faust/dsp/llvm-dsp.h`; gAIn FX uses nothing else), LLVM linked **statically into**
  `libfaust.2.88.0.dylib`. No `faust` executable, no OSC/HTTP/interpreter libraries. Homebrew's build has every backend and loads a shared libLLVM.
- Result: `libfaust.2.dylib` depends only on `/usr/lib/libSystem.B.dylib` and `/usr/lib/libc++.1.dylib`; install name `@rpath/libfaust.2.dylib`;
  `minos 14.0`; 68,622,152 bytes; SHA-256 of `prefix/lib/libfaust.2.88.0.dylib` as built on 2026-11-28:
  `70ba66f27759da7de9652ef810ee0ad457921b4d88984d0e2b4b988064f5fdfd` (a rebuild will not be bit-identical; the linker embeds a UUID).
- Build time on this Mac (18 cores, `nice -n 15`, `-j10`): LLVM 3 min 57 s, Faust 23 s, downloads and unpacking about 2 minutes.
- `share/faust/*.lib` (53 files) are byte-identical to Homebrew's 2.88.0 copies (checked with shasum).

## Commands

```bash
T=$HOME/gainfx-toolchain
mkdir -p $T/src $T/build $T/prefix $T/config
cd $T/src
curl -sSL -O https://github.com/llvm/llvm-project/releases/download/llvmorg-23.1.6/llvm-project-23.1.6.src.tar.xz
curl -sSL -O https://github.com/grame-cncm/faust/releases/download/2.88.0/faust-2.88.0.tar.gz
shasum -a 256 *.tar.*          # compare with the table above
# LLVM: only these folders are needed (llvm's CMake insists on libc/ being there)
tar xf llvm-project-23.1.6.src.tar.xz llvm-project-23.1.6.src/llvm llvm-project-23.1.6.src/cmake \
       llvm-project-23.1.6.src/third-party llvm-project-23.1.6.src/libc
tar xf faust-2.88.0.tar.gz

# ---- LLVM (about 4 minutes with -j10) ----
cd $T
nice -n 15 cmake -S src/llvm-project-23.1.6.src/llvm -B build/llvm -G Ninja \
  -DCMAKE_BUILD_TYPE=Release \
  -DCMAKE_INSTALL_PREFIX="$T/prefix" \
  -DCMAKE_OSX_DEPLOYMENT_TARGET=14.0 -DCMAKE_OSX_ARCHITECTURES=arm64 \
  -DLLVM_TARGETS_TO_BUILD=AArch64 -DLLVM_ENABLE_PROJECTS="" -DLLVM_ENABLE_RUNTIMES="" \
  -DLLVM_ENABLE_RTTI=ON -DLLVM_ENABLE_EH=ON -DLLVM_ENABLE_ASSERTIONS=OFF \
  -DLLVM_ENABLE_Z3_SOLVER=OFF -DLLVM_ENABLE_ZSTD=OFF -DLLVM_ENABLE_ZLIB=OFF -DLLVM_ENABLE_LIBXML2=OFF \
  -DLLVM_ENABLE_LIBEDIT=OFF -DLLVM_ENABLE_FFI=OFF -DLLVM_ENABLE_CURL=OFF -DLLVM_ENABLE_HTTPLIB=OFF -DLLVM_ENABLE_LIBPFM=OFF \
  -DLLVM_ENABLE_BINDINGS=OFF -DLLVM_ENABLE_OCAMLDOC=OFF \
  -DLLVM_INCLUDE_TESTS=OFF -DLLVM_INCLUDE_EXAMPLES=OFF -DLLVM_INCLUDE_BENCHMARKS=OFF -DLLVM_INCLUDE_DOCS=OFF \
  -DLLVM_BUILD_TOOLS=OFF -DLLVM_BUILD_UTILS=OFF -DLLVM_BUILD_LLVM_DYLIB=OFF -DLLVM_LINK_LLVM_DYLIB=OFF -DBUILD_SHARED_LIBS=OFF
nice -n 15 cmake --build build/llvm -j10 --target all llvm-config
nice -n 15 cmake --install build/llvm
mkdir -p prefix/bin && cp build/llvm/bin/llvm-config prefix/bin/    # tools are not installed with LLVM_BUILD_TOOLS=OFF; Faust's CMake needs this one

# ---- Faust (under a minute) ----
cat > config/gainfx-backends.cmake <<'EOF'
foreach(b AS C CODEBOX CPP CMAJOR CSHARP DLANG FIR INTERP INTERP_COMP JAVA JAX JULIA JSFX LINEN NNX OLDCPP RUST SDF3 TEMPLATE VHDL WASM)
  set(${b}_BACKEND OFF CACHE STRING "Include ${b} backend" FORCE)
endforeach()
set(LLVM_BACKEND DYNAMIC CACHE STRING "Include LLVM backend" FORCE)
EOF
nice -n 15 cmake -S src/faust-2.88.0/build -B build/faust -G Ninja \
  -C config/gainfx-backends.cmake \
  -DCMAKE_BUILD_TYPE=Release \
  -DCMAKE_INSTALL_PREFIX="$T/prefix" \
  -DCMAKE_OSX_DEPLOYMENT_TARGET=14.0 -DCMAKE_OSX_ARCHITECTURES=arm64 \
  -DCMAKE_CXX_FLAGS="-ffile-prefix-map=$T/src/faust-2.88.0/=" -DCMAKE_C_FLAGS="-ffile-prefix-map=$T/src/faust-2.88.0/=" \
  -DINCLUDE_EXECUTABLE=OFF -DINCLUDE_STATIC=OFF -DINCLUDE_DYNAMIC=ON \
  -DINCLUDE_OSC=OFF -DINCLUDE_HTTP=OFF -DINCLUDE_ITP=OFF -DINCLUDE_EMCC=OFF -DINCLUDE_WASM_GLUE=OFF \
  -DUSE_LLVM_CONFIG=ON -DLLVM_CONFIG="$T/prefix/bin/llvm-config" -DLINK_LLVM_STATIC=ON
nice -n 15 cmake --build build/faust -j10
nice -n 15 cmake --install build/faust
```

`-ffile-prefix-map` keeps the build folder's path (and so the user name) out of the library: Faust's assert messages then say
`compiler/boxes/boxes.cpp`, as Homebrew's build does, instead of the full path. It changes no code.

Faust's CMake writes the library into the source tree first (`src/faust-2.88.0/build/lib/`) and adds `/opt/homebrew/lib` to the
linker's search path when that folder exists; nothing is taken from it here (`llvm-config --link-static --system-libs` is just `-lm`,
and the result's `otool -L` shows only system libraries).

## Check the result

```bash
P=$HOME/gainfx-toolchain/prefix
otool -L $P/lib/libfaust.2.dylib            # only @rpath/libfaust.2.dylib, /usr/lib/libSystem.B.dylib, /usr/lib/libc++.1.dylib
vtool -show-build $P/lib/libfaust.2.dylib   # minos 14.0
ls $P/share/faust/*.lib | wc -l             # 53
```

Checked on 2026-11-28 (nothing here was run on macOS 14; no such Mac was available):
- LLVM compiles with `-Werror=unguarded-availability-new` (its own configure turns that on), and neither build log has an availability warning.
- `nm -u` on libfaust: 473 imports. The 216 from libc++ contain no symbol that libc++'s ABI changelog lists as added in LLVM 16 or later
  (Apple maps LLVM 16 to macOS 14.0, LLVM 18 to macOS 15.0). The rest are long-standing libSystem calls (libm, stdio, pthread, mmap, dlopen, ...).
- LLVM's default target triple is fixed at build time as `arm64-apple-darwin27.2.0`, but on Darwin LLVM replaces the version with the
  running system's (`uname`) each time it is asked (`llvm/lib/TargetParser/Unix/Host.inc`, `updateTripleOSVersion`), the same as Homebrew's build.

## Space

`build/` (about 725 MB) and the unpacked `src/llvm-project-23.1.6.src` (1.5 GB) and `src/faust-2.88.0` (526 MB) can be deleted;
keep `prefix/`, `config/`, this file and the two tarballs. To use LLVM's static libraries again after moving `prefix/`, nothing needs
rebuilding for gAIn FX: only `lib/libfaust*.dylib`, `include/faust` and `share/faust` are read by the app's build.
