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
nasm-3.02.tar.xz(1.5 MiB)
sha25687336eba53b4acfe917424ab5d500d2b0054d9f5148d35c2273ccf2cfb712f0d
upstream: https://www.nasm.us/pub/nasm/releasebuilds/3.02/nasm-3.02.tar.xz
archive copy: sources-4/toolchain--nasm-3.02.tar.xz
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.
--disable-gdb, line 13: gdb (explained with the switches below)
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:
CFLAGS="$CFLAGS -std=gnu17"— adds-std=gnu17to the tree’s compile flags, which already carry-std=gnu11. NASM’sconfigurethen appends the first C standard it finds the compiler accepts, and GCC takes the last-std=on its command line, so the standard NASM is compiled with is the oneconfigurepicks.pa_cv_CFLAGS__std_c23=no— answersconfigure’s “does the compiler accept-std=c23?” probe in advance with “no”. NASM’sconfigure.actries-std=c23,-std=c17,-std=c11and-std=c99in that order and keeps the first that works; with C23 ruled out it settles on-std=c17, so NASM is compiled as C17 whatever the compiler’s newest standard is. The build log shows-std=gnu11 … -std=gnu17 -std=c17 -U__STRICT_ANSI__on every compile;-U__STRICT_ANSI__is a separate flagconfigureadds whichever standard it picks.--with-zlib— given without a path, this is whatconfiguredoes anyway: it searches for zlib’sinflatein-lzand links the system library when it finds it. Only when it finds none does it compile the copy of zlib’s inflate code NASM carries underzlib/.nasmlinkslibz.so.1;ndisasmlinks only the C library.--disable-gdb,pa_cv_CFLAGS__g3=no,pa_cv_CFLAGS__ggdb=no— NASM’sconfigureadds-g3to every compile unconditionally and-ggdbunless--disable-gdbis given (autoconf/m4/pa_option_debug.m4). Theg3answer stops-g3;--disable-gdbstops-ggdb, and theggdbanswer stops it a second time. No port ships debug information, and these are how this recipe keeps upstream’s own-gout (see What kpkg does around build.sh). The--disable-gdbhere is NASM’s switch for its debug flags, not a feature tied to thegdbport, so the “Optional, off in KDOS” entry above is not a lost feature.
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.