public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Marek Szuba" <marecki@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] repo/gentoo:master commit in: dev-libs/beignet/, dev-libs/beignet/files/
Date: Fri, 24 May 2019 14:20:52 +0000 (UTC)	[thread overview]
Message-ID: <1558707629.74f59b17f771af5dbc926bf408629d871b2b1f23.marecki@gentoo> (raw)

commit:     74f59b17f771af5dbc926bf408629d871b2b1f23
Author:     Marek Szuba <marecki <AT> gentoo <DOT> org>
AuthorDate: Fri May 24 14:14:52 2019 +0000
Commit:     Marek Szuba <marecki <AT> gentoo <DOT> org>
CommitDate: Fri May 24 14:20:29 2019 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=74f59b17

dev-libs/beignet: enable LLVM7 support, switch to EAPI-7

LLVM7 support is provided by the backported upstream commit
e1b2419a0008e38ef2d9d255d9e9c74e9fba084b . It is described as
preliminary but the commit description elaborates this is simply because
LLVM7 was not released at the time. Fortunately it seems there have been
no breaking changes since the snapshot against which upstream tested
this and everything seems to be in order, in both 1.3 and 2.0 mode.

Signed-off-by: Marek Szuba <marecki <AT> gentoo.org>
Package-Manager: Portage-2.3.62, Repoman-2.3.11

 dev-libs/beignet/beignet-1.3.2-r3.ebuild         | 104 +++++++++++++++++++
 dev-libs/beignet/files/beignet-1.3.2_llvm7.patch | 124 +++++++++++++++++++++++
 2 files changed, 228 insertions(+)

diff --git a/dev-libs/beignet/beignet-1.3.2-r3.ebuild b/dev-libs/beignet/beignet-1.3.2-r3.ebuild
new file mode 100644
index 00000000000..15e6c37a560
--- /dev/null
+++ b/dev-libs/beignet/beignet-1.3.2-r3.ebuild
@@ -0,0 +1,104 @@
+# Copyright 1999-2019 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=7
+
+PYTHON_COMPAT=( python{2_7,3_5,3_6} )
+CMAKE_BUILD_TYPE="Release"
+
+inherit python-any-r1 cmake-multilib flag-o-matic llvm
+
+DESCRIPTION="OpenCL implementation for Intel Sandy Bridge, Ivy Bridge and Haswell GPUs"
+HOMEPAGE="https://01.org/beignet https://gitlab.freedesktop.org/beignet/beignet"
+SRC_URI="https://01.org/sites/default/files/${P}-source.tar.gz"
+
+LICENSE="LGPL-2.1+"
+SLOT="0"
+KEYWORDS="~amd64"
+IUSE="ocl-icd ocl20"
+
+BDEPEND="${PYTHON_DEPS}
+	virtual/pkgconfig"
+COMMON="app-eselect/eselect-opencl
+	media-libs/mesa[${MULTILIB_USEDEP}]
+	<sys-devel/clang-7.0.9999:=[${MULTILIB_USEDEP}]
+	>=x11-libs/libdrm-2.4.70[video_cards_intel,${MULTILIB_USEDEP}]
+	x11-libs/libXext[${MULTILIB_USEDEP}]
+	x11-libs/libXfixes[${MULTILIB_USEDEP}]
+	ocl-icd? ( dev-libs/ocl-icd )"
+RDEPEND="${COMMON}"
+DEPEND="${COMMON}"
+
+LLVM_MAX_SLOT=7
+
+PATCHES=(
+	"${FILESDIR}"/no-debian-multiarch.patch
+	"${FILESDIR}"/${PN}-1.3.2_disable-doNegAddOptimization.patch
+	"${FILESDIR}"/${PN}-1.3.2_cmake-llvm-config-multilib.patch
+	"${FILESDIR}"/${PN}-1.3.2_llvm6.patch
+	"${FILESDIR}"/${PN}-1.3.2_llvm7.patch
+	"${FILESDIR}"/${PN}-1.3.1-oclicd_no_upstream_icdfile.patch
+	"${FILESDIR}"/${PN}-1.2.0_no-hardcoded-cflags.patch
+	"${FILESDIR}"/llvm-terminfo.patch
+)
+
+DOCS=(
+	docs/.
+)
+
+S="${WORKDIR}"/Beignet-${PV}-Source
+
+pkg_setup() {
+	llvm_pkg_setup
+	python_setup
+}
+
+src_prepare() {
+	# See Bug #593968
+	append-flags -fPIC
+
+	cmake-utils_src_prepare
+	# We cannot run tests because they require permissions to access
+	# the hardware, and building them is very time-consuming.
+	cmake_comment_add_subdirectory utests
+}
+
+multilib_src_configure() {
+	VENDOR_DIR="/usr/$(get_libdir)/OpenCL/vendors/${PN}"
+
+	local mycmakeargs=(
+		-DCMAKE_INSTALL_PREFIX="${EPREFIX}${VENDOR_DIR}"
+		-DOCLICD_COMPAT=$(usex ocl-icd)
+		$(usex ocl20 "" "-DENABLE_OPENCL_20=OFF")
+	)
+
+	cmake-utils_src_configure
+}
+
+multilib_src_install() {
+	VENDOR_DIR="/usr/$(get_libdir)/OpenCL/vendors/${PN}"
+
+	cmake-utils_src_install
+
+	insinto /etc/OpenCL/vendors/
+	echo "${EPREFIX}${VENDOR_DIR}/lib/${PN}/libcl.so" > "${PN}-${ABI}.icd" || die "Failed to generate ICD file"
+	doins "${PN}-${ABI}.icd"
+
+	dosym "lib/${PN}/libcl.so" "${VENDOR_DIR}"/libOpenCL.so.1
+	dosym "lib/${PN}/libcl.so" "${VENDOR_DIR}"/libOpenCL.so
+	dosym "lib/${PN}/libcl.so" "${VENDOR_DIR}"/libcl.so.1
+	dosym "lib/${PN}/libcl.so" "${VENDOR_DIR}"/libcl.so
+}
+
+pkg_postinst() {
+	elog ""
+	elog "Please note that for Skylake and newer architectures, Beignet has been deprecated upstream in favour of dev-libs/intel-neo."
+	elog "It remains the recommended solution for Sandy Bridge, Ivy Bridge and Haswell."
+	elog ""
+
+	if use ocl-icd; then
+		"${ROOT}"/usr/bin/eselect opencl set --use-old ocl-icd
+	else
+		"${ROOT}"/usr/bin/eselect opencl set --use-old beignet
+	fi
+}

