commit:     d26fd29f801bbe025e9b6e18e514e0fc976c8cdc
Author:     Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Sun Apr 24 15:39:13 2022 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Sun Apr 24 15:43:25 2022 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=d26fd29f

dev-util/spirv-tools: fix hardcoded librt path in installed CMake files

Fixes build failure after upgrading glibc in e.g. intel-graphics-compiler.

Reported-by: Jan Henke <gentoo <AT> taujhe.de>
Signed-off-by: Sam James <sam <AT> gentoo.org>

 .../files/spirv-tools-1.3.211-cmake-librt.patch    | 40 ++++++++++++++++++
 dev-util/spirv-tools/spirv-tools-1.3.211-r1.ebuild | 49 ++++++++++++++++++++++
 2 files changed, 89 insertions(+)

diff --git a/dev-util/spirv-tools/files/spirv-tools-1.3.211-cmake-librt.patch 
b/dev-util/spirv-tools/files/spirv-tools-1.3.211-cmake-librt.patch
new file mode 100644
index 000000000000..48afd5a736f1
--- /dev/null
+++ b/dev-util/spirv-tools/files/spirv-tools-1.3.211-cmake-librt.patch
@@ -0,0 +1,40 @@
+https://github.com/KhronosGroup/SPIRV-Tools/commit/cb96abbf7affd986016f17dd09f9f971138a922b
+
+From: Chad Versace <[email protected]>
+Date: Thu, 14 Apr 2022 06:04:12 -0700
+Subject: [PATCH] Fix CMake for librt (#4773)
+
+In the installed file
+/usr/lib64/cmake/SPIRV-Tools/SPIRV-ToolsTarget.cmake, occurences of
+librt in the INTERFACE_LINK_LIBRARIES property are incorrect.  The
+property contains the absolute path to librt. In most situations, this
+produces no problem. But when building in a sysroot, which is commonly
+done when cross-compiling, the absolute path breaks dependent projects.
+
+For example, when building spirv-tools using the Chrome OS SDK, and
+targeting the board 'volteer', where the build sysroot is
+'/build/volteer', the file includes this line
+    INTERFACE_LINK_LIBRARIES "/build/volteer/usr/lib64/librt.so"
+when it should instead say
+    INTERFACE_LINK_LIBRARIES "rt"
+
+The CMake documentation agrees [1]:
+    Note that it is not advisable to populate the
+    INTERFACE_LINK_LIBRARIES of a target with absolute paths to
+    dependencies. That would hard-code into installed packages the
+    library file paths for dependencies as found on the machine the
+    package was made on.
+
+[1] https://cmake.org/cmake/help/latest/prop_tgt/INTERFACE_LINK_LIBRARIES.html
+--- a/source/CMakeLists.txt
++++ b/source/CMakeLists.txt
+@@ -407,7 +407,7 @@ if("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
+   find_library(LIBRT rt)
+   if(LIBRT)
+     foreach(target ${SPIRV_TOOLS_TARGETS})
+-      target_link_libraries(${target} ${LIBRT})
++      target_link_libraries(${target} rt)
+     endforeach()
+   endif()
+ endif()
+

diff --git a/dev-util/spirv-tools/spirv-tools-1.3.211-r1.ebuild 
b/dev-util/spirv-tools/spirv-tools-1.3.211-r1.ebuild
new file mode 100644
index 000000000000..b85f5ddda7c5
--- /dev/null
+++ b/dev-util/spirv-tools/spirv-tools-1.3.211-r1.ebuild
@@ -0,0 +1,49 @@
+# Copyright 1999-2022 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=7
+
+MY_PN=SPIRV-Tools
+CMAKE_ECLASS="cmake"
+PYTHON_COMPAT=( python3_{8..10} )
+PYTHON_REQ_USE="xml(+)"
+inherit cmake-multilib python-any-r1
+
+if [[ ${PV} == *9999* ]]; then
+       EGIT_REPO_URI="https://github.com/KhronosGroup/${MY_PN}.git";
+       inherit git-r3
+else
+       EGIT_COMMIT="sdk-${PV}.0"
+       
SRC_URI="https://github.com/KhronosGroup/${MY_PN}/archive/${EGIT_COMMIT}.tar.gz 
-> ${P}.tar.gz"
+       KEYWORDS="~amd64 ~arm ~arm64 ~ppc ~ppc64 ~riscv ~x86"
+       S="${WORKDIR}"/${MY_PN}-${EGIT_COMMIT}
+fi
+
+DESCRIPTION="Provides an API and commands for processing SPIR-V modules"
+HOMEPAGE="https://github.com/KhronosGroup/SPIRV-Tools";
+
+LICENSE="Apache-2.0"
+SLOT="0"
+# Tests fail upon finding symbols that do not match a regular expression
+# in the generated library. Easily hit with non-standard compiler flags
+RESTRICT="test"
+COMMON_DEPEND="~dev-util/spirv-headers-${PV}"
+DEPEND="${COMMON_DEPEND}"
+RDEPEND=""
+BDEPEND="${PYTHON_DEPS}
+       ${COMMON_DEPEND}"
+
+PATCHES=(
+       "${FILESDIR}"/${P}-cmake-librt.patch
+)
+
+multilib_src_configure() {
+       local mycmakeargs=(
+               "-DSPIRV-Headers_SOURCE_DIR=${ESYSROOT}/usr/"
+               "-DSPIRV_WERROR=OFF"
+               "-DSPIRV_TOOLS_BUILD_STATIC=OFF"
+               "-DBUILD_SHARED_LIBS=ON"
+       )
+
+       cmake_src_configure
+}

Reply via email to