5.6. Release and Cross-Build Notes
Maintainer procedure: these commands build distribution artifacts and are not part of the DQ language or compiler command-line contract.
5.6.1 Release Packages
Build a compact Linux package without bundled LLVM tools:
make -j"$(nproc)" package-linux-release
Cross-build and package ARM64 Linux without bundled LLVM tools:
make -j"$(nproc)" package-arm64-linux
# Alias: make -j"$(nproc)" package-aarch64-linux
This uses the cross-aarch64-linux build and creates
dist/dq-<version>-arm64-linux.tar.gz. The archive includes dq-comp, dq-run,
dq-atrun, and the standard packages. The destination needs a 64-bit ARM Linux system,
the tools' runtime dependencies, and a compatible native Clang/linker.
Pass CMAKE_EXTRA_ARGS to select the ARM64 LLVM development libraries when
cross-building, as described in the cross-compilation guide below.
Linux archives include install.sh. After extraction on the destination, run
sudo ./install.sh for the default /usr/local installation, or
./install.sh --prefix "$HOME/.local" for a user installation. The installer also
accepts DESTDIR or --destdir for staging and requires no build tools.
The installer replaces shipped components and removes obsolete files, while
preserving additional packages under <prefix>/lib/dq/packages. Examples,
documentation, autotests, and the VS Code extension remain in the archive.
To prepare a deployment tree without changing the live installation:
DESTDIR=/tmp/dq-root ./install.sh --prefix /usr/local
To test an extracted Linux release, run from the archive's root:
bin/dq-atrun --clean -c bin/dq-comp -r autotest/tests
The archive includes the test helper package, C++ fixture, and internal test
executables under autotest/bin. Native x86 assembly tests are marked
hostarch('x64') and are skipped on ARM64. Driver tests also need c++, nm,
llvm-readobj, and wasm-objdump on PATH. When using versioned LLVM packages,
add their tool directory to PATH, for example /usr/lib/llvm-21/bin.
On Debian 13 (Trixie), after enabling Trixie backports, install the ARM64 release's runtime and linker dependencies plus the additional test tools with:
sudo apt install -t trixie-backports libc++1 libc++abi1 clang-21 lld-21 llvm-21
sudo apt install g++ libbacktrace-dev zlib1g-dev wabt wasi-libc
sudo apt install -t trixie-backports libclang-rt-21-dev-wasm32
export PATH="/usr/lib/llvm-21/bin:$PATH"
The ARM64 release requires libc++ 21; Trixie's default libc++ 19 is insufficient. The WASI libc and wasm32 builtins are needed by the cross-target driver tests.
Build the self-contained Linux package:
make -j"$(nproc)" package-linux-full-release
Build the full Windows package from its supported cross-build environment:
make -j"$(nproc)" package-windows-release
Run the normal compiler build and autotests before producing packages. Test each package in a clean environment that does not accidentally provide unbundled compiler or runtime dependencies.
5.6.2 Clean Ubuntu Test Container
One suitable smoke-test environment is Ubuntu 24.04:
docker pull ubuntu:24.04
docker run --name dq-ubuntu2404 -it ubuntu:24.04 bash
apt update
apt install -y lsb-release wget gnupg software-properties-common ca-certificates sudo
apt install -y build-essential git cmake ninja-build clang lld g++
Keep package-production dependencies separate from dependencies expected on the destination machine. The full package should be tested without relying on a system LLVM installation.
For compiler cross-compilation prerequisites and target toolchains, see Compiler Cross-Builds.
5.6.3 Compiler Cross-Builds
These procedures build dq-comp itself for another host architecture. They
require LLVM development libraries for that host, in addition to a cross C++
toolchain. Application cross-compilation
uses an existing compiler and has different requirements.
5.6.3.1 Prerequisites: LLVM Dependency
The DQ compiler depends on LLVM (find_package(LLVM REQUIRED CONFIG)). To build dq-comp so that it runs on a target architecture (e.g., aarch64), you must provide the target architecture's version of the LLVM libraries.
This is a known issue on Debian/Ubuntu: installing target-architecture -dev packages (like llvm-dev:arm64) can conflict with critical host packages and try to remove your desktop environment!
Do NOT use apt to install target LLVM development libraries.
Instead, use the official pre-built LLVM binaries for the target architecture, or build LLVM from source for the target.
5.6.3.1.1 Example: Setting up for aarch64-linux (Using Pre-built LLVM)
-
Install the cross-compiler and multiarch dependencies on the host: Because the official LLVM binaries for Linux are compiled with
libc++and Link Time Optimization (LTO), we must useclang++andlldas the cross-compiler instead of GNUg++. We also need the target architecture'slibc++,zlib,zstd, andlibxml2headers.bash sudo apt update sudo apt install clang lld \ libc++-dev:arm64 libc++abi-dev:arm64 \ zlib1g-dev:arm64 libzstd-dev:arm64 libxml2-dev:arm64 -
Download Pre-built LLVM for aarch64: Go to the LLVM GitHub Releases page and download the
aarch64-linux-gnutarball for the matching LLVM version (LLVM 21 for this compiler).
bash
mkdir -p sysroots/llvm-aarch64
cd sysroots
wget https://github.com/llvm/llvm-project/releases/download/llvmorg-21.1.0/LLVM-21.1.0-Linux-ARM64.tar.xz
tar -xf LLVM-21.1.0-Linux-ARM64.tar.xz -C llvm-aarch64 --strip-components=1
cd ..
- Configure CMake to use the downloaded LLVM:
When running the make target, you can pass the
LLVM_DIRdirectly via the environment or add it to the make command. For our setup, we can explicitly tell CMake where to find it:
bash
make cross-aarch64-linux CMAKE_EXTRA_ARGS="-DLLVM_DIR=$(pwd)/sysroots/llvm-aarch64/lib/cmake/llvm"
(For other architectures like armhf or riscv64, substitute :arm64 with :armhf or :riscv64 in the apt install command above.)
5.6.3.2 Building
We have added specific Make targets that simplify the CMake configuration for cross-compiling. The toolchain files are located in toolchains/.
5.6.3.2.1 Supported Targets
make cross-aarch64-linuxmake cross-armhf-linuxmake cross-rv64g-linuxmake cross-x86_64-win
5.6.3.3 Windows x86_64
The Windows cross-build is different from the Linux cross-builds in two ways:
- You need a Windows cross C/C++ toolchain that runs on the Linux host.
dq-compitself links against LLVM C++ libraries, so the build still needs Windows-target LLVM development libraries visible throughLLVM_DIR.
The llvm-mingw project is a good source for the first part. For an x86_64
Linux host building x86_64 Windows binaries, use the Ubuntu x86_64 tarball:
llvm-mingw-20251216-ucrt-ubuntu-22.04-x86_64.tar.xz
For the self-contained Windows DQ package, the matching Windows-hosted toolchain archive is also required:
llvm-mingw-20251216-ucrt-x86_64.zip
The .tar.xz archive is used on the Linux build machine. The .zip archive is
for the final Windows package, where it can provide clang.exe, lld, startup
objects, CRT libraries, and Windows import libraries for DQ users.
5.6.3.3.1 Recommended Local Layout
Keep checked-in CMake toolchain files in toolchains/. Put downloaded and
extracted binary toolchains under sysroots/, which is ignored by git:
mkdir -p sysroots/llvm-mingw-x86_64
tar -xf toolchains/llvm-mingw-20251216-ucrt-ubuntu-22.04-x86_64.tar.xz \
-C sysroots/llvm-mingw-x86_64 --strip-components=1
If the archive was downloaded somewhere else, use that path instead of the
toolchains/...tar.xz path above. The important result is:
sysroots/llvm-mingw-x86_64/bin/x86_64-w64-mingw32-clang++
sysroots/llvm-mingw-x86_64/x86_64-w64-mingw32/
5.6.3.3.2 Configure With llvm-mingw
The Windows toolchain file accepts DQ_MINGW_ROOT:
make cross-x86_64-win CMAKE_EXTRA_ARGS="\
-DDQ_MINGW_ROOT=$(pwd)/sysroots/llvm-mingw-x86_64 \
-DLLVM_DIR=/path/to/windows-target-llvm/lib/cmake/llvm"
DQ_MINGW_ROOT points CMake at the llvm-mingw cross compiler and target
headers/libraries. LLVM_DIR must point at the LLVM CMake package for LLVM
libraries that are linkable into the Windows dq-comp.exe.
5.6.3.3.3 Important Limitation
The llvm-mingw release archive provides the compiler, linker, CRT/startup objects, and Windows import libraries. It does not provide the LLVM development CMake package used by this project:
lib/cmake/llvm/LLVMConfig.cmake
Therefore llvm-mingw alone is probably not sufficient to build dq-comp.exe.
You still need a compatible Windows-target LLVM development build. The most
reliable approach is to build LLVM for the same MinGW/UCRT ABI using the
llvm-mingw toolchain, then pass that build's lib/cmake/llvm directory as
LLVM_DIR.
5.6.3.3.4 Building the Windows LLVM Development Package
Use the helper script after extracting the llvm-mingw Linux-hosted toolchain:
tools/build-llvm-mingw-ucrt.sh
The script builds and installs a minimal LLVM development package here:
sysroots/llvm-x86_64-win-ucrt
It downloads the matching LLVM source archive if needed, configures LLVM for
x86_64-w64-windows-gnu, builds the X86, ARM, RISC-V, and WebAssembly target
backends, disables optional compression/XML/terminal dependencies, and installs
the CMake package needed by dq-comp:
sysroots/llvm-x86_64-win-ucrt/lib/cmake/llvm/LLVMConfig.cmake
After that, configure the DQ compiler cross-build with:
make cross-x86_64-win CMAKE_EXTRA_ARGS="\
-DDQ_MINGW_ROOT=$(pwd)/sysroots/llvm-mingw-x86_64 \
-DLLVM_DIR=$(pwd)/sysroots/llvm-x86_64-win-ucrt/lib/cmake/llvm"
5.6.3.3.5 Building a Windows Release Package
After the cross-build succeeds, create a distributable zip with:
make package-x86_64-win CMAKE_EXTRA_ARGS="\
-DDQ_MINGW_ROOT=$(pwd)/sysroots/llvm-mingw-x86_64 \
-DLLVM_DIR=$(pwd)/sysroots/llvm-x86_64-win-ucrt/lib/cmake/llvm"
The package is written to:
dist/dq-<version>-x86_64-windows-ucrt.zip
It contains:
bin/dq-comp.exebin/dq-run.exebin/dq-atrun.exe- the required llvm-mingw runtime DLLs
- the Windows-hosted llvm-mingw linker SDK under
toolchain/llvm-mingw/ stdpkg/- project license and Windows quick-start notes
The package script expects the Windows-hosted llvm-mingw archive here by default:
sysroots/llvm-mingw-20251216-ucrt-x86_64.zip
Override it with DQ_WINDOWS_TOOLCHAIN_ZIP=/path/to/llvm-mingw-ucrt-x86_64.zip,
or use an already extracted Windows-hosted toolchain with:
DQ_WINDOWS_TOOLCHAIN_ROOT=/path/to/llvm-mingw-20251216-ucrt-x86_64 \
tools/package-windows-release.sh
At runtime, dq-comp.exe links application executables with the packaged
toolchain:
toolchain\llvm-mingw\bin\clang++.exe --target=x86_64-w64-windows-gnu -fuse-ld=lld
The compiler locates this driver relative to dq-comp.exe, so only the
package's bin directory needs to be added to PATH. Keep the package
directories together. Set DQ_LINKER_DRIVER to override that driver path.
If the helper needs a different native llvm-tblgen, set it explicitly:
LLVM_TBLGEN=/path/to/llvm-tblgen tools/build-llvm-mingw-ucrt.sh
Prebuilt package managers such as MSYS2 may also provide LLVMConfig.cmake, but
mixing their LLVM libraries with the llvm-mingw toolchain can create C++ ABI and
runtime mismatches. For the first Windows DQ package, prefer building LLVM with
the same llvm-mingw toolchain used to build dq-comp.exe.
5.6.3.3.6 Current Portability Status
The repository has a Windows cross-build target and the hosted compiler tools now build as Windows executables with the llvm-mingw toolchain:
dq-comp.exedq-run.exedq-atrun.exe
The compiler sources now guard Linux-only backtrace support, use portable
executable discovery, and provide a Windows implementation of the process
runner and artifact locking. Application linking uses the bundled llvm-mingw
toolchain, and hosted Windows programs use a minimal rtl/rtl_windows.dq
runtime entry point. On Windows x86-64, access violations are converted to
catchable ESegFault exceptions through native SEH. Fault recovery is tested
under Wine at -O0; see Exceptions and Backtraces
for implementation details and optimization limitations.
5.6.3.3.7 Example: Building for aarch64
From the root of the dq-lang project, run:
make cross-aarch64-linux
This will:
1. Create a build directory at build-cross/aarch64-linux.
2. Run CMake with the repository's toolchains/aarch64-linux.cmake toolchain file.
3. Compile the project for the aarch64 target.
The tools are written to build-cross/aarch64-linux/bin/, including dq-comp,
dq-run, and dq-atrun. They run on the target host, rather than on the build
machine.
5.6.3.4 Toolchain Files
If you need to customize the cross-compilation environment (for example, setting a custom sysroot or pointing to a locally compiled LLVM), you can edit the corresponding toolchain file in the toolchains/ directory.
CMAKE_FIND_ROOT_PATHis currently pointed to the default Ubuntu cross-compiler sysroot (e.g.,/usr/aarch64-linux-gnu).