Building from Source
Prerequisites
Section titled “Prerequisites”| Dependency | Minimum Version | Purpose |
|---|---|---|
| GCC | 12+ | Kernel module & compiler build |
| GNU Make | 4.0+ | Build orchestration |
| Linux kernel headers | 6.1+ (6.6 LTS recommended) | Module compilation |
| CMake | 3.20+ | Compiler and tool build |
| QEMU (optional) | 8.0+ | Testing without real hardware |
aarch64-linux-gnu- (optional) |
- | Cross-compilation for ARM64 |
Install dependencies
Section titled “Install dependencies”macOS:
brew install cmake qemu aarch64-elf-gccDebian / Ubuntu:
sudo apt install build-essential cmake linux-headers-$(uname -r) \ qemu-system-arm gcc-aarch64-linux-gnuFedora:
sudo dnf install cmake kernel-devel qemu-system-aarch64 \ gcc-aarch64-linux-gnuBuild the Compiler
Section titled “Build the Compiler”./scripts/dev/build.sh --variant release kdalcThis builds the standalone compiler binary (kdalc) under
build/release/compiler/; the target kdalc_lib builds the library
(libkdalc.a) there too.
Build the CLI Tool
Section titled “Build the CLI Tool”./scripts/dev/build.sh --variant release kdalityThis places kdality under build/release/.
Build the Kernel Module
Section titled “Build the Kernel Module”# kbuild against a configured kernel tree (CMake cache variable KDIR;# the default is the running kernel's /lib/modules/<version>/build)CMAKE_ARGS="-DKDIR=/path/to/linux" ./scripts/dev/build.sh --variant debug moduleFor a cross build, the kbuild step needs ARCH and CROSS_COMPILE in its
environment as usual; KDAL’s CI builds the module against Linux v6.18 for
arm64 (kernel module build and KUnit in QEMU).
Build Everything
Section titled “Build Everything”The project uses CMake 3.20+, wrapped by convenience scripts under
scripts/dev/:
./scripts/dev/build.sh --variant release all # kdalc, libkdalc.a, kdality (+ VS Code extension if npm is found)./scripts/dev/build.sh --variant debug kdalc # debug compiler build./scripts/dev/build.sh --variant release kdality # optimized kdality./scripts/dev/build.sh --variant release vscode # VS Code extension (.vsix), needs npm./scripts/dev/build.sh --variant debug module # kernel module via kbuild (KDIR, above)./scripts/dev/build.sh --variant release install # install SDK (cmake --install)./scripts/dev/build.sh --variant asan clean # remove asan artifacts./scripts/dev/build.sh help # list the targetsBuild tree roles
Section titled “Build tree roles”build/release/: optimized local SDK/toolchain build; use for install, packaging, and normal local runs.build/debug/: symbols + assertions; use when stepping throughkdalc,kdality, or generated CMake targets.build/asan/: AddressSanitizer-enabled debug build; use for heap, stack, and use-after-free investigations.build/ci/release/: CI-only verification tree; keeps automation output separate from developer builds.build/nightly/<os-arch>/: nightly matrix tree per host/architecture; avoids stale cache reuse across targets.build/release/<os-arch>/: release packaging tree per artifact target in the release matrix.
Install targets
Section titled “Install targets”sudo ./scripts/dev/build.sh --variant release install # installs to /usr/local/To uninstall:
cmake --build --preset release --target uninstallInstalled layout:
<PREFIX>/├── bin/ kdalc, kdality├── include/ kdal/ headers, kdalc/ (the compiler's headers)├── lib/ libkdalc.a├── share/kdal/│ ├── stdlib/ .kdh standard library│ └── vim/ Vim plugin files└── lib/cmake/ CMake package filesVerify the Build
Section titled “Verify the Build”# Check compiler./build/release/compiler/kdalc -h
# Check tool./build/release/kdality -h
# Lint a sample file./build/release/kdality lint lang/stdlib/uart.kdh
# Run all tests./scripts/dev/test.sh --variant release allQEMU Testing
Section titled “QEMU Testing”Set up the QEMU aarch64 environment:
# Create guest rootfs and download the cloud image./scripts/env/prepare.sh
# Build the guest kernel image./scripts/env/kernel.sh
# Boot QEMU with shared directory./scripts/env/run.sh
# Inside QEMU guest:insmod /mnt/shared/kdal.kodmesg | grep kdal./kdality listCMake Modules
Section titled “CMake Modules”The KDAL SDK includes CMake integration for projects that use CMake
(cmake/CompileKDC.cmake):
find_package(KDAL REQUIRED)include(CompileKDC)
add_kdc_driver(my_uart SOURCE uart_hello.kdc KERNEL_DIR /lib/modules/6.6.0/build OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR}/kdc_out CROSS aarch64-linux-gnu- VERBOSE)add_kdc_driver runs the compiler and leaves the C source and
Makefile.kbuild in OUTPUT_DIR; the module build itself fails today
(open finding O7). cmake/KDALTesting.cmake adds add_kdal_kunit_test,
add_kdal_userspace_test and add_kdal_benchmark. There are no
kdal_lint or kdal_test_gen functions: run kdality lint and
kdality test-gen directly. CMake modules are installed to
<PREFIX>/lib/cmake/KDAL/.