spirv-tools: split outputs

Signed-off-by: Marcin Serwin <marcin@serwin.dev>
This commit is contained in:
Marcin Serwin
2026-01-06 13:24:48 +01:00
parent 9ab5458766
commit fc198f842e
2 changed files with 67 additions and 17 deletions

View File

@@ -0,0 +1,55 @@
From 2c8680324480bc0c20a026eb7ff9ffae1fe5fb13 Mon Sep 17 00:00:00 2001
From: Marcin Serwin <marcin@serwin.dev>
Date: Tue, 6 Jan 2026 13:22:42 +0100
Subject: [PATCH] Fix generated pkg-config modules with absolute installdirs
Fixes: https://github.com/KhronosGroup/SPIRV-Tools/issues/3905
Signed-off-by: Marcin Serwin <marcin@serwin.dev>
---
cmake/SPIRV-Tools-shared.pc.in | 4 ++--
cmake/SPIRV-Tools.pc.in | 4 ++--
cmake/write_pkg_config.cmake | 2 ++
3 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/cmake/SPIRV-Tools-shared.pc.in b/cmake/SPIRV-Tools-shared.pc.in
index 0dcaa276..f6a282bd 100644
--- a/cmake/SPIRV-Tools-shared.pc.in
+++ b/cmake/SPIRV-Tools-shared.pc.in
@@ -1,7 +1,7 @@
prefix=@CMAKE_INSTALL_PREFIX@
exec_prefix=${prefix}
-libdir=${prefix}/@CMAKE_INSTALL_LIBDIR@
-includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@
+libdir=@PKG_CONFIG_LIBDIR@
+includedir=@PKG_CONFIG_INCLUDEDIR@
Name: SPIRV-Tools
Description: Tools for SPIR-V
diff --git a/cmake/SPIRV-Tools.pc.in b/cmake/SPIRV-Tools.pc.in
index 2984dc57..62902e58 100644
--- a/cmake/SPIRV-Tools.pc.in
+++ b/cmake/SPIRV-Tools.pc.in
@@ -1,7 +1,7 @@
prefix=@CMAKE_INSTALL_PREFIX@
exec_prefix=${prefix}
-libdir=${prefix}/@CMAKE_INSTALL_LIBDIR@
-includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@
+libdir=@PKG_CONFIG_LIBDIR@
+includedir=@PKG_CONFIG_INCLUDEDIR@
Name: SPIRV-Tools
Description: Tools for SPIR-V
diff --git a/cmake/write_pkg_config.cmake b/cmake/write_pkg_config.cmake
index d367ce3e..ed932271 100644
--- a/cmake/write_pkg_config.cmake
+++ b/cmake/write_pkg_config.cmake
@@ -28,4 +28,6 @@ REGEX
# CMake support "-dev" in the version.
# If it's not a "-dev" version then ensure it ends with ".1"
string(REGEX REPLACE "-dev.1" ".0" CURRENT_VERSION "${CURRENT_VERSION}.1")
+cmake_path(APPEND PKG_CONFIG_LIBDIR "\${exec_prefix}" "${CMAKE_INSTALL_LIBDIR}")
+cmake_path(APPEND PKG_CONFIG_INCLUDEDIR "\${prefix}" "${CMAKE_INSTALL_INCLUDEDIR}")
configure_file(${TEMPLATE_FILE} ${OUT_FILE} @ONLY)
--
2.51.2

View File

@@ -18,10 +18,20 @@ stdenv.mkDerivation (finalAttrs: {
hash = "sha256-H+t7ZH4SB+XgWTLj9XaJWZwAWk8M2QeC98Zi5ay8PBc=";
};
patches = [
# https://github.com/KhronosGroup/SPIRV-Tools/pull/6483
./0001-Fix-generated-pkg-config-modules-with-absolute-insta.patch
]
# The cmake options are sufficient for turning on static building, but not
# for disabling shared building, just trim the shared lib from the CMake
# description
patches = lib.optional stdenv.hostPlatform.isStatic ./no-shared-libs.patch;
++ lib.optional stdenv.hostPlatform.isStatic ./no-shared-libs.patch;
outputs = [
"out"
"lib"
"dev"
];
nativeBuildInputs = [
cmake
@@ -29,27 +39,12 @@ stdenv.mkDerivation (finalAttrs: {
];
cmakeFlags = [
"-DSPIRV-Headers_SOURCE_DIR=${spirv-headers.src}"
"-DSPIRV-Headers_SOURCE_DIR=${spirv-headers}"
# Avoid blanket -Werror to evade build failures on less
# tested compilers.
"-DSPIRV_WERROR=OFF"
];
# https://github.com/KhronosGroup/SPIRV-Tools/issues/3905
postPatch = ''
substituteInPlace CMakeLists.txt \
--replace-fail '-P ''${CMAKE_CURRENT_SOURCE_DIR}/cmake/write_pkg_config.cmake' \
'-DCMAKE_INSTALL_FULL_LIBDIR=''${CMAKE_INSTALL_FULL_LIBDIR}
-DCMAKE_INSTALL_FULL_INCLUDEDIR=''${CMAKE_INSTALL_FULL_INCLUDEDIR}
-P ''${CMAKE_CURRENT_SOURCE_DIR}/cmake/write_pkg_config.cmake'
substituteInPlace cmake/SPIRV-Tools.pc.in \
--replace-fail '$'{prefix}/@CMAKE_INSTALL_LIBDIR@ @CMAKE_INSTALL_FULL_LIBDIR@ \
--replace-fail '$'{prefix}/@CMAKE_INSTALL_INCLUDEDIR@ @CMAKE_INSTALL_FULL_INCLUDEDIR@
substituteInPlace cmake/SPIRV-Tools-shared.pc.in \
--replace-fail '$'{prefix}/@CMAKE_INSTALL_LIBDIR@ @CMAKE_INSTALL_FULL_LIBDIR@ \
--replace-fail '$'{prefix}/@CMAKE_INSTALL_INCLUDEDIR@ @CMAKE_INSTALL_FULL_INCLUDEDIR@
'';
meta = {
description = "SPIR-V Tools project provides an API and commands for processing SPIR-V modules";
homepage = "https://github.com/KhronosGroup/SPIRV-Tools";