opencl-clang: fix runtime error

Error log:
clang (LLVM option parsing): Unknown command line argument '-pgo-warn-misexpect'.
Try: 'clang (LLVM option parsing) --help'

Force opencl-clang to link with shared clang-cpp for target builds and
explicitly link with spirv library because of a change in behaviour in llvm 10.

Use the patch to link with all static libs only for native cases where meta-clang
default to building static libs only by default.

Signed-off-by: Naveen Saini <naveen.kumar.saini@intel.com>
Signed-off-by: Anuj Mittal <anuj.mittal@intel.com>
This commit is contained in:
Naveen Saini 2020-04-16 16:22:38 +08:00 committed by Anuj Mittal
parent ee68102442
commit 52dc027375
4 changed files with 80 additions and 34 deletions

View File

@ -0,0 +1,35 @@
From 7fc05c52dd91902fa324a7aac9b90715cfca4717 Mon Sep 17 00:00:00 2001
From: Naveen Saini <naveen.kumar.saini@intel.com>
Date: Wed, 15 Apr 2020 17:55:32 +0800
Subject: [PATCH] Building in-tree with LLVM 10.0 with the LLVM_LINK_LLVM_DYLIB
Failed to link with the LLVMSPIRVLib library.
Add an explicit dependency to force the correct build order and linking.
Reference:
https://github.com/KhronosGroup/SPIRV-LLVM-Translator/commit/a6d4ccf082858e63e139ca06c02a071c343d2657
Upstream-Status: Submitted [https://github.com/intel/opencl-clang/pull/118]
Signed-off-by: Naveen Saini <naveen.kumar.saini@intel.com>
---
CMakeLists.txt | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 51c140d..b8b514e 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -208,7 +208,7 @@ link_directories(
set(OPENCL_CLANG_LINK_LIBS ${CMAKE_DL_LIBS})
-if(NOT LLVMSPIRVLib IN_LIST LLVM_AVAILABLE_LIBS)
+if(NOT LLVMSPIRVLib IN_LIST LLVM_AVAILABLE_LIBS OR (USE_PREBUILT_LLVM AND LLVM_LINK_LLVM_DYLIB))
# SPIRV-LLVM-Translator is not included into LLVM as a component.
# So, we need to list it here explicitly as an external library
list(APPEND OPENCL_CLANG_LINK_LIBS LLVMSPIRVLib)
--
2.17.1

View File

@ -0,0 +1,42 @@
From b29e00e6fe428a031cf577dfb703cf13eff837f6 Mon Sep 17 00:00:00 2001
From: Naveen Saini <naveen.kumar.saini@intel.com>
Date: Wed, 15 Apr 2020 18:05:14 +0800
Subject: [PATCH 2/2] make sure only static libraries linked for native build
LINK_COMPONENTS=all isn't working for static libs for out of tree builds. Use
LLVM_AVAILABLE_LIBS instead. Reported:
https://github.com/intel/opencl-clang/issues/114
Upstream-Status: Pending
Signed-off-by: Anuj Mittal <anuj.mittal@intel.com>
Signed-off-by: Naveen Saini <naveen.kumar.saini@intel.com>
---
CMakeLists.txt | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 8707487..ad2dbda 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -218,7 +218,7 @@ add_subdirectory(cl_headers)
set(LLVM_REQUIRES_EH ON)
-if(USE_PREBUILT_LLVM OR CLANG_LINK_CLANG_DYLIB)
+if(false)
list(APPEND OPENCL_CLANG_LINK_LIBS clang-cpp)
else()
list(APPEND OPENCL_CLANG_LINK_LIBS
@@ -266,6 +266,7 @@ add_llvm_library(${TARGET_NAME} SHARED
all
LINK_LIBS
${OPENCL_CLANG_LINK_LIBS}
+ ${LLVM_AVAILABLE_LIBS}
)
# Configure resource file on Windows
--
2.17.1

View File

@ -1,32 +0,0 @@
From cc0769fb72561f82976e40c5b7ea8bf07069c87a Mon Sep 17 00:00:00 2001
From: Anuj Mittal <anuj.mittal@intel.com>
Date: Thu, 19 Mar 2020 16:30:07 +0800
Subject: [PATCH] link to all libs
LINK_COMPONENTS=all isn't working for static libs for out of tree builds. Use
LLVM_AVAILABLE_LIBS instead. Reported:
https://github.com/intel/opencl-clang/issues/114
Upstream-Status: Pending
Signed-off-by: Anuj Mittal <anuj.mittal@intel.com>
---
CMakeLists.txt | 1 +
1 file changed, 1 insertion(+)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 4590a11..2ff9901 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -261,6 +261,7 @@ add_llvm_library(${TARGET_NAME} SHARED
clangLex
clangBasic
${ADDITIONAL_LIBS}
+ ${LLVM_AVAILABLE_LIBS}
)
# Configure resource file on Windows
--
2.25.1

View File

@ -7,10 +7,11 @@ LIC_FILES_CHKSUM = "file://LICENSE;md5=e8a15bf1416762a09ece07e44c79118c"
SRC_URI = "git://github.com/intel/opencl-clang.git;branch=ocl-open-100;protocol=https \
file://0001-don-t-redefine-LLVM_TABLEGEN_EXE.patch \
file://link-with-all-libs.patch \
file://0001-Building-in-tree-with-LLVM-10.0-with-the-LLVM_LINK_L.patch \
"
SRC_URI_append_class-native = " file://0002-make-sure-only-static-libraries-linked-for-native-bu.patch"
SRCREV = "0a5a9f67b56431ef7b9436d1af812df6dfb44975"
SRCREV = "9f0c2c0f5ddea1accc921aed4c94bc52c1b85637"
S = "${WORKDIR}/git"