tstellar / rpms / llvm

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