diff --git a/dev-libs/beignet/files/beignet-1.3.2_llvm7.patch b/dev-libs/beignet/files/beignet-1.3.2_llvm7.patch
new file mode 100644
index 00000000000..8990f0f0e48
--- /dev/null
+++ b/dev-libs/beignet/files/beignet-1.3.2_llvm7.patch
@@ -0,0 +1,124 @@
+commit e1b2419a0008e38ef2d9d255d9e9c74e9fba084b
+Author: Rebecca N. Palmer <rebecca_palmer@zoho.com>
+Date:   Sat Jul 21 20:05:54 2018 +0100
+
+    Add preliminary LLVM 7 support
+    
+    This is preliminary because LLVM 7 has not been released yet:
+    it was tested with the snapshot from Debian experimental (svn336894).
+    
+    1.Change linking order, as clangCodeGen now links to clangFrontend
+    2.Pass references not pointers to WriteBitcodeToFile and CloneModule
+    3.Add the headers that LoopSimplifyID, LCSSAID and
+    some create*Pass have moved to
+    4.Define our DEBUG whether or not we just undefined LLVM's
+    (theirs is now LLVM_DEBUG, but we never actually use it)
+    
+    Signed-off-by: Rebecca N. Palmer <rebecca_palmer@zoho.com>
+    Reviewed-by: Yang Rong <rong.r.yang@intel.com>
+
+diff --git a/CMake/FindLLVM.cmake b/CMake/FindLLVM.cmake
+index 5457f248..f882589d 100644
+--- a/CMake/FindLLVM.cmake
++++ b/CMake/FindLLVM.cmake
+@@ -113,10 +113,10 @@ macro(add_one_lib name)
+ endmacro()
+ 
+ #Assume clang lib path same as llvm lib path
++add_one_lib("clangCodeGen")
+ add_one_lib("clangFrontend")
+ add_one_lib("clangSerialization")
+ add_one_lib("clangDriver")
+-add_one_lib("clangCodeGen")
+ add_one_lib("clangSema")
+ add_one_lib("clangStaticAnalyzerFrontend")
+ add_one_lib("clangStaticAnalyzerCheckers")
+diff --git a/backend/src/backend/gen_program.cpp b/backend/src/backend/gen_program.cpp
+index 274c99c7..41592349 100644
+--- a/backend/src/backend/gen_program.cpp
++++ b/backend/src/backend/gen_program.cpp
+@@ -454,7 +454,11 @@ namespace gbe {
+ #ifdef GBE_COMPILER_AVAILABLE
+       std::string str;
+       llvm::raw_string_ostream OS(str);
++#if LLVM_VERSION_MAJOR >= 7
++      llvm::WriteBitcodeToFile(*((llvm::Module*)prog->module), OS);
++#else
+       llvm::WriteBitcodeToFile((llvm::Module*)prog->module, OS);
++#endif
+       std::string& bin_str = OS.str();
+       int llsz = bin_str.size();
+       *binary = (char *)malloc(sizeof(char) * (llsz+1) );
+@@ -545,7 +549,11 @@ namespace gbe {
+                                     &modRef);
+         src = llvm::unwrap(modRef);
+       }
++#if LLVM_VERSION_MAJOR >= 7
++      llvm::Module* clone = llvm::CloneModule(*src).release();
++#else
+       llvm::Module* clone = llvm::CloneModule(src).release();
++#endif
+       if (LLVMLinkModules2(wrap(dst), wrap(clone))) {
+ #elif LLVM_VERSION_MAJOR * 10 + LLVM_VERSION_MINOR >= 37
+       if (LLVMLinkModules(wrap(dst), wrap(src), LLVMLinkerPreserveSource_Removed, &errMsg)) {
+diff --git a/backend/src/backend/program.cpp b/backend/src/backend/program.cpp
+index c37c5951..b36f7b4a 100644
+--- a/backend/src/backend/program.cpp
++++ b/backend/src/backend/program.cpp
+@@ -794,7 +794,11 @@ namespace gbe {
+       llvm::raw_fd_ostream ostream (dumpSPIRBinaryName.c_str(),
+                                     err, llvm::sys::fs::F_None);
+       if (!err)
++#if LLVM_VERSION_MAJOR<7
+         llvm::WriteBitcodeToFile(*out_module, ostream);
++#else
++        llvm::WriteBitcodeToFile(**out_module, ostream);
++#endif
+     }
+ #endif
+     return true;
+diff --git a/backend/src/llvm/ExpandLargeIntegers.cpp b/backend/src/llvm/ExpandLargeIntegers.cpp
+index 8515dc13..4aec44ee 100644
+--- a/backend/src/llvm/ExpandLargeIntegers.cpp
++++ b/backend/src/llvm/ExpandLargeIntegers.cpp
+@@ -99,8 +99,8 @@ using namespace llvm;
+ 
+ #ifdef DEBUG
+   #undef DEBUG
+-  #define DEBUG(...)
+ #endif
++#define DEBUG(...)
+ // Break instructions up into no larger than 64-bit chunks.
+ static const unsigned kChunkBits = 64;
+ static const unsigned kChunkBytes = kChunkBits / CHAR_BIT;
+diff --git a/backend/src/llvm/llvm_bitcode_link.cpp b/backend/src/llvm/llvm_bitcode_link.cpp
+index ef56e4c2..4c3e20e4 100644
+--- a/backend/src/llvm/llvm_bitcode_link.cpp
++++ b/backend/src/llvm/llvm_bitcode_link.cpp
+@@ -340,7 +340,11 @@ namespace gbe
+     /* We use beignet's bitcode as dst because it will have a lot of
+        lazy functions which will not be loaded. */
+ #if LLVM_VERSION_MAJOR * 10 + LLVM_VERSION_MINOR >= 39
++#if LLVM_VERSION_MAJOR >= 7
++    llvm::Module * linked_module = llvm::CloneModule(*(llvm::Module*)mod).release();
++#else
+     llvm::Module * linked_module = llvm::CloneModule((llvm::Module*)mod).release();
++#endif
+     if(LLVMLinkModules2(wrap(clonedLib), wrap(linked_module))) {
+ #else
+     char* errorMsg;
+diff --git a/backend/src/llvm/llvm_includes.hpp b/backend/src/llvm/llvm_includes.hpp
+index 184553af..ffccf025 100644
+--- a/backend/src/llvm/llvm_includes.hpp
++++ b/backend/src/llvm/llvm_includes.hpp
+@@ -89,6 +89,10 @@
+ #include "llvm/CodeGen/IntrinsicLowering.h"
+ 
+ #include "llvm/Transforms/Scalar.h"
++#if LLVM_VERSION_MAJOR >= 7
++#include "llvm/Transforms/Utils.h"
++#include "llvm/Transforms/InstCombine/InstCombine.h"
++#endif
+ #include "llvm/MC/MCAsmInfo.h"
+ #include "llvm/MC/MCContext.h"
+ #include "llvm/MC/MCInstrInfo.h"


             reply	other threads:[~2019-05-24 14:20 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-24 14:20 Marek Szuba [this message]
  -- strict thread matches above, loose matches on Subject: below --
2020-03-25 13:36 [gentoo-commits] repo/gentoo:master commit in: dev-libs/beignet/, dev-libs/beignet/files/ Marek Szuba
2019-05-24 14:20 Marek Szuba
2018-08-31 13:27 Marek Szuba
2017-12-19 14:38 Marek Szuba
2017-10-17 13:08 Marek Szuba
2017-06-14  8:09 Marek Szuba
2016-11-28 13:57 Marek Szuba
2016-10-11  0:56 Marek Szuba

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1558707629.74f59b17f771af5dbc926bf408629d871b2b1f23.marecki@gentoo \
    --to=marecki@gentoo.org \
    --cc=gentoo-commits@lists.gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox