SDL3, Vulkan and FFmpeg are mandatory for the NX runtime, including when running with -H.
There are no renderer or media-decoding disable options. Tools-only and GNUABI-only builds do not need them.
Persistent per-build-dir options (POSIX examples):
cmake --preset default -B build -DSNX_FFMPEG_ASM=OFF && cmake --build build
-DSNX_FFMPEG_ASM=OFF: omit x86-64 NASM assembly; slower FFmpeg decoding.-DSNX_LTO=ON: link with ThinLTO (cmake/lto.cmake). OFF by default, as the builds of
development and of pull requests run many times a day. The nightlies and releases turn it on for Linux x86-64,
Windows and Android's arm64-v8a. It is used in the Release, RelWithDebInfo and MinSizeRel builds, never in a Debug
one, where CMake's CheckIPOSupported links a test project with it: Linux, FreeBSD, Windows (Clang with lld:
MSYS2's CLANG64, llvm-mingw, the windows-cross preset) and Android. It does not work on macOS and iOS, where CMake
has no IPO for the apps' Swift, and the Linux and NetBSD cross builds' check does not test their preset's linker. It
stays off with SNX_TEST_SANITIZERS unless the linker is lld: ASan gives each object a common symbol, and GNU ld's LTO plugin
then takes every archive member that has one, with references that nothing defines. The objects
compile to LLVM bitcode, and the link optimizes across files: on a Steam Deck, the GPU thread's time for each frame
fell by 6.3%. The links take longer, the test programs' too. On an 8-thread Linux desktop a clean build took 440 s,
against 316 s without it. The link keeps each module's machine code in the build folder's thinlto-cache/ (2 GB at
most, with lld or GNU ld's gold plugin), so a build after an edit to one file of the renderer took 18 s, against
50 s without the cache and 4 s without ThinLTO. The installed scarletnx-recompiler archive and the parts it is made
of always build without it, as machine code (Library), and the game modules' runtime library is
compiled with its own flags, which it does not change.-DSDL3_FORCE_BUNDLED=ON: build the pinned SDL3 instead of using a system SDL3 development package
(-DCPM_DOWNLOAD_SDL3=ON before CPMUtil, read as this).-DSNX_DEPLOY=OFF: disable runtime deployment.-DSNX_JEMALLOC=OFF: keep the C library's malloc in scarletnx instead of the pinned jemalloc (default ON on Linux,
FreeBSD, macOS and Android, where it goes into the driver's executable libscarletnx-run.so that runs recompiles;
refused elsewhere and with SNX_TEST_SANITIZERS). A recompile's threads spend less time in malloc with jemalloc.-DSNX_TRACY=ON: build the runtime with the pinned Tracy profiler client (default OFF). For development builds
only; not available on iOS. It turns SNX_DEPLOY off, since the profiling runtime must not be copied over a
game; the tracy preset sets both. See profiling.-DSNX_RECOMPILED_DIR=/path: override deployment dir (default: empty, the data folder's recompiled/ the build
tree's driver uses). SNX_GAMES_DIR, its name before, is still taken while it is empty, said as it configures. A
tree whose value is the checkout's games/, the default before, is set back to empty.-DCPM_SOURCE_CACHE=/path: override source-download cache.-Dlz4_FORCE_SYSTEM=ON, -DVulkan-Headers_FORCE_SYSTEM=ON, -DSPIRV-Tools_FORCE_SYSTEM=ON,
-DCPMUTIL_FORCE_SYSTEM=ON: take LZ4, the Vulkan headers, SPIRV-Tools' programs, or all of them and SDL3, from the
system, which must have them at the pinned version or newer (default OFF: every package from its pinned source but
SDL3). -DCPM_USE_LOCAL_PACKAGES=ON before CPMUtil, read as these where the system has them. See
Rebuild, deploy, cache.-D<package>_CUSTOM_DIR=/path: a folder holding that package (as cpmfile.json names it) already, which the configure
takes instead of downloading it; refused for a package cpmfile.json patches, which CPMUtil would take unpatched.-DSNX_DEPS_CACHE=/path: reuse and publish finished FFmpeg, OpenSSL, jemalloc and SPIRV-Tools builds there
(default: the environment's SNX_DEPS_CACHE, else none).-DSNX_BUILD_NX=OFF: omit the Switch runtime (default ON).-DSNX_BUILD_GNUABI=OFF: omit the CPU-only Linux AArch64 runtime, see GNU ABI (default ON).-DSNX_BUILD_3DS=OFF: omit the 3DS layer, see 3DS (default ON).-DSNX_BUILD_GUI=OFF: omit the SDL3 launcher. The default is ON when SNX_BUILD_NX is on and SNX_TOOLS_ONLY
is not, OFF otherwise.-DSNX_TOOLS_ONLY=ON: build the extraction/recompilation driver without the runtime, see below (default OFF).-DSNX_RECOMPILER_SHARED=ON, -DSNX_RECOMPILER_INSTALL=ON: also build the recompiler as a shared library, and
install the library, see Library (defaults OFF and the value of SNX_TOOLS_ONLY).-DSNX_SAIL_X64: the x86-64 back end, ON on x86-64, Android's included, where it is the only code generator:
OFF there stops the configure, naming the value. The configure's log says whether it is built. Its instruction
selection is in the tree (tools/sailgen/sdm/x64_isel.inc,
sailgen). Its code needs SSE2 alone, which every x86-64
processor has. Without SSSE3, SSE4.1, SSE4.2 or PCLMULQDQ (a processor from before 2008, or an Android x86_64 device
without PCLMULQDQ: its ABI promises the others) the back end does their instructions by SSE2's or calls helpers of its
own, and the recompile and the run's log say so (cpu: this host has no PCLMULQDQ, done by the fallback).-DBUILD_TESTING=ON: build the tests, which the default and tracy presets leave out.-DSNX_BUILD_TESTING=OFF: leave the tests out whatever BUILD_TESTING says. ON by default when ScarletNX is the
top-level project, OFF when another project adds it with CPM or add_subdirectory (Library).Test options, all OFF by default. One that is on without BUILD_TESTING=ON stops the configure, as nothing would build
it:
-DSNX_TEST_SANITIZERS=ON: build the native tests, and the programs and libraries of the repository they run or
link, with ASan and UBSan (runtime_architecture names one left out). The runtime is one, so it is not deployed.
CI's job Linux (x86_64, ASan + UBSan) runs the tests this way, with
LSAN_OPTIONS=use_stacks=0:use_registers=0:suppressions=$PWD/tests/lsan.supp so the leak check finds the same leaks
on every machine, and none of the system's libraries' own (SDL's ALSA backend never frees ALSA's device hints).-DSNX_TEST_VULKAN=ON: add the offscreen Vulkan integration tests, see below.-DSNX_TEST_ONLINE_LIVE=ON: add online_presets_live, which asks each WFC service's DNS server over the
internet (labels external and network): how a service that stopped answering is found
(src/common/online).-DSNX_TEST_AMBERLITH=/path/to/amberlith.nro (SNX_TEST_EDENPROBE before 1.0.0, still read as it, and said):
add amberlith_vk_memory_1 and amberlith_vk_memory_2, which run Amberlith as CI does against its baseline, with
guest buffers copied and read in place (docs/dev/amberlith.md).-DSNX_TEST_SDM=ON: download the Intel SDM into CPM_SOURCE_CACHE once and have sailgen_sdm_isel make the x86-64
back end's instruction selection again from it, which must be the tree's (needs pdftotext, poppler's). The test is
skipped without the PDF, which -DSNX_SDM_PDF= also names. CI's Linux x86-64 job runs it on a run by hand, a
version's tag and a pull request that changes tools/sailgen.-DSNX_TEST_VP9_VECTORS=ON: add the nvdec_vp9_* tests, which run NVDEC's VP9 jobs on libvpx's test vectors;
configure downloads the 32 files from the WebM project into CPM_SOURCE_CACHE once. CI's Linux, ASan, Windows and
macOS jobs run them.-DSNX_TEST_AV1_VECTORS=ON, with -DSNX_TEST_VULKAN=ON: add vulkan_video_av1, which runs the native video
service's AV1 decoder on four of AOMedia's test vectors, with Vulkan Video where the device decodes AV1 and on the
CPU elsewhere; configure downloads the 8 files into CPM_SOURCE_CACHE once. CI's headless Vulkan step runs it.-DSNX_TEST_A64_FP_DIFF=ON: add the AArch64 FP differential test, which needs Python unicorn 2.1.4 and a native
Linux host.-DSNX_TEST_ARM_AOT=ON, -DSNX_TEST_ARM_DIFF=ON: the 3DS ARM11 and checked memory witnesses, and the comparisons of
the native back ends' A32 and Thumb blocks with Python's Unicorn, see 3DS.With Unicorn (its header and library, found or given with -DSNX_UNICORN_INCLUDE_DIR and -DSNX_UNICORN_LIBRARY; Python's
wheel of unicorn 2.1.4 has both, in its include and lib/libunicorn.so.2), the tests labelled unicorn run the code
that the native back ends make for the other machines against the recorded ends (test-references'
recompiler_backends/), and their A32 and Thumb blocks (arm_<machine>_vector
and its like, with SNX_TEST_ARM_DIFF) against Unicorn's own ARM core (ctest -L unicorn, ctest -L rv64 for one
machine).
CI's job Linux (x86_64, other machines under Unicorn) runs them in every pull request, run by hand and version's tag,
as all of its tests, and fails where a machine ran none (scripts/unicorn-tests.py). PowerPC64's are
skipped: Unicorn 2.1.4 as it is released does not hold the MSR of a 64-bit PowerPC.
The random A32 and Thumb blocks of the profiles and memories no Unicorn test draws (the Cortex-A9's, the ARM11's, the
ARM946E-S's and the ARM7TDMI's, hosted and checked memory, the ARM7TDMI's trace), arm_<machine>_<mode>, are held to
LLVM -O0's results as test-references' arm/ keeps them, recorded while the build had LLVM: a hash a block over its
states (arm_x64.c's --frozen, the file's first blocks on the machines under Unicorn). python3 tests/arm_frozen.py
verify build/tests/snx-test-arm-x64 --out <test-references>/arm runs every file and says what each covers; a change
to how arm_x64.c draws its blocks bumps its FROZEN_GENERATOR, and the files need another reference.
The tests labelled census (ctest -L census -V) recompile five whole programs that they make: a Switch game of a word of
each A64 instruction, the same with a Switch 2's NPDM, an NRO of it, a 32-bit Switch game of each A32 and Thumb
instruction, and a 3DS game of the ARM11's. Each prints how many of its functions or blocks this machine's native back
end made, and fails where it left any, naming its address and its word. On a machine with no native back end
they are skipped, saying so. CI's Linux, Windows and macOS jobs and its cross builds print the five counts, and fail
where one is missing (scripts/recompile-census.py).
# Build without the GUI launcher; SDL3 remains required by the runtime:
cmake --preset default -B build/headless-vk -DSNX_BUILD_GUI=OFF -DSNX_DEPLOY=OFF &&
cmake --build build/headless-vk
# Run Vulkan without a display server, a surface or a swapchain:
./build/headless-vk/scarletnx "Game.xci" -H
cmake --preset windows-cross && cmake --build --preset windows-cross
# -> build/windows-cross/scarletnx.exe; requires llvm-mingw on PATH
All NX builds use SDL3 and support -H at runtime. Omit the flag to run with a window.
Software Vulkan / lavapipe setup.
Offscreen integration test, with an installed Vulkan 1.3 ICD (lavapipe works):
cmake --preset default -B build/headless-vk -DSNX_BUILD_GUI=OFF \
-DSNX_DEPLOY=OFF -DBUILD_TESTING=ON -DSNX_TEST_VULKAN=ON && cmake --build build/headless-vk
# Set VK_DRIVER_FILES to your lavapipe manifest to force CPU rendering.
ctest --test-dir build/headless-vk -R vulkan_headless --output-on-failure
# the same with the validation layer
(cd build/headless-vk && src/nx/snx-test-vulkan -H --vk-validation=1)
The test uses synthetic pixels, not a game. It checks offscreen submissions, frame recycling, cropping,
readback hashes and PPM contents without WSI. Validation requires the Khronos validation layer to be installed.
It takes the runtime's settings as --KEY=VALUE (--vk-memory=2, --memory-traps=2) and stops on any
other argument. SNX_TEST_VULKAN is off by default so ordinary unit tests do not require an ICD.
Made from docs/dev/build.md at 69237645142c. GPL-3.0-or-later.