Skip to the text
KDOS
Menu
kdos.dev KDOS from Scratch KDOS 0.2 · 4dd4a10 · 2026-11-30 Contents Index

42.7. nasm-3.02

The Netwide Assembler, a portable 80x86 assembler

Version 3.02, release 1
Shelf toolchain — The native compilers, the linker, the C library, and the LLVM family
Phase 30_foundation (Build Foundation), 86 of 127 in build order
Licence BSD-2-Clause
Homepage https://www.nasm.us/
Build time 0.4 SBU
Installed size 2.9 MiB in 5 files
Recipe ports/core/toolchain/nasm/kpkgbuild

About

NASM is an assembler for the x86 instruction set, with its own Intel-style syntax. KDOS does not run it directly; it is a build tool for the ports that carry hand-written SIMD kernels in NASM syntax. The codecs (ffmpeg, x264, x265, dav1d, svt-av1, libvpx, openh264), libjpeg-turbo, libass, firefox-esr, librewolf, thunderbird, qemu and the limine boot loader all name it in depends. The tree builds those ports with their assembly on, as Writing ports sets out, and NASM is the assembler that assembly is written for.

The package is two programs, nasm and ndisasm, with their manual pages.

Sources

Dependencies

Depends on: zlib.

Required by (21): avidemux, dav1d, ffmpeg, firefox-esr, gst-plugins-good, handbrake, kodi, koreader, libass, libjpeg-turbo, libretro-mupen64plus-next, librewolf, libvpx, limine, mupen64plus, openh264, qemu, svt-av1, thunderbird, x264, x265.

Optional, off in KDOS

These switches in build.sh turn off a feature whose library is a port here. The recipe may turn each off on purpose, or because the library was not yet a port when the recipe was written; this list cannot tell which.

Installation

From the repository root, inside the build container, this is the line kdosbuild runs for the port:

script/chroot/exec.sh bash -c 'source script/phases/30_foundation/phase.env && kpkg install nasm'

What kpkg does

kpkg runs these steps, in this order, as root inside the chroot. The port directory is /ports/core/toolchain/nasm.

1. Verify every declared source. Each file a sha256 = line names, found in the port directory or in /var/cache/kpkg/sources, must hash to its line; a mismatch stops the build before anything is unpacked.

cd /ports/core/toolchain/nasm
echo '87336eba53b4acfe917424ab5d500d2b0054d9f5148d35c2273ccf2cfb712f0d  nasm-3.02.tar.xz' | sha256sum -c -

2. Unpack. The work directory is emptied and the first source is unpacked into $SRC with its top directory stripped; any later tarball lands unstripped beside it in $SRC_ROOT, and a file that is not a tarball is copied into $SRC.

SRC_ROOT=/var/cache/kpkg/work/nasm
SRC=$SRC_ROOT/nasm-3.02
PKG=$SRC_ROOT/pkg
rm -rf "$SRC_ROOT"
mkdir -p "$SRC" "$PKG"
tar --no-same-permissions --warning=no-unknown-keyword -xf nasm-3.02.tar.xz -C "$SRC" --strip-components=1

Every config.guess and config.sub older than automake’s is then replaced with automake’s, so a configure script recognises the musl target.

3. Build. build.sh is sourced in a subshell under set -e, from $SRC, with name, version, release and the five paths PKGNAME, PORT_SRC, SRC_ROOT, SRC and PKG set as shell variables. Its body, verbatim:

export CFLAGS="$CFLAGS -std=gnu17"
./configure --prefix=/usr --with-zlib --disable-gdb pa_cv_CFLAGS__std_c23=no pa_cv_CFLAGS__g3=no pa_cv_CFLAGS__ggdb=no
make
make DESTDIR=$PKG install

The switches, and why each is set:

The common switches of each build system are explained in the Flag glossary.

4. Package. kpkg removes libtool archives, the info directory index, mimeinfo.cache and every fonts.dir from $PKG, copies the source’s licence files into /usr/share/licenses/nasm, prunes what the image does not ship, lints the tree and rolls it reproducibly:

tar --sort=name --format=gnu --numeric-owner --owner=0 --group=0 \
    --mtime=@$SOURCE_DATE_EPOCH \
    --use-compress-program='xz -9 -T0 --block-size=32MiB --no-adjust' \
    -cf nasm-3.02-1.tar.xz -C "$PKG" .

5. Adopt. kpkgadd installs the package’s files over the root, refusing a path another package owns, records the file list in /var/lib/kpkg/db/nasm, and runs the triggers its paths call for.

Contents

Installed programs: nasm, ndisasm.

Installed directories: /usr/share/licenses/nasm.

Short descriptions

nasm the Netwide Assembler, a portable 80x86 assembler
ndisasm the Netwide Disassembler, an 80x86 binary file disassembler

Notes

A pa_cv_CFLAGS_<flag> answer only works while upstream’s probe keeps its name. The names are built from the flag text by NASM’s PA_SHSYM macro (autoconf/m4/pa_shsym.m4): every character that cannot appear in a shell variable becomes _, and + becomes x. If a release renames a probe, the answer is silently ignored and the flag it was meant to stop returns; read the checking whether gcc accepts … lines of the build log after a version bump.