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

60.2. openmp-23.1.2

LLVM's OpenMP runtime, libomp — what clang -fopenmp links

Version 23.1.2, release 1
Shelf toolchain — The native compilers, the linker, the C library, and the LLVM family
Phase 31_compilers (Compilers), 2 of 22 in build order
Licence Apache-2.0 WITH LLVM-exception
Homepage https://openmp.llvm.org/
Build time 3.2 SBU
Installed size 2.0 MiB in 22 files
Recipe ports/core/toolchain/openmp/kpkgbuild

About

libomp, LLVM’s OpenMP runtime: the library clang -fopenmp links, with omp.h and the OMPT tool interface headers, and libompd with its gdb plug-in for debugging OpenMP programs. clang depends on it, because clang’s driver uses libomp for -fopenmp by default.

GCC keeps its own OpenMP runtime, libgomp, which clang’s driver cannot use in its place, and its own omp.h in GCC’s private include directory, which GCC searches before /usr/include. The two runtimes therefore sit side by side: this port’s omp.h in /usr/include is the one clang finds, and GCC never sees it.

The port configures LLVM’s runtimes directory and names itself in LLVM_ENABLE_RUNTIMES, the build upstream supports for its runtimes; openmp’s own directory refuses to configure on its own (see A second version beside the first). It is compiled by GCC, the system compiler: this port builds before clang, which depends on it.

Why it is in KDOS

The comment above it in script/phases/31_compilers/packages.txt:

libomp, the runtime clang -fopenmp links.

Sources

Dependencies

Depends on: llvm, python3, cmake, ninja.

Required by (1): clang.

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/31_compilers/phase.env && kpkg install openmp'

What kpkg does

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

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/openmp
echo 'c98bbef08a2b4c2613cd50e9aa9ae7b69b1fe6c16b2c40373bc0ab6116fdf78a  openmp-23.1.2.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/openmp
SRC=$SRC_ROOT/openmp-23.1.2
PKG=$SRC_ROOT/pkg
rm -rf "$SRC_ROOT"
mkdir -p "$SRC" "$PKG"
tar --no-same-permissions --warning=no-unknown-keyword -xf openmp-23.1.2.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:

cmake -S runtimes -B build -G Ninja \
	-D CMAKE_INSTALL_PREFIX=/usr \
	-D CMAKE_BUILD_TYPE=Release \
	-D CMAKE_C_FLAGS_RELEASE="$CFLAGS -DNDEBUG" \
	-D CMAKE_CXX_FLAGS_RELEASE="$CXXFLAGS -DNDEBUG" \
	-D LLVM_ENABLE_RUNTIMES="openmp" \
	-D LLVM_ENABLE_PER_TARGET_RUNTIME_DIR=OFF \
	-D LLVM_INCLUDE_TESTS=OFF \
	-D LIBOMP_ENABLE_SHARED=ON \
	-D LIBOMP_INSTALL_ALIASES=OFF \
	-D LIBOMP_ARCHER_SUPPORT=OFF \
	-D OPENMP_ENABLE_LIBOMPTARGET=OFF \
	-Wno-dev

cmake --build build
DESTDIR=$PKG cmake --install build

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/openmp, 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 openmp-23.1.2-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/openmp, and runs the triggers its paths call for.

Contents

Installed libraries: libomp.so, libompd.so.

Installed directories: /usr/lib/cmake/openmp, /usr/share/gdb/python/ompd, /usr/share/licenses/openmp.