SHA256
1
0
forked from pool/pocl

Accepting request 719902 from home:StefanBruens:branches:science

- Fix build with LTO enabled
- Fixup build/runtime dependencies
- Correct opencl header lookup

OBS-URL: https://build.opensuse.org/request/show/719902
OBS-URL: https://build.opensuse.org/package/show/science/pocl?expand=0&rev=49
This commit is contained in:
Martin Hauke 2019-07-31 21:55:55 +00:00 committed by Git OBS Bridge
parent e75b135db6
commit 829fed3675
3 changed files with 85 additions and 22 deletions

View File

@ -0,0 +1,44 @@
From dd408ae373b06ee46e178401ab28ecb62b9d2f06 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Stefan=20Br=C3=BCns?= <stefan.bruens@rwth-aachen.de>
Date: Mon, 29 Jul 2019 17:01:50 +0200
Subject: [PATCH] Determine CLANG resources dir at runtime
When the resources dir is determined at compile time, it also includes
the full version (e.g. /usr/lib64/clang/8.0.0/include/opencl-c.h). If
clang gets a minor version update later (e.g. from 8.0.0 to 8.0.1), pocl
will still add the obsolete path for the header lookup.
Determine the path at runtime instead. LLVM 9.0 adds a static method
llvm::driver::Driver::GetResourcesPath(...) which can be used, LLVM 8.0
and older have to use a dummy Driver instance.
Fixes #747.
---
lib/CL/pocl_llvm_build.cc | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/lib/CL/pocl_llvm_build.cc b/lib/CL/pocl_llvm_build.cc
index f0b897f4..00a6fb26 100644
--- a/lib/CL/pocl_llvm_build.cc
+++ b/lib/CL/pocl_llvm_build.cc
@@ -438,7 +438,16 @@ int pocl_llvm_build_program(cl_program program,
po.Includes.push_back(BuiltinRenamesH);
#ifndef LLVM_OLDER_THAN_4_0
// Use Clang's opencl-c.h header.
- po.Includes.push_back(CLANG_RESOURCE_DIR "/include/opencl-c.h");
+ {
+#if (!defined(LLVM_OLDER_THAN_8_0)) && (!defined(LLVM_8_0))
+ std::string ClangResourcesDir = driver::Driver::GetResourcesPath(CLANG);
+#else
+ DiagnosticsEngine Diags{new DiagnosticIDs, new DiagnosticOptions};
+ driver::Driver TheDriver(CLANG, "", Diags);
+ std::string ClangResourcesDir = TheDriver.ResourceDir;
+#endif
+ po.Includes.push_back(ClangResourcesDir + "/include/opencl-c.h");
+ }
#endif
po.Includes.push_back(KernelH);
clang::TargetOptions &ta = pocl_build.getTargetOpts();
--
2.22.0

View File

@ -1,3 +1,20 @@
-------------------------------------------------------------------
Sun Jul 28 19:15:03 UTC 2019 - Stefan Brüns <stefan.bruens@rwth-aachen.de>
- Use GCC (default host compiler) for compiling the library itself,
and only compile the openCL kernel bytecode with clang, which is the
upstream default setup. This also fixes problems where clang chokes
on the GCC LTO options.
- Drop unused boost_headers, glew, ncurses and uthash devel BuildRequires.
- Remove unneeded extra linker flags.
- Fix build on ARM, and enable Arch64 (needs explicit CPU specification),
supported since pocl 1.1.
- Fix failing header lookup when minor libclang version changes
(https://github.com/pocl/pocl/issues/747), add
fix_resources_path_version_dependency.patch
- Require implementation (libpocl2) from the main package which
contains the ICD referencing it.
-------------------------------------------------------------------
Fri Apr 5 19:56:21 UTC 2019 - Martin Hauke <mardnh@gmx.de>

View File

@ -30,28 +30,28 @@ Group: Development/Tools/Other
URL: http://portablecl.org/
Source0: https://github.com/pocl/pocl/archive/v%{version}.tar.gz#/%{name}-%{version}.tar.gz
Source99: pocl-rpmlintrc
BuildRequires: clang < 9
BuildRequires: clang-devel < 9
# PATCH-FIX-UPSTREAM - The clang resources path at compile time includes the full version, determine at runtime
Patch0: fix_resources_path_version_dependency.patch
BuildRequires: clang
BuildConflicts: clang >= 9
BuildRequires: clang-devel >= 4
BuildRequires: cmake
BuildRequires: libboost_headers-devel
BuildRequires: libtool
BuildRequires: gcc-c++
BuildRequires: libtool-ltdl-devel
BuildRequires: ncurses-devel
BuildRequires: ninja
BuildRequires: opencl-headers
BuildRequires: pkgconfig
BuildRequires: uthash-devel
BuildRequires: pkgconfig(OpenCL)
BuildRequires: pkgconfig(glew)
BuildRequires: pkgconfig(hwloc)
Requires: clang < 9
Requires: gcc
Requires: libstdc++-devel
Requires: libut2
# Only armv7l is supported
# PPC support is currently broken, due to path problems
# s390(x) and aarch64 also not supported, so use ExclusiveArch
ExclusiveArch: %{ix86} x86_64 armv7l armv7hl
# Autoreq does not look into the ICD file
Requires: libpocl2
%if 0%{?sle_version} == 150000 && 0%{?is_opensuse}
# Old versions have opencl-c.h in the clang package, not libclang
Requires: clang5
%endif
# PPC has limited support/testing from upstream
# s390(x) is also not supported, so use ExclusiveArch
ExclusiveArch: %{ix86} x86_64 %arm aarch64
%description
Portable Computing Language (pocl) is an implementation of the OpenCL standard
@ -76,7 +76,7 @@ Portable Computing Language (pocl) is an implementation of the OpenCL standard
which can be adapted for new targets and devices, both for homogeneous CPU and
heterogenous GPUs/accelerators.
This subpackage contains the share library part of pocl.
This subpackage contains the shared library part of pocl.
%package devel
Summary: Development files for the Portable Computing Language
@ -94,6 +94,7 @@ This subpackage provides the development files needed for pocl.
%prep
%setup -q
%patch0 -p1
%build
%define __builder ninja
@ -101,16 +102,17 @@ This subpackage provides the development files needed for pocl.
-DENABLE_CUDA=0 \
-DENABLE_ICD=ON \
-DPOCL_INSTALL_ICD_VENDORDIR=%{_sysconfdir}/OpenCL/vendors \
-DCMAKE_C_COMPILER=clang \
-DCMAKE_CXX_COMPILER=clang++ \
%ifarch %{ix86} x86_64
-DKERNELLIB_HOST_CPU_VARIANTS=distro \
%endif
-DEXTRA_KERNEL_CXX_FLAGS="%{optflags} -std=c++11" \
-DCMAKE_EXE_LINKER_FLAGS="-Wl,--as-needed -Wl,-z,now" \
-DCMAKE_MODULE_LINKER_FLAGS="-Wl,--as-needed -Wl,-z,now" \
-DCMAKE_SHARED_LINKER_FLAGS="-Wl,--as-needed -Wl,-z,now" \
%ifarch %{arm}
-DLLC_HOST_CPU=cortex-a9 \
%endif
%ifarch aarch64
-DLLC_HOST_CPU=cortex-a53 \
%endif
-DWITH_LLVM_CONFIG=%{_bindir}/llvm-config
%make_jobs
%install