On macOS running on Intel hardware, a precompiled llvmpipe Vulkan driver
(libvulkan_lvp.dylib) and an ICD manifest (lvp_icd.x86_64.json) can be
installed beside the asy executable, alongside the other shared libraries.
When Metal is unavailable (e.g., headless VM), the renderer loader
automatically detects this and uses the llvmpipe driver via VK_ICD_FILENAMES.
The ICD JSON is looked up beside the executable first, then in the
Asymptote search path.

sudo port install meson ninja llvm-19 py312-mako py312-packaging xorg-libxshmfence
sudo ln -s /opt/local/bin/llvm-config-mp-19 /opt/local/bin/llvm-config

git clone https://gitlab.freedesktop.org/mesa/mesa.git
cd mesa

mkdir build && cd build
python3 -m venv venv
source venv/bin/activate
pip3 install mako packaging PyYAML
meson setup .. \
  --prefix=/opt/local \
  --pkg-config-path=/opt/local/lib/pkgconfig:/opt/local/share/pkgconfig \
  -Dgallium-drivers=llvmpipe \
  -Dvulkan-drivers=swrast \
  -Dglx=disabled \
  -Degl=disabled \
  -Dgles1=disabled \
  -Dgles2=disabled \
  -Dllvm=enabled \
  -Dbuildtype=release

ninja
sudo ninja install

# Install beside the asy executable (replace /path/to with the
# directory containing the asy binary):
cd /path/to
cp /opt/local/lib/libvulkan_lvp.dylib .
cp /opt/local/share/vulkan/icd.d/lvp_icd.x86_64.json .
install_name_tool -change @rpath/libLLVM.dylib \
  /opt/local/libexec/llvm-19/lib/libLLVM.dylib \
  libvulkan_lvp.dylib
sed -i '' 's|/opt/local/lib/libvulkan_lvp.dylib|./libvulkan_lvp.dylib|' \
  lvp_icd.x86_64.json

Runtime dependencies on the target Mac (must be installed via MacPorts):

  llvm-19          libLLVM.dylib (JIT compilation)
  spirv-tools      libSPIRV-Tools.dylib (shader compilation)
  xorg-libxcb      libxcb, libxcb-xfixes, libxcb-randr, libxcb-shm
  xorg-libX11      libX11-xcb
  zstd             libzstd.1.dylib
  expat            libexpat.1.dylib
  zlib             libz.1.dylib (usually pre-installed)

These are the same libraries needed to build Mesa, so if you built llvmpipe
from source they should already be present.
