summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--dev-libs/beignet/Manifest23
-rw-r--r--dev-libs/beignet/beignet-1.3.2-r3.ebuild104
-rw-r--r--dev-libs/beignet/files/beignet-1.2.0_no-hardcoded-cflags.patch12
-rw-r--r--dev-libs/beignet/files/beignet-1.3.1-oclicd_no_upstream_icdfile.patch14
-rw-r--r--dev-libs/beignet/files/beignet-1.3.2_cmake-llvm-config-multilib.patch17
-rw-r--r--dev-libs/beignet/files/beignet-1.3.2_disable-doNegAddOptimization.patch66
-rw-r--r--dev-libs/beignet/files/beignet-1.3.2_llvm6.patch27
-rw-r--r--dev-libs/beignet/files/beignet-1.3.2_llvm7.patch124
-rw-r--r--dev-libs/beignet/files/llvm-terminfo.patch20
-rw-r--r--dev-libs/beignet/files/no-debian-multiarch.patch39
-rw-r--r--dev-libs/beignet/metadata.xml14
11 files changed, 460 insertions, 0 deletions
diff --git a/dev-libs/beignet/Manifest b/dev-libs/beignet/Manifest
new file mode 100644
index 0000000..3ecdfd2
--- /dev/null
+++ b/dev-libs/beignet/Manifest
@@ -0,0 +1,23 @@
+-----BEGIN PGP SIGNED MESSAGE-----
+Hash: SHA512
+
+DIST beignet-1.3.2-source.tar.gz 1143573 BLAKE2B e95e9ad352e7e695a0c56a8cea7bff312d7e1e811e17da6c744f16833130ca5339c163504afff3ed61947e752b94dc0465f6702317feb7662fb9676939838f20 SHA512 ed09a895c2f7e9b6e18687a899f1303dfda95e505c3c2d54bf7598cc4eba6c2fb5926589b19dd294384a4ff3f832c43235b1f03f8b7fd295cd558e78bda1400a
+-----BEGIN PGP SIGNATURE-----
+Version: GnuPG v2
+
+iQKTBAEBCgB9FiEEX+aBqe7MmoWBwzA1lSmjXZiBxnkFAl6bCclfFIAAAAAALgAo
+aXNzdWVyLWZwckBub3RhdGlvbnMub3BlbnBncC5maWZ0aGhvcnNlbWFuLm5ldDVG
+RTY4MUE5RUVDQzlBODU4MUMzMzAzNTk1MjlBMzVEOTg4MUM2NzkACgkQlSmjXZiB
+xnn3ZA//XEdnxAzCHukTl3aukFcLWpxeSLQSY6xlKm6Q8duyf+VCskPpTyGhpa6g
+Z51/9WU/C+/eSuLMTEcbs0Nnamh5k0Ah/a3+7rHewVBfqZhSm8jzu7H1F01biZMz
+SKXZQQwY/91XqhFrLbEMJitxV18ZU8wZWn3wNmEwyHy0qsMmj+s/t5qxPiFx90Ix
+vqmvLS85t1RD2HsCIv+4D6XKTcxF3cbk3gfPWhYjiikeBG9S04z8C6lWP02ZRdpb
+6motuojMnx01Y1dcKj2aEduQhgzoRkaFS2NxgZ+L6P3afm36vCWWOzjEt7uUeNUq
+/PGpn/3/EutCu1wNW1TzypCbh5V2MqRA23cUZ426eLyMjGAWfJ3gppw49cSzEX40
+KI9h3j6E+Vmh3sy6rkOvrK8K44XDLruEVtF0txv6X9zIJ6rTNhS2iFYUCWEje2p9
+zZcWGBCZQW+FuNEFSRq3ouwwMwuupNLM+WyH6u14WWD7nHZpZ5Kdx+2w6VF2IhtP
+473SY5dXt37a1FVBO8TsvktreuFqK4UaW8WlOzowQfwpW2QprQIMmJDh5vB3y/Cr
+6e/NUfDv/oH4ZUkn4IbFlVRu2G73iE58C1T/3Rg6uI3VN0SmOROAIBFHg0LEWTjY
+sfgysOTjrHtNhi/RBhyvYbNrjM7510RkYcH5d/j9ZzekScGd1BE=
+=LE4/
+-----END PGP SIGNATURE-----
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 0000000..132de59
--- /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-8.0.0:=[static-analyzer,${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 Broadwell 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.2.0_no-hardcoded-cflags.patch b/dev-libs/beignet/files/beignet-1.2.0_no-hardcoded-cflags.patch
new file mode 100644
index 0000000..3f98759
--- /dev/null
+++ b/dev-libs/beignet/files/beignet-1.2.0_no-hardcoded-cflags.patch
@@ -0,0 +1,12 @@
+--- a/CMakeLists.txt 2016-08-30 10:06:31.000000000 +0000
++++ b/CMakeLists.txt 2016-09-16 06:55:28.975772954 +0000
+@@ -89,8 +89,7 @@
+ elseif (COMPILER STREQUAL "ICC")
+ set (CMAKE_C_CXX_FLAGS "${CMAKE_C_CXX_FLAGS} -wd2928 -Wall -fPIC -fstrict-aliasing -fp-model fast -msse4.1 -Wl,-E")
+ endif ()
+-set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_C_CXX_FLAGS} -std=c++0x -Wno-invalid-offsetof")
+-set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CMAKE_C_CXX_FLAGS}")
++set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x -Wno-invalid-offsetof")
+ set (CMAKE_CXX_FLAGS_DEBUG "-O0 -g -DGBE_DEBUG=1")
+ set (CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g -DGBE_DEBUG=1")
+ set (CMAKE_CXX_FLAGS_MINSIZEREL "-Os -DNDEBUG -DGBE_DEBUG=0")
diff --git a/dev-libs/beignet/files/beignet-1.3.1-oclicd_no_upstream_icdfile.patch b/dev-libs/beignet/files/beignet-1.3.1-oclicd_no_upstream_icdfile.patch
new file mode 100644
index 0000000..7e9e883
--- /dev/null
+++ b/dev-libs/beignet/files/beignet-1.3.1-oclicd_no_upstream_icdfile.patch
@@ -0,0 +1,14 @@
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -213,11 +213,6 @@
+ Find_Package(OCLIcd)
+ IF(OCLIcd_FOUND)
+ MESSAGE(STATUS "Looking for OCL ICD header file - found")
+- configure_file (
+- "intel-beignet.icd.in"
+- "${ICD_FILE_NAME}"
+- )
+- install (FILES ${CMAKE_CURRENT_BINARY_DIR}/${ICD_FILE_NAME} DESTINATION /etc/OpenCL/vendors)
+ ELSE(OCLIcd_FOUND)
+ MESSAGE(STATUS "Looking for OCL ICD header file - not found")
+ MESSAGE(FATAL_ERROR "OCL ICD loader miss. If you really want to disable OCL ICD support, please run cmake with option -DOCLICD_COMPAT=0.")
diff --git a/dev-libs/beignet/files/beignet-1.3.2_cmake-llvm-config-multilib.patch b/dev-libs/beignet/files/beignet-1.3.2_cmake-llvm-config-multilib.patch
new file mode 100644
index 0000000..5add6a1
--- /dev/null
+++ b/dev-libs/beignet/files/beignet-1.3.2_cmake-llvm-config-multilib.patch
@@ -0,0 +1,17 @@
+--- a/CMake/FindLLVM.cmake
++++ b/CMake/FindLLVM.cmake
+@@ -8,12 +8,12 @@
+ # LLVM_FOUND - True if llvm found.
+ if (LLVM_INSTALL_DIR)
+ find_program(LLVM_CONFIG_EXECUTABLE
+- NAMES llvm-config-37 llvm-config-3.7 llvm-config-36 llvm-config-3.6 llvm-config-38 llvm-config-3.8 llvm-config-39 llvm-config-3.9 llvm-config llvm-config-35 llvm-config-3.5 llvm-config-34 llvm-config-3.4
++ NAMES $ENV{CHOST}-llvm-config
+ DOC "llvm-config executable"
+ PATHS ${LLVM_INSTALL_DIR} NO_DEFAULT_PATH)
+ else (LLVM_INSTALL_DIR)
+ find_program(LLVM_CONFIG_EXECUTABLE
+- NAMES llvm-config-37 llvm-config-3.7 llvm-config-36 llvm-config-3.6 llvm-config-38 llvm-config-3.8 llvm-config-39 llvm-config-3.9 llvm-config llvm-config-35 llvm-config-3.5 llvm-config-34 llvm-config-3.4
++ NAMES $ENV{CHOST}-llvm-config
+ DOC "llvm-config executable")
+ endif (LLVM_INSTALL_DIR)
+
diff --git a/dev-libs/beignet/files/beignet-1.3.2_disable-doNegAddOptimization.patch b/dev-libs/beignet/files/beignet-1.3.2_disable-doNegAddOptimization.patch
new file mode 100644
index 0000000..ae399b1
--- /dev/null
+++ b/dev-libs/beignet/files/beignet-1.3.2_disable-doNegAddOptimization.patch
@@ -0,0 +1,66 @@
+--- b/backend/src/backend/gen_insn_selection_optimize.cpp
++++ a/backend/src/backend/gen_insn_selection_optimize.cpp
+@@ -74,7 +74,8 @@ namespace gbe
+ const GenRegister& replacement) :
+ insn(insn), intermedia(intermedia), replacement(replacement)
+ {
+- assert(insn.opcode == SEL_OP_MOV || insn.opcode == SEL_OP_ADD);
++ assert(insn.opcode == SEL_OP_MOV);
++ assert(&(insn.src(0)) == &replacement);
+ assert(&(insn.dst(0)) == &intermedia);
+ this->elements = CalculateElements(intermedia, insn.state.execWidth);
+ replacementOverwritten = false;
+@@ -101,7 +102,6 @@ namespace gbe
+ void doReplacement(ReplaceInfo* info);
+ bool CanBeReplaced(const ReplaceInfo* info, const SelectionInstruction& insn, const GenRegister& var);
+ void cleanReplaceInfoMap();
+- void doNegAddOptimization(SelectionInstruction &insn);
+
+ SelectionBlock &bb;
+ const ir::Liveness::LiveOut& liveout;
+@@ -159,13 +159,8 @@ namespace gbe
+
+ void SelBasicBlockOptimizer::addToReplaceInfoMap(SelectionInstruction& insn)
+ {
+- assert(insn.opcode == SEL_OP_MOV || insn.opcode == SEL_OP_ADD);
+- GenRegister &src = insn.src(0);
+- if (insn.opcode == SEL_OP_ADD) {
+- if (src.file == GEN_IMMEDIATE_VALUE)
+- src = insn.src(1);
+- }
+-
++ assert(insn.opcode == SEL_OP_MOV);
++ const GenRegister& src = insn.src(0);
+ const GenRegister& dst = insn.dst(0);
+ if (src.type != dst.type || src.file != dst.file)
+ return;
+@@ -254,29 +249,10 @@ namespace gbe
+
+ if (insn.opcode == SEL_OP_MOV)
+ addToReplaceInfoMap(insn);
+-
+- doNegAddOptimization(insn);
+ }
+ cleanReplaceInfoMap();
+ }
+
+- /* LLVM transform Mad(a, -b, c) to
+- Add b, -b, 0
+- Mad val, a, b, c
+- for Gen support negtive modifier, mad(a, -b, c) is native suppoted.
+- Also it can be used for the same like instruction sequence.
+- Do it just like a: mov b, -b, so it is a Mov operation like LocalCopyPropagation
+- */
+- void SelBasicBlockOptimizer::doNegAddOptimization(SelectionInstruction &insn) {
+- if (insn.opcode == SEL_OP_ADD) {
+- GenRegister src0 = insn.src(0);
+- GenRegister src1 = insn.src(1);
+- if ((src0.negation && src1.file == GEN_IMMEDIATE_VALUE && src1.value.f == 0.0f) ||
+- (src1.negation && src0.file == GEN_IMMEDIATE_VALUE && src0.value.f == 0.0f))
+- addToReplaceInfoMap(insn);
+- }
+- }
+-
+ void SelBasicBlockOptimizer::run()
+ {
+ for (size_t i = 0; i < MaxTries; ++i) {
diff --git a/dev-libs/beignet/files/beignet-1.3.2_llvm6.patch b/dev-libs/beignet/files/beignet-1.3.2_llvm6.patch
new file mode 100644
index 0000000..be3ccbc
--- /dev/null
+++ b/dev-libs/beignet/files/beignet-1.3.2_llvm6.patch
@@ -0,0 +1,27 @@
+--- a/backend/src/llvm/llvm_to_gen.cpp
++++ b/backend/src/llvm/llvm_to_gen.cpp
+@@ -322,7 +322,11 @@ namespace gbe
+ DataLayout DL(&mod);
+
+ gbeDiagnosticContext dc;
++#if LLVM_VERSION_MAJOR >= 6
++ mod.getContext().setDiagnosticHandlerCallBack(&gbeDiagnosticHandler,&dc);
++#else
+ mod.getContext().setDiagnosticHandler(&gbeDiagnosticHandler,&dc);
++#endif
+
+ #if LLVM_VERSION_MAJOR * 10 + LLVM_VERSION_MINOR >= 37
+ mod.setDataLayout(DL);
+--- a/backend/src/llvm/llvm_unroll.cpp
++++ b/backend/src/llvm/llvm_unroll.cpp
+@@ -205,7 +205,9 @@ namespace gbe {
+ if (parentTripCount != 0 && currTripCount * parentTripCount > 32) {
+ //Don't change the unrollID if doesn't force unroll.
+ //setUnrollID(parentL, false);
+-#if LLVM_VERSION_MAJOR * 10 + LLVM_VERSION_MINOR >= 38
++#if LLVM_VERSION_MAJOR >= 6
++ loopInfo.erase(parentL);
++#elif LLVM_VERSION_MAJOR * 10 + LLVM_VERSION_MINOR >= 38
+ loopInfo.markAsRemoved(parentL);
+ #else
+ LPM.deleteLoopFromQueue(parentL);
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 0000000..8990f0f
--- /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"
diff --git a/dev-libs/beignet/files/llvm-terminfo.patch b/dev-libs/beignet/files/llvm-terminfo.patch
new file mode 100644
index 0000000..afbbc26
--- /dev/null
+++ b/dev-libs/beignet/files/llvm-terminfo.patch
@@ -0,0 +1,20 @@
+--- a/backend/src/CMakeLists.txt 2015-12-18 07:40:03.000000000 +0100
++++ b/backend/src/CMakeLists.txt 2016-08-01 13:44:31.475875150 +0200
+@@ -153,7 +153,7 @@
+
+ add_library(gbeinterp SHARED gbe_bin_interpreter.cpp)
+
+-if (LLVM_VERSION_NODOT VERSION_EQUAL 34)
++if (NOT (LLVM_VERSION_NODOT LESS 34))
+ find_library(TERMINFO NAMES tinfo ncurses)
+ if (${TERMINFO} STREQUAL TERMINFO-NOTFOUND)
+ message(FATAL_ERROR "no libtinfo or libncurses is found in system")
+@@ -161,7 +161,7 @@
+ target_link_libraries(gbe ${TERMINFO})
+ message(STATUS "use ${TERMINFO} as terminal control library")
+ endif (${TERMINFO} STREQUAL TERMINFO-NOTFOUND)
+-endif(LLVM_VERSION_NODOT VERSION_EQUAL 34)
++endif(NOT (LLVM_VERSION_NODOT LESS 34))
+
+ link_directories (${LLVM_LIBRARY_DIR} ${DRM_LIBDIR})
+
diff --git a/dev-libs/beignet/files/no-debian-multiarch.patch b/dev-libs/beignet/files/no-debian-multiarch.patch
new file mode 100644
index 0000000..c9aef4d
--- /dev/null
+++ b/dev-libs/beignet/files/no-debian-multiarch.patch
@@ -0,0 +1,39 @@
+--- a/CMakeLists.txt 2015-04-17 04:27:51.000000000 +0200
++++ b/CMakeLists.txt 2015-05-20 20:59:17.895041760 +0200
+@@ -39,14 +39,9 @@
+
+ SET(CMAKE_VERBOSE_MAKEFILE "false")
+ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/CMake/")
+-INCLUDE (GNUInstallDirs OPTIONAL)
+-# support old CMake without GNUInstallDirs
+-if (NOT CMAKE_INSTALL_FULL_LIBDIR)
+- set (CMAKE_INSTALL_FULL_LIBDIR "${CMAKE_INSTALL_PREFIX}/lib")
+- set (BEIGNET_LIBRARY_ARCHITECTURE "")
+-else (NOT CMAKE_INSTALL_FULL_LIBDIR)
+- set (BEIGNET_LIBRARY_ARCHITECTURE "${CMAKE_LIBRARY_ARCHITECTURE}")
+-endif (NOT CMAKE_INSTALL_FULL_LIBDIR)
++
++set (CMAKE_INSTALL_FULL_LIBDIR "${CMAKE_INSTALL_PREFIX}/lib")
++set (BEIGNET_LIBRARY_ARCHITECTURE "")
+
+ if (NOT LIB_INSTALL_DIR)
+ set (LIB_INSTALL_DIR "${CMAKE_INSTALL_FULL_LIBDIR}")
+@@ -55,17 +50,7 @@
+ set (BEIGNET_INSTALL_DIR "${LIB_INSTALL_DIR}/beignet/")
+ endif (NOT BEIGNET_INSTALL_DIR)
+
+-# allow co-installation of 32- and 64-bit versions:
+-# https://wiki.debian.org/Multiarch
+-if (BEIGNET_INSTALL_DIR STREQUAL "${CMAKE_INSTALL_PREFIX}/lib/beignet/")
+- set (ICD_FILE_NAME "intel-beignet.icd")
+-else (BEIGNET_INSTALL_DIR STREQUAL "${CMAKE_INSTALL_PREFIX}/lib/beignet/")
+- if (BEIGNET_LIBRARY_ARCHITECTURE STREQUAL "")
+- set (ICD_FILE_NAME "intel-beignet.icd")
+- else (BEIGNET_LIBRARY_ARCHITECTURE STREQUAL "")
+- set (ICD_FILE_NAME "intel-beignet-${BEIGNET_LIBRARY_ARCHITECTURE}.icd")
+- endif (BEIGNET_LIBRARY_ARCHITECTURE STREQUAL "")
+-endif (BEIGNET_INSTALL_DIR STREQUAL "${CMAKE_INSTALL_PREFIX}/lib/beignet/")
++set (ICD_FILE_NAME "intel-beignet.icd")
+
+ # Force Release with debug info
+ if (NOT CMAKE_BUILD_TYPE)
diff --git a/dev-libs/beignet/metadata.xml b/dev-libs/beignet/metadata.xml
new file mode 100644
index 0000000..917f7f9
--- /dev/null
+++ b/dev-libs/beignet/metadata.xml
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd">
+<pkgmetadata>
+ <maintainer type="person">
+ <email>marecki@gentoo.org</email>
+ <name>Marek Szuba</name>
+ </maintainer>
+ <use>
+ <flag name="ocl-icd">Enable compatibility with the
+ <pkg>dev-libs/ocl-icd</pkg> OpenCL ICD loader</flag>
+ <flag name="ocl20">Enable experimental OpenCL 2.0 support on Skylake
+ and newer architectures</flag>
+ </use>
+</pkgmetadata>