[llvm] df6291a - [CMake][MSVC] Compile with `/permissive-`
Eli Friedman via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 20 12:44:04 PDT 2022
Author: Mehdi Chinoune
Date: 2022-06-20T12:42:51-07:00
New Revision: df6291a666d3be784e2bbd00e4dbcdcceaf0196f
URL: https://github.com/llvm/llvm-project/commit/df6291a666d3be784e2bbd00e4dbcdcceaf0196f
DIFF: https://github.com/llvm/llvm-project/commit/df6291a666d3be784e2bbd00e4dbcdcceaf0196f.diff
LOG: [CMake][MSVC] Compile with `/permissive-`
This turns off a bunch of non-standard behaviors in MSVC. LLVM, as a
portable codebase, should build correctly without those behaviors. Note
that `/permissive-` implies `/Zc:strictStrings` and `/Zc:rvalueCast`.
See also:
https://docs.microsoft.com/en-us/cpp/build/reference/permissive-standards-conformance
Differential Revision: https://reviews.llvm.org/D125263
Added:
Modified:
llvm/cmake/modules/HandleLLVMOptions.cmake
Removed:
################################################################################
diff --git a/llvm/cmake/modules/HandleLLVMOptions.cmake b/llvm/cmake/modules/HandleLLVMOptions.cmake
index f39ec2c527f48..56d05f5b5fced 100644
--- a/llvm/cmake/modules/HandleLLVMOptions.cmake
+++ b/llvm/cmake/modules/HandleLLVMOptions.cmake
@@ -522,17 +522,9 @@ if( MSVC )
endif()
endif()
- # Disable string literal const->non-const type conversion.
- # "When specified, the compiler requires strict const-qualification
- # conformance for pointers initialized by using string literals."
- append("/Zc:strictStrings" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
-
# "Generate Intrinsic Functions".
append("/Oi" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
- # "Enforce type conversion rules".
- append("/Zc:rvalueCast" CMAKE_CXX_FLAGS)
-
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND NOT LLVM_ENABLE_LTO)
# clang-cl and cl by default produce non-deterministic binaries because
# link.exe /incremental requires a timestamp in the .obj file. clang-cl
@@ -561,6 +553,10 @@ if( MSVC )
# but in many objects files need more than that. This flag is to increase the
# number of sections.
append("/bigobj" CMAKE_CXX_FLAGS)
+
+ # Enable standards conformance mode.
+ # This ensures handling of various C/C++ constructs is more similar to other compilers.
+ append("/permissive-" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
endif( MSVC )
# Warnings-as-errors handling for GCC-compatible compilers:
More information about the llvm-commits
mailing list