From 5b9433484c5a1d47110b6d9da73795b7a66dd39b Mon Sep 17 00:00:00 2001 From: Jan Palus Date: Sun, 8 Sep 2019 11:38:13 +0200 Subject: [PATCH] adjust for llvm 8 and spirv translator 8; rel 2 --- align-with-modified-llvm-writespirv-api.patch | 71 +++++++++++++++++++ llvm_clang_vfs.patch | 25 ------- opencl-clang.spec | 20 +++--- 3 files changed, 80 insertions(+), 36 deletions(-) create mode 100644 align-with-modified-llvm-writespirv-api.patch delete mode 100644 llvm_clang_vfs.patch diff --git a/align-with-modified-llvm-writespirv-api.patch b/align-with-modified-llvm-writespirv-api.patch new file mode 100644 index 0000000..a0d6f98 --- /dev/null +++ b/align-with-modified-llvm-writespirv-api.patch @@ -0,0 +1,71 @@ +From 94af090661d7c953c516c97a25ed053c744a0737 Mon Sep 17 00:00:00 2001 +From: Alexey Sotkin +Date: Mon, 18 Feb 2019 18:19:13 +0300 +Subject: [PATCH] Align with modified llvm::writeSpirv API + +--- + common_clang.cpp | 29 +++++++++++++++++++++++++---- + 1 file changed, 25 insertions(+), 4 deletions(-) + +diff --git a/common_clang.cpp b/common_clang.cpp +index eff1064..ee1ec9b 100644 +--- a/common_clang.cpp ++++ b/common_clang.cpp +@@ -63,17 +63,18 @@ Copyright (c) Intel Corporation (2009-2017). + #define CL_OUT_OF_HOST_MEMORY -6 + + #include "assert.h" +-#include ++#include + #include +-#include + #include +-#include ++#include ++#include + #ifdef _WIN32 + #include + #endif + + #if defined _DEBUG + #include ++#include + #include + #include + #endif +@@ -164,6 +165,25 @@ static void PrintCompileOptions(const char *pszOptions, const char *pszOptionsEx + #endif + } + ++class SmallVectorBuffer : public std::streambuf ++{ ++ // All memory management is delegated to llvm::SmallVectorImpl ++ llvm::SmallVectorImpl &OS; ++ ++ // Since we don't touch any pointer in streambuf(pbase, pptr, epptr) this is ++ // the only method we need to override. ++ virtual std::streamsize xsputn(const char *s, std::streamsize n) override { ++ OS.append(s, s + n); ++ return n; ++ } ++ ++public: ++ SmallVectorBuffer() = delete; ++ SmallVectorBuffer(const SmallVectorBuffer&) = delete; ++ SmallVectorBuffer &operator=(const SmallVectorBuffer&) = delete; ++ SmallVectorBuffer(llvm::SmallVectorImpl &O) : OS(O) {} ++}; ++ + extern "C" CC_DLL_EXPORT int + Compile(const char *pszProgramSource, const char **pInputHeaders, + unsigned int uiNumInputHeaders, const char **pInputHeadersNames, +@@ -300,7 +320,8 @@ Compile(const char *pszProgramSource, const char **pInputHeaders, + return CL_COMPILE_PROGRAM_FAILURE; + } + pResult->getIRBufferRef().clear(); +- llvm::raw_svector_ostream OS(pResult->getIRBufferRef()); ++ SmallVectorBuffer StreamBuf(pResult->getIRBufferRef()); ++ std::ostream OS(&StreamBuf); + std::string Err; + success = llvm::writeSpirv(M.get(), OS, Err); + err_ostream << Err.c_str(); diff --git a/llvm_clang_vfs.patch b/llvm_clang_vfs.patch deleted file mode 100644 index f64fdf8..0000000 --- a/llvm_clang_vfs.patch +++ /dev/null @@ -1,25 +0,0 @@ -diff -dur opencl-clang-8.0.1.orig/common_clang.cpp opencl-clang-8.0.1/common_clang.cpp ---- opencl-clang-8.0.1.orig/common_clang.cpp 2019-06-04 15:59:30.000000000 +0200 -+++ opencl-clang-8.0.1/common_clang.cpp 2019-06-27 10:24:52.000000000 +0200 -@@ -40,7 +40,7 @@ - #include "llvm/Support/TargetSelect.h" - #include "llvm/Support/ManagedStatic.h" - #include "llvm/Support/Mutex.h" --#include "llvm/Support/VirtualFileSystem.h" -+#include "clang/Basic/VirtualFileSystem.h" - #include "clang/Basic/LangOptions.h" - #include "clang/Basic/Diagnostic.h" - #include "clang/Basic/DiagnosticIDs.h" -@@ -215,9 +215,9 @@ - - compiler->setDiagnostics(&*Diags); - -- auto OverlayFS = new llvm::vfs::OverlayFileSystem( -- llvm::vfs::getRealFileSystem()); -- auto MemFS = new llvm::vfs::InMemoryFileSystem(); -+ auto OverlayFS = new clang::vfs::OverlayFileSystem( -+ clang::vfs::getRealFileSystem()); -+ auto MemFS = new clang::vfs::InMemoryFileSystem(); - OverlayFS->pushOverlay(MemFS); - - compiler->setVirtualFileSystem(OverlayFS); diff --git a/opencl-clang.spec b/opencl-clang.spec index a48bf67..6fbee66 100644 --- a/opencl-clang.spec +++ b/opencl-clang.spec @@ -1,25 +1,24 @@ # requires the OpenCL patches -%define llvm_version 7.0.1 -%define llvm_rpm_version %{llvm_version}-3 +%define llvm_version 8.0.1 -%define spirv_llvm_translator_version 7.0.1 +%define spirv_llvm_translator_version 8.0.1 Summary: Intel Graphics Compute Runtime for OpenCL Name: opencl-clang Version: 8.0.1 -Release: 1 +Release: 2 License: University of Illinois/NCSA Open Source License Group: Libraries Source0: https://github.com/intel/opencl-clang/archive/v%{version}/%{name}-%{version}.tar.gz # Source0-md5: cb6b746c837a6cac6c8906911b2ea9de -Patch0: llvm_clang_vfs.patch +Patch0: align-with-modified-llvm-writespirv-api.patch URL: https://01.org/compute-runtime BuildRequires: SPIRV-LLVM-Translator-devel >= %{spirv_llvm_translator_version} BuildRequires: clang >= %{llvm_rpm_version} -BuildRequires: clang-devel >= %{llvm_rpm_version} +BuildRequires: clang-devel >= %{llvm_version} BuildRequires: cmake >= 3.4.3 -BuildRequires: llvm-devel >= %{llvm_rpm_version} +BuildRequires: llvm-devel >= %{llvm_version} BuildRequires: pkgconfig BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n) @@ -43,7 +42,6 @@ Pliki nagłówkowe biblioteki %{name}. %prep %setup -q - %patch0 -p1 %build @@ -66,8 +64,8 @@ rm -rf $RPM_BUILD_ROOT %{__make} -C build install \ DESTDIR=$RPM_BUILD_ROOT -mv $RPM_BUILD_ROOT%{_libdir}/libopencl-clang.so.7 $RPM_BUILD_ROOT%{_libdir}/libopencl-clang.so.%{llvm_version} -ln -s libopencl-clang.so.%{llvm_version} $RPM_BUILD_ROOT%{_libdir}/libopencl-clang.so.7 +mv $RPM_BUILD_ROOT%{_libdir}/libopencl-clang.so.8 $RPM_BUILD_ROOT%{_libdir}/libopencl-clang.so.%{llvm_version} +ln -s libopencl-clang.so.%{llvm_version} $RPM_BUILD_ROOT%{_libdir}/libopencl-clang.so.8 ln -sf libopencl-clang.so.%{llvm_version} $RPM_BUILD_ROOT%{_libdir}/libopencl-clang.so %post -p /sbin/ldconfig @@ -80,7 +78,7 @@ rm -rf $RPM_BUILD_ROOT %defattr(644,root,root,755) %doc README.md %attr(755,root,root) %{_libdir}/libopencl-clang.so.%{llvm_version} -%ghost %attr(755,root,root) %{_libdir}/libopencl-clang.so.7 +%ghost %attr(755,root,root) %{_libdir}/libopencl-clang.so.8 %files devel %defattr(644,root,root,755) -- 2.43.0