4ca785
From 59c38a2216f4467b53970bb6b010bc4fe0b8d1d3 Mon Sep 17 00:00:00 2001
4ca785
From: serge-sans-paille <sguelton@redhat.com>
4ca785
Date: Fri, 25 Jan 2019 17:32:54 +0000
4ca785
Subject: [PATCH 1/2] [PATCH] Filter out cxxflags not supported by clang
4b6a50
4b6a50
---
4b6a50
 cmake/modules/AddLLVM.cmake       | 6 +++++-
4b6a50
 cmake/modules/CMakeLists.txt      | 3 +++
4b6a50
 cmake/modules/LLVMConfig.cmake.in | 2 ++
4ca785
 tools/llvm-config/CMakeLists.txt  | 4 ++++
4ca785
 4 files changed, 14 insertions(+), 1 deletion(-)
4b6a50
4b6a50
diff --git a/cmake/modules/AddLLVM.cmake b/cmake/modules/AddLLVM.cmake
4ca785
index 4dbc0ddaf4f..c408377cd2e 100644
4b6a50
--- a/cmake/modules/AddLLVM.cmake
4b6a50
+++ b/cmake/modules/AddLLVM.cmake
4ca785
@@ -664,7 +664,11 @@ macro(add_llvm_library name)
4b6a50
 
4b6a50
       if(${name} IN_LIST LLVM_DISTRIBUTION_COMPONENTS OR
4b6a50
           NOT LLVM_DISTRIBUTION_COMPONENTS)
4b6a50
-        set(export_to_llvmexports EXPORT LLVMExports)
4b6a50
+        if (ARG_SHARED)
4b6a50
+          set(export_to_llvmexports EXPORT LLVMExports)
4b6a50
+        else()
4b6a50
+          set(export_to_llvmexports EXPORT LLVMStaticExports)
4b6a50
+        endif()
4b6a50
         set_property(GLOBAL PROPERTY LLVM_HAS_EXPORTS True)
4b6a50
       endif()
4b6a50
 
4b6a50
diff --git a/cmake/modules/CMakeLists.txt b/cmake/modules/CMakeLists.txt
4ca785
index f5cc0006fa0..6605dc729c2 100644
4b6a50
--- a/cmake/modules/CMakeLists.txt
4b6a50
+++ b/cmake/modules/CMakeLists.txt
4ca785
@@ -97,6 +97,7 @@ set(LLVM_CONFIG_BINARY_DIR "\${LLVM_INSTALL_PREFIX}")
4ca785
 set(LLVM_CONFIG_TOOLS_BINARY_DIR "\${LLVM_INSTALL_PREFIX}/${LLVM_TOOLS_INSTALL_DIR}")
4b6a50
 set(LLVM_CONFIG_EXPORTS_FILE "\${LLVM_CMAKE_DIR}/LLVMExports.cmake")
4b6a50
 set(LLVM_CONFIG_EXPORTS "${LLVM_EXPORTS}")
4b6a50
+set(LLVM_CONFIG_STATIC_EXPORTS_FILE "\${LLVM_CMAKE_DIR}/LLVMStaticExports.cmake")
4b6a50
 configure_file(
4b6a50
   LLVMConfig.cmake.in
4b6a50
   ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/LLVMConfig.cmake
4ca785
@@ -113,6 +114,8 @@ if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
4b6a50
   if(llvm_has_exports)
4b6a50
     install(EXPORT LLVMExports DESTINATION ${LLVM_INSTALL_PACKAGE_DIR}
4b6a50
             COMPONENT cmake-exports)
4b6a50
+    install(EXPORT LLVMStaticExports DESTINATION ${LLVM_INSTALL_PACKAGE_DIR}
4b6a50
+            COMPONENT cmake-exports)
4b6a50
   endif()
4b6a50
 
4b6a50
   install(FILES
4b6a50
diff --git a/cmake/modules/LLVMConfig.cmake.in b/cmake/modules/LLVMConfig.cmake.in
4ca785
index 7ca06381d90..44d042c9b11 100644
4b6a50
--- a/cmake/modules/LLVMConfig.cmake.in
4b6a50
+++ b/cmake/modules/LLVMConfig.cmake.in
4ca785
@@ -84,6 +84,8 @@ if(NOT TARGET LLVMSupport)
4b6a50
   set(LLVM_EXPORTED_TARGETS "@LLVM_CONFIG_EXPORTS@")
4b6a50
   include("@LLVM_CONFIG_EXPORTS_FILE@")
4b6a50
   @llvm_config_include_buildtree_only_exports@
4b6a50
+
4b6a50
+  include("@LLVM_CONFIG_STATIC_EXPORTS_FILE@" OPTIONAL)
4b6a50
 endif()
4b6a50
 
a264db
 # By creating intrinsics_gen here, subprojects that depend on LLVM's
4ca785
diff --git a/tools/llvm-config/CMakeLists.txt b/tools/llvm-config/CMakeLists.txt
4ca785
index a7db17386fb..8a796d03b5a 100644
4ca785
--- a/tools/llvm-config/CMakeLists.txt
4ca785
+++ b/tools/llvm-config/CMakeLists.txt
4ca785
@@ -42,7 +42,11 @@ set(LLVM_SRC_ROOT ${LLVM_MAIN_SRC_DIR})
4ca785
 set(LLVM_OBJ_ROOT ${LLVM_BINARY_DIR})
4ca785
 set(LLVM_CPPFLAGS "${LLVM_DEFINITIONS}")
4ca785
 set(LLVM_CFLAGS "${LLVM_C_STD_FLAG} ${LLVM_DEFINITIONS}")
4ca785
+STRING(REGEX REPLACE "-mcet" "" LLVM_CFLAGS ${LLVM_CFLAGS})
4ca785
+STRING(REGEX REPLACE "-fcf-protection" "" LLVM_CFLAGS ${LLVM_CFLAGS})
4ca785
 set(LLVM_CXXFLAGS "${LLVM_CXX_STD_FLAG} ${COMPILE_FLAGS} ${LLVM_DEFINITIONS}")
4ca785
+STRING(REGEX REPLACE "-mcet" "" LLVM_CXXFLAGS ${LLVM_CXXFLAGS})
4ca785
+STRING(REGEX REPLACE "-fcf-protection" "" LLVM_CXXFLAGS ${LLVM_CXXFLAGS})
4ca785
 set(LLVM_BUILD_SYSTEM cmake)
4ca785
 set(LLVM_HAS_RTTI ${LLVM_CONFIG_HAS_RTTI})
4ca785
 set(LLVM_DYLIB_VERSION "${LLVM_VERSION_MAJOR}${LLVM_VERSION_SUFFIX}")
4b6a50
-- 
4ca785
2.19.2
4b6a50