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
openmp-23.1.2.tar.xz(170.9 MiB)
sha256c98bbef08a2b4c2613cd50e9aa9ae7b69b1fe6c16b2c40373bc0ab6116fdf78a
upstream: https://github.com/llvm/llvm-project/releases/download/llvmorg-23.1.2/llvm-project-23.1.2.src.tar.xz
archive copy: sources-4/toolchain--clang-23.1.2.tar.xz
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:
CMAKE_C_FLAGS_RELEASE— Replaces CMake’s Release flags,-O3 -DNDEBUG, with the tree’sCFLAGSand-DNDEBUG.CMAKE_CXX_FLAGS_RELEASE— The same for C++.LLVM_ENABLE_RUNTIMES="openmp"— The runtime theruntimesdirectory builds: this one.LLVM_ENABLE_PER_TARGET_RUNTIME_DIR=OFF— Installs into/usr/librather than a directory per target triple, solibomp.sois on the default library path.LIBOMP_ENABLE_SHARED=ON— Buildslibompas a shared library, which is upstream’s default, named.LIBOMP_INSTALL_ALIASES=OFF— Installs none of the alias links upstream adds by default,libgomp.so,libgomp.so.1andlibiomp5.so, each pointing atlibomp. The twolibgompnames are GCC’s library, and with the aliases a program linked with-lgomp, or one already linked against GCC’slibgomp.so.1, would get LLVM’s runtime instead.LIBOMP_ARCHER_SUPPORT=OFF— Builds no Archer, the OMPT tool that reports data races in OpenMP programs through ThreadSanitizer. compiler-rt builds no ThreadSanitizer, which does not support musl, so Archer would have nothing to report through.OPENMP_ENABLE_LIBOMPTARGET=OFF— Builds nolibomptarget, the runtime that offloads OpenMP regions to a GPU.
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.