[PATCH] [compiler-rt][CMake] Filter MSVC-specific warning flags from CMAKE_*_FLAGS when building with clang.exe

Greg Bedwell greg_bedwell at sn.scee.net
Fri Mar 13 11:58:53 PDT 2015


Hi kcc, samsonov,

This fixes a compiler-rt build failure introduced by r231924 (temporarily reverted in r231925 pending this fix).
r231924 modified HandleLLVMOptions.cmake to pass in MSVC warning promotion/suppression flags as flags rather than as definitions ( see http://reviews.llvm.org/D8188 ).  This meant that under the (MSVC) condition in CMake, we'd get new flags in the form /wNNNN, /wdNNNN and /weNNNN within CMAKE_*_FLAGS.  These are not accepted by clang.exe resulting in an error building compiler-rt within the context of an MSVC build.

I found the existing code that converts from the '/flag' form to the '-flag' form when building with clang.exe under the (MSVC) condition and extended it to remove the above flags entirely.

Thanks,

Greg Bedwell
SN Systems Ltd - Sony Computer Entertainment Group

http://reviews.llvm.org/D8326

Files:
  cmake/Modules/CompilerRTCompile.cmake

Index: cmake/Modules/CompilerRTCompile.cmake
===================================================================
--- cmake/Modules/CompilerRTCompile.cmake
+++ cmake/Modules/CompilerRTCompile.cmake
@@ -21,9 +21,13 @@
     string(REPLACE " " ";" global_flags "${CMAKE_C_FLAGS}")
   endif()
   # On Windows, CMAKE_*_FLAGS are built for MSVC but we use the GCC clang.exe
-  # which doesn't support flags starting with "/smth". Replace those with
-  # "-smth" equivalents.
+  # so perform any required transformations to ensure that they are accepted.
   if(MSVC)
+    # The MSVC warning suppression/promotion flags are meaningless and
+    # unsupported here so remove them.
+    string(REGEX REPLACE "/w[de]?[0-9]+(;|$)" "" global_flags "${global_flags}")
+
+    # Replace flags starting with "/smth" with "-smth" equivalents.
     string(REGEX REPLACE "^/" "-" global_flags "${global_flags}")
     string(REPLACE ";/" ";-" global_flags "${global_flags}")
   endif()

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D8326.21938.patch
Type: text/x-patch
Size: 964 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150313/1bb15349/attachment.bin>


More information about the llvm-commits mailing list