dev-util/spirv-llvm-translator: support new OpenCL block representation
authorMarek Szuba <marecki@gentoo.org>
Fri, 3 May 2019 14:03:39 +0000 (15:03 +0100)
committerMarek Szuba <marecki@gentoo.org>
Fri, 3 May 2019 14:04:56 +0000 (15:04 +0100)
Without this patch, offline compilation of certain kernels used by
dev-libs/intel-neo unit tests fails with "LLVM ERROR: unknown argument
number for an object"; some real-world kernels would presumably be
affected as well.

The patch has been retrieved from
https://github.com/intel/opencl-clang/blob/ocl-open-80/patches/spirv/0001-Update-LowerOpenCL-pass-to-handle-new-blocks-represn.patch
(commit 912a9cc8d30b773372ce58d4fc17bf38fd388692 i.e. latest version as of
2019-05-02).

See-Also: https://github.com/intel/compute-runtime/issues/156
Signed-off-by: Marek Szuba <marecki@gentoo.org>
Package-Manager: Portage-2.3.62, Repoman-2.3.11

dev-util/spirv-llvm-translator/Manifest
dev-util/spirv-llvm-translator/spirv-llvm-translator-8.0.0.1-r1.ebuild [new file with mode: 0644]

index 33846447d840ebf33d599c618acd504ee66c0bab..336d1277a9f18c1462341cebf75a49c636e54ce8 100644 (file)
@@ -1 +1,2 @@
+DIST spirv-llvm-translator-8.0.0.1-LowerOpenCL_new_block_representation.patch.xz 10108 BLAKE2B 96492a7d3ab25e1fe837ced225d50c7450595af52bc3aa6c17e02dc08c1cccaf7ca8dc5949da17da7cc6ea5fcae8688a5994a50bb7693a52493520e57981bc48 SHA512 574ca7b7fe054e82ee154556555e2d184f102faa7da08ce9d6ca5d2ca37463c7a86b3861b93969f9c886544551af8c8f95e57363ea017f7fc426b56d97eb7cf2
 DIST spirv-llvm-translator-8.0.0.1.tar.gz 437384 BLAKE2B bca52bfec04d0adc08b00f5fdbcb6cf953be00f835d2a393545e77bd8776063ef91e8fb62c232b50cbeab58a0a01bea6e47b89c1756699bf35481e87823995de SHA512 85faf176d1ce79d19f10c88055f4a102a5952dcdcd6709e5e5cfdbf69eb958d51020a3ad34198c7c874b42ee8e318f1ce3169ea92853134dfff3dc5843f84414
diff --git a/dev-util/spirv-llvm-translator/spirv-llvm-translator-8.0.0.1-r1.ebuild b/dev-util/spirv-llvm-translator/spirv-llvm-translator-8.0.0.1-r1.ebuild
new file mode 100644 (file)
index 0000000..3412d8c
--- /dev/null
@@ -0,0 +1,67 @@
+# Copyright 1999-2019 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=6
+
+inherit cmake-multilib flag-o-matic llvm eapi7-ver
+
+MY_PN="SPIRV-LLVM-Translator"
+MY_PV="$(ver_rs 3 -)"
+MY_P="${MY_PN}-${MY_PV}"
+
+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${MY_PV}.tar.gz -> ${P}.tar.gz
+       https://dev.gentoo.org/~marecki/dists/${PN}/${PN}-8.0.0.1-LowerOpenCL_new_block_representation.patch.xz"
+
+LICENSE="UoI-NCSA"
+SLOT="8"
+KEYWORDS="~amd64"
+IUSE="test"
+
+S="${WORKDIR}/${MY_P}"
+
+COMMON="sys-devel/llvm:8=[${MULTILIB_USEDEP}]"
+DEPEND="${COMMON}
+       test? ( dev-python/lit )"
+RDEPEND="${COMMON}"
+
+LLVM_MAX_SLOT=8
+
+PATCHES=(
+       "${WORKDIR}"/${PN}-8.0.0.1-LowerOpenCL_new_block_representation.patch
+       "${FILESDIR}"/${PN}-8.0.0.1-no_pkgconfig_files.patch
+)
+
+src_prepare() {
+       append-flags -fPIC
+       cmake-utils_src_prepare
+}
+
+multilib_src_configure() {
+       local mycmakeargs=(
+               -DCMAKE_INSTALL_PREFIX="$(get_llvm_prefix)"
+               $(usex test "-DLLVM_INCLUDE_TESTS=ON" "")
+       )
+       cmake-utils_src_configure
+}
+
+multilib_src_compile() {
+       cmake-utils_src_compile llvm-spirv
+}
+
+multilib_src_install() {
+       cmake-utils_src_install
+       # CMake does not install the executable so do it by hand
+       if multilib_is_native_abi; then
+               exeinto "$(get_llvm_prefix)"/bin
+               doexe "${BUILD_DIR}"/tools/llvm-spirv/llvm-spirv
+       fi
+}
+
+multilib_src_test() {
+       # TODO: figure out why some tests fail on amd64 when ABI==x86
+       if multilib_is_native_abi; then
+               lit "${BUILD_DIR}/test" || die "Error running tests for ABI ${ABI}"
+       fi
+}