116.4. glslang-16.6.0
OpenGL and OpenGL ES shader front end and validator
| Version | 16.6.0, release 1 |
| Shelf | gpu — The GPU stack: Mesa, DRM, GL and Vulkan loaders and headers, shader compilers, VA-API, OpenCL |
| Phase | 41_system (System), 597 of 1047 in build order |
| Licence | BSD-3-Clause AND BSD-2-Clause AND MIT AND Apache-2.0 |
| Homepage | https://github.com/KhronosGroup/glslang |
| Build time | 4.6 SBU |
| Installed size | 30.9 MiB in 48 files |
| Recipe | ports/core/gpu/glslang/kpkgbuild |
About
glslang is Khronos’s reference front end for the OpenGL and Vulkan shading languages: it parses and validates GLSL and HLSL and compiles them to SPIR-V. It installs the glslang command (with glslangValidator, its older name, as a link to it) and the libraries other compilers build on, among them libglslang and libSPIRV. shaderc, the compiler behind glslc, is built on it; ffmpeg compiles its Vulkan shaders with the glslang command at build time, and libplacebo links the library to compile shaders at run time.
build.sh configures and builds the project twice from the same tree, once shared (build-shared) and once static (build-static), and installs both into the one package.
Sources
glslang-16.6.0.tar.gz(4.4 MiB)
sha2569c09b901149c729df745057dafa815278aaa101b84d2b6e14f16a42de52f97f2
upstream: https://github.com/KhronosGroup/glslang/archive/16.6.0/glslang-16.6.0.tar.gz
archive copy: sources-2/gpu--glslang-16.6.0.tar.gz
Dependencies
Depends on: cmake, ninja, python3, spirv-tools.
Required by (9): ddnet, ffmpeg, gst-plugins-bad, libggml, libplacebo, mesa, mesa-demos, mesa-opencl, shaderc.
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/41_system/phase.env && kpkg install glslang'
What kpkg does
kpkg runs these steps, in this order, as root inside the chroot. The port directory is /ports/core/gpu/glslang.
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/gpu/glslang
echo '9c09b901149c729df745057dafa815278aaa101b84d2b6e14f16a42de52f97f2 glslang-16.6.0.tar.gz' | 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/glslang
SRC=$SRC_ROOT/glslang-16.6.0
PKG=$SRC_ROOT/pkg
rm -rf "$SRC_ROOT"
mkdir -p "$SRC" "$PKG"
tar --no-same-permissions --warning=no-unknown-keyword -xf glslang-16.6.0.tar.gz -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 CXXFLAGS="$CXXFLAGS -include cstdint"
cmake -B build-shared -G Ninja \
-DCMAKE_INSTALL_PREFIX=/usr \
-DCMAKE_INSTALL_LIBDIR=lib \
-DCMAKE_INSTALL_LIBEXECDIR=lib \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_C_FLAGS_RELEASE="$CFLAGS -DNDEBUG" \
-DCMAKE_CXX_FLAGS_RELEASE="$CXXFLAGS -DNDEBUG" \
-DBUILD_SHARED_LIBS=ON \
-DALLOW_EXTERNAL_SPIRV_TOOLS=ON \
-DENABLE_OPT=ON \
-DGLSLANG_TESTS=OFF \
-Wno-dev
ninja -C build-shared
cmake -B build-static -G Ninja \
-DCMAKE_INSTALL_PREFIX=/usr \
-DCMAKE_INSTALL_LIBDIR=lib \
-DCMAKE_INSTALL_LIBEXECDIR=lib \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_C_FLAGS_RELEASE="$CFLAGS -DNDEBUG" \
-DCMAKE_CXX_FLAGS_RELEASE="$CXXFLAGS -DNDEBUG" \
-DBUILD_SHARED_LIBS=OFF \
-DALLOW_EXTERNAL_SPIRV_TOOLS=ON \
-DENABLE_OPT=ON \
-DGLSLANG_TESTS=OFF \
-Wno-dev
ninja -C build-static
DESTDIR=$PKG ninja -C build-shared install
DESTDIR=$PKG ninja -C build-static install
cd $PKG/usr/lib
for lib in *.so; do
ln -sf "${lib}" "${lib}.0"
done
The switches, and why each is set:
-include cstdint— Compile every C++ file as though it began with#include <cstdint>, the header that declares the fixed-width integer types, for a source that uses them without including it (see-include <header>in the flag glossary).-DCMAKE_INSTALL_LIBEXECDIR=lib— Set CMake’s libexec directory to/usr/lib. No install rule in glslang’s CMake files names that directory, so on this release the switch changes nothing that is installed.-DBUILD_SHARED_LIBS=ON— Inbuild-shared: build the libraries as shared objects, each with glslang’s major version in its soname.-DBUILD_SHARED_LIBS=OFF— Inbuild-static: build the same libraries as static archives (libglslang.aand the rest).-DALLOW_EXTERNAL_SPIRV_TOOLS=ON— Build against the installed spirv-tools through its CMake package. Without it glslang looks for SPIRV-Tools in its ownExternal/directory, which a release archive does not populate (update_glslang_sources.pydownloads it).-DENABLE_OPT=ON— Build in SPIR-V optimisation through SPIRV-Tools’ optimiser library,SPIRV-Tools-opt. The installedglslang-config.cmakethen requiresSPIRV-Tools-optof every CMake consumer.-DGLSLANG_TESTS=OFF— Build none of glslang’s self-tests. The option defaults to on when glslang is the top-level CMake project, as it is here.
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/glslang, 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 glslang-16.6.0-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/glslang, and runs the triggers its paths call for.
Contents
Installed programs: glslang, glslangValidator.
Installed libraries: libGenericCodeGen.a, libMachineIndependent.a, libOSDependent.a, libSPIRV.a, libSPIRV.so, libglslang-default-resource-limits.a, libglslang-default-resource-limits.so, libglslang.a, libglslang.so.
Installed directories: /usr/include/glslang, /usr/lib/cmake/glslang, /usr/share/licenses/glslang.
Notes
The two installs write the same CMake package files under /usr/lib/cmake/glslang, and the static one runs second, so the installed glslang-targets.cmake describes the static archives: glslang::glslang, glslang::SPIRV and the rest are STATIC IMPORTED targets. A program that finds glslang through CMake, as shaderc does, links it statically; one that links -lglslang directly gets the shared library. The glslang command installed is the static build’s, for the same reason.
After the install, build.sh adds a .so.0 link beside every .so in /usr/lib, pointing at it: libglslang.so.0 to libglslang.so, and so on for each library.