[PATCH] D58767: [compiler-rt] [CMake] Check for llvm_replace_compiler_option before using it

Martin Storsjö via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 28 02:47:09 PST 2019


mstorsjo created this revision.
mstorsjo added a reviewer: rnk.
Herald added subscribers: Sanitizers, jdoerfert, mgorny, dberris.
Herald added projects: LLVM, Sanitizers.

This fixes building compiler-rt standalone with MSVC/clang-cl, where this cmake command isn't available.


Repository:
  rCRT Compiler Runtime

https://reviews.llvm.org/D58767

Files:
  CMakeLists.txt


Index: CMakeLists.txt
===================================================================
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -375,9 +375,11 @@
   # warning from the MS linker complaining that it can't find the 'vc140.pdb'
   # file used by our object library compilations.
   list(APPEND SANITIZER_COMMON_CFLAGS /Z7)
-  llvm_replace_compiler_option(CMAKE_CXX_FLAGS "/Z[i7I]" "/Z7")
-  llvm_replace_compiler_option(CMAKE_CXX_FLAGS_DEBUG "/Z[i7I]" "/Z7")
-  llvm_replace_compiler_option(CMAKE_CXX_FLAGS_RELWITHDEBINFO "/Z[i7I]" "/Z7")
+  if(COMMAND llvm_replace_compiler_option)
+    llvm_replace_compiler_option(CMAKE_CXX_FLAGS "/Z[i7I]" "/Z7")
+    llvm_replace_compiler_option(CMAKE_CXX_FLAGS_DEBUG "/Z[i7I]" "/Z7")
+    llvm_replace_compiler_option(CMAKE_CXX_FLAGS_RELWITHDEBINFO "/Z[i7I]" "/Z7")
+  endif()
 elseif(COMPILER_RT_HAS_GLINE_TABLES_ONLY_FLAG AND NOT COMPILER_RT_DEBUG)
   list(APPEND SANITIZER_COMMON_CFLAGS -gline-tables-only)
 elseif(COMPILER_RT_HAS_G_FLAG)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D58767.188693.patch
Type: text/x-patch
Size: 981 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190228/74ecc1b3/attachment.bin>


More information about the llvm-commits mailing list