diff --git a/dev-util/spirv-headers/metadata.xml b/dev-util/spirv-headers/metadata.xml new file mode 100644 index 0000000..e808bfd --- /dev/null +++ b/dev-util/spirv-headers/metadata.xml @@ -0,0 +1,11 @@ + + + + + vulkan@gentoo.org + Vulkan Project + + + KhronosGroup/SPIRV-Headers + + diff --git a/dev-util/spirv-headers/spirv-headers-1.4.326.ebuild b/dev-util/spirv-headers/spirv-headers-1.4.326.ebuild new file mode 100644 index 0000000..989970d --- /dev/null +++ b/dev-util/spirv-headers/spirv-headers-1.4.326.ebuild @@ -0,0 +1,36 @@ +# Copyright 1999-2025 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=8 + +MY_PN=SPIRV-Headers +inherit cmake + +if [[ ${PV} == *9999* ]]; then + EGIT_REPO_URI="https://github.com/KhronosGroup/${MY_PN}.git" + inherit git-r3 +elif [[ ${PV} == *1.4.326* ]]; then + EGIT_REPO_URI="https://github.com/KhronosGroup/${MY_PN}.git" + inherit git-r3 + #EGIT_COMMIT + EGIT_OVERRIDE_BRANCH_KHRONOSGROUP_SPIRV_HEADERS="vulkan-tmp-${PV}" + KEYWORDS="~amd64 ~x86" +else + SRC_URI="https://github.com/KhronosGroup/${MY_PN}/archive/vulkan-sdk-${PV}.tar.gz -> ${P}.tar.gz" + KEYWORDS="~alpha amd64 arm arm64 ~hppa ~loong ~mips ppc ppc64 ~riscv ~s390 ~sparc x86" + S="${WORKDIR}"/${MY_PN}-vulkan-sdk-${PV} +fi + +DESCRIPTION="Machine-readable files for the SPIR-V Registry" +HOMEPAGE="https://registry.khronos.org/SPIR-V/ https://github.com/KhronosGroup/SPIRV-Headers" + +LICENSE="MIT" +SLOT="0" + +src_configure() { + local mycmakeargs=( + -DSPIRV_HEADERS_ENABLE_TESTS=OFF + -DSPIRV_HEADERS_ENABLE_INSTALL=ON + ) + cmake_src_configure +} diff --git a/dev-util/spirv-llvm-translator/Manifest b/dev-util/spirv-llvm-translator/Manifest new file mode 100644 index 0000000..2281bb8 --- /dev/null +++ b/dev-util/spirv-llvm-translator/Manifest @@ -0,0 +1 @@ +DIST spirv-llvm-translator-21.1.0.tar.gz 1828044 BLAKE2B 5ebf5c6883c53eb68d5b32fa80f612aa5ac6ac2f1ca80206ab663e9902e0dacfaf1b2ad3ccef733548a0babf4967d6a6f93f4cbd952a23356174ecbfe8e39671 SHA512 dbacf6ff5b12d9755d80f9d673a0bc96e783a586f3d8f93e2291fae934b3c2d2fa8c605b926c42c09fb1391b110c7b7d5bf9185dd980df0f47d0e5afc9119bdc diff --git a/dev-util/spirv-llvm-translator/files/spirv-llvm-translator-16.0.0-ld_library_path.patch b/dev-util/spirv-llvm-translator/files/spirv-llvm-translator-16.0.0-ld_library_path.patch new file mode 100644 index 0000000..3068cd5 --- /dev/null +++ b/dev-util/spirv-llvm-translator/files/spirv-llvm-translator-16.0.0-ld_library_path.patch @@ -0,0 +1,63 @@ +From c2133b18cb48b9bb9c47897b16d64c5f0547cde6 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= +Date: Thu, 4 May 2023 08:44:25 +0200 +Subject: [PATCH] [test] Use LD_LIBRARY_PATH to ensure that a new lib is used + (#1989) +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Add the library `BINARY_DIR` to `LD_LIBRARY_PATH` to ensure that +the freshly built `libLLVMSPIRVLib.so` is tested. Otherwise, llvm-spirv +spawned by the test suite may use the previously installed +`libLLVMSPIRVLib.so`. + +I have noticed the problem after rebuilding LLVM with +`-DLLVM_ENABLE_ASSSERTIONS=ON`. This meant that the previous version +of `libLLVMSPIRVLib.so` now crashed, effectively causing the test suite +to fail incorrectly. + +Signed-off-by: Michał Górny +--- + test/CMakeLists.txt | 1 + + test/lit.cfg.py | 3 ++- + test/lit.site.cfg.py.in | 1 + + 3 files changed, 4 insertions(+), 1 deletion(-) + +diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt +index 235f6d0a0..355baffb8 100644 +--- a/test/CMakeLists.txt ++++ b/test/CMakeLists.txt +@@ -3,6 +3,7 @@ llvm_canonicalize_cmake_booleans(SPIRV_SKIP_DEBUG_INFO_TESTS) + + # required by lit.site.cfg.py.in + get_target_property(LLVM_SPIRV_DIR llvm-spirv BINARY_DIR) ++get_target_property(LLVM_SPIRV_LIB_DIR LLVMSPIRVLib BINARY_DIR) + set(LLVM_SPIRV_TEST_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}) + + if(SPIRV_TOOLS_FOUND AND NOT SPIRV-Tools-tools_FOUND) +diff --git a/test/lit.cfg.py b/test/lit.cfg.py +index 4b66412c3..fd8d3f94c 100644 +--- a/test/lit.cfg.py ++++ b/test/lit.cfg.py +@@ -76,6 +76,7 @@ + else: + config.substitutions.append(('spirv-val', ':')) + ++llvm_config.with_system_environment('LD_LIBRARY_PATH') + if using_spirv_tools: +- llvm_config.with_system_environment('LD_LIBRARY_PATH') + llvm_config.with_environment('LD_LIBRARY_PATH', config.spirv_tools_lib_dir, append_path=True) ++llvm_config.with_environment('LD_LIBRARY_PATH', config.llvm_spirv_lib_dir, append_path=True) +diff --git a/test/lit.site.cfg.py.in b/test/lit.site.cfg.py.in +index a01f2bb34..fdc4f4319 100644 +--- a/test/lit.site.cfg.py.in ++++ b/test/lit.site.cfg.py.in +@@ -6,6 +6,7 @@ config.llvm_src_root = "@LLVM_SOURCE_DIR@" + config.llvm_obj_root = "@LLVM_BINARY_DIR@" + config.llvm_tools_dir = "@LLVM_TOOLS_DIR@" + config.llvm_spirv_dir = "@LLVM_SPIRV_DIR@" ++config.llvm_spirv_lib_dir = "@LLVM_SPIRV_LIB_DIR@" + config.llvm_libs_dir = "@LLVM_LIBS_DIR@" + config.llvm_shlib_dir = "@SHLIBDIR@" + config.llvm_plugin_ext = "@LLVM_PLUGIN_EXT@" diff --git a/dev-util/spirv-llvm-translator/files/spirv-llvm-translator-20.1.3-option-registered.patch b/dev-util/spirv-llvm-translator/files/spirv-llvm-translator-20.1.3-option-registered.patch new file mode 100644 index 0000000..8070484 --- /dev/null +++ b/dev-util/spirv-llvm-translator/files/spirv-llvm-translator-20.1.3-option-registered.patch @@ -0,0 +1,34 @@ +Fix for "Option 'spirv-ext' registered more than once" error. + +Bug: https://bugs.gentoo.org/959744 +Upstream PR: https://github.com/KhronosGroup/SPIRV-LLVM-Translator/pull/3218 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -102,13 +102,6 @@ if(LLVM_SPIRV_BUILD_EXTERNAL) + + message(STATUS "Found LLVM: ${LLVM_VERSION}") + +- is_llvm_target_library("SPIRV" spirv_present_result INCLUDED_TARGETS) +- if(spirv_present_result) +- message(STATUS "Found SPIR-V Backend") +- set(SPIRV_BACKEND_FOUND TRUE) +- add_compile_definitions(LLVM_SPIRV_BACKEND_TARGET_PRESENT) +- endif() +- + option(CCACHE_ALLOWED "allow use of ccache" TRUE) + find_program(CCACHE_EXE_FOUND ccache) + if(CCACHE_EXE_FOUND AND CCACHE_ALLOWED) +@@ -118,6 +111,13 @@ if(LLVM_SPIRV_BUILD_EXTERNAL) + endif() + endif() + ++is_llvm_target_library("SPIRV" spirv_present_result INCLUDED_TARGETS) ++if(spirv_present_result) ++ message(STATUS "Found SPIR-V Backend") ++ set(SPIRV_BACKEND_FOUND TRUE) ++ add_compile_definitions(LLVM_SPIRV_BACKEND_TARGET_PRESENT) ++endif() ++ + set(LLVM_SPIRV_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/include) + + # first try locating SPIRV-Tools via pkgconfig (the old way) diff --git a/dev-util/spirv-llvm-translator/files/spirv-llvm-translator-21.1.0-intel.patch b/dev-util/spirv-llvm-translator/files/spirv-llvm-translator-21.1.0-intel.patch new file mode 100644 index 0000000..8c5b57b --- /dev/null +++ b/dev-util/spirv-llvm-translator/files/spirv-llvm-translator-21.1.0-intel.patch @@ -0,0 +1,41 @@ +--- a/lib/SPIRV/libSPIRV/SPIRVOpCode.h ++++ b/lib/SPIRV/libSPIRV/SPIRVOpCode.h +@@ -44,1 +44,1 @@ +-#include "spirv/unified1/spirv.hpp" ++#include + +--- a/lib/SPIRV/VectorComputeUtil.h ++++ b/lib/SPIRV/VectorComputeUtil.h +@@ -44,1 +44,1 @@ +-#include "spirv/unified1/spirv.hpp" ++#include + +--- a/lib/SPIRV/libSPIRV/SPIRVIsValidEnum.h ++++ b/lib/SPIRV/libSPIRV/SPIRVIsValidEnum.h +@@ -44,1 +44,1 @@ +-#include "spirv/unified1/spirv.hpp" ++#include + +--- a/lib/SPIRV/libSPIRV/spirv_internal.hpp ++++ b/lib/SPIRV/libSPIRV/spirv_internal.hpp +@@ -44,1 +44,1 @@ +-#include "spirv/unified1/spirv.hpp" ++#include + +--- a/lib/SPIRV/libSPIRV/SPIRVEnum.h ++++ b/lib/SPIRV/libSPIRV/SPIRVEnum.h +@@ -44,1 +44,1 @@ +-#include "spirv/unified1/spirv.hpp" ++#include + +--- a/lib/SPIRV/libSPIRV/SPIRV.debug.h ++++ b/lib/SPIRV/libSPIRV/SPIRV.debug.h +@@ -44,1 +44,1 @@ +-#include "spirv/unified1/spirv.hpp" ++#include + +--- a/lib/SPIRV/libSPIRV/SPIRVNameMapEnum.h ++++ b/lib/SPIRV/libSPIRV/SPIRVNameMapEnum.h +@@ -44,1 +44,1 @@ +-#include "spirv/unified1/spirv.hpp" ++#include diff --git a/dev-util/spirv-llvm-translator/metadata.xml b/dev-util/spirv-llvm-translator/metadata.xml new file mode 100644 index 0000000..fc2f688 --- /dev/null +++ b/dev-util/spirv-llvm-translator/metadata.xml @@ -0,0 +1,18 @@ + + + + + conikost@gentoo.org + Conrad Kostecki + + + x11@gentoo.org + X11 + + + llvm@gentoo.org + + + KhronosGroup/SPIRV-LLVM-Translator + + diff --git a/dev-util/spirv-llvm-translator/spirv-llvm-translator-21.1.0.ebuild b/dev-util/spirv-llvm-translator/spirv-llvm-translator-21.1.0.ebuild new file mode 100644 index 0000000..725cdb5 --- /dev/null +++ b/dev-util/spirv-llvm-translator/spirv-llvm-translator-21.1.0.ebuild @@ -0,0 +1,63 @@ +# Copyright 1999-2025 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=8 + +LLVM_COMPAT=( 21 ) +MY_PN="SPIRV-LLVM-Translator" +MY_P="${MY_PN}-${PV}" + +inherit cmake-multilib flag-o-matic llvm-r2 multiprocessing + +DESCRIPTION="Bi-directional translator between SPIR-V and LLVM IR" +HOMEPAGE="https://github.com/KhronosGroup/SPIRV-LLVM-Translator" +SRC_URI="https://github.com/KhronosGroup/${MY_PN}/archive/v${PV}.tar.gz -> ${P}.tar.gz" +S="${WORKDIR}/${MY_P}" + +LICENSE="UoI-NCSA" +SLOT="$(ver_cut 1)" +KEYWORDS="amd64 ~arm arm64 ~loong ~riscv x86" +IUSE="test" +RESTRICT="!test? ( test )" + +RDEPEND=" + dev-util/spirv-tools[${MULTILIB_USEDEP}] + llvm-core/llvm:${SLOT}=[${MULTILIB_USEDEP}] +" +DEPEND="${RDEPEND} + >=dev-util/spirv-headers-1.4.326 +" +BDEPEND=" + virtual/pkgconfig + test? ( + dev-python/lit + llvm-core/clang:${SLOT} + ) +" + +#PATCHES=( "${FILESDIR}"/${PN}-21.1.0-intel.patch ) + +src_prepare() { + append-flags -fPIC + cmake_src_prepare + + # do not force a specific LLVM version to find_package(), this only + # causes issues and we force a specific path anyway + sed -i -e '/find_package/s:${BASE_LLVM_VERSION}::' CMakeLists.txt || die +} + +multilib_src_configure() { + local mycmakeargs=( + -DCCACHE_ALLOWED="OFF" + -DCMAKE_INSTALL_PREFIX="$(get_llvm_prefix)" + -DLLVM_EXTERNAL_SPIRV_HEADERS_SOURCE_DIR="${ESYSROOT}/usr/include/spirv" + -DLLVM_SPIRV_INCLUDE_TESTS=$(usex test "ON" "OFF") + -Wno-dev + ) + + cmake_src_configure +} + +multilib_src_test() { + lit -vv "-j${LIT_JOBS:-$(makeopts_jobs)}" "${BUILD_DIR}/test" || die +}