[llvm] r258687 - Reapplying r256836 with a fix for MSVC 14 support.

Ismail Donmez via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 26 00:19:44 PST 2016


Hi,

On Mon, Jan 25, 2016 at 4:17 PM, Aaron Ballman via llvm-commits
<llvm-commits at lists.llvm.org> wrote:
> Author: aaronballman
> Date: Mon Jan 25 08:17:39 2016
> New Revision: 258687
>
> URL: http://llvm.org/viewvc/llvm-project?rev=258687&view=rev
> Log:
> Reapplying r256836 with a fix for MSVC 14 support.
>
> Enable more strict standards conformance in MSVC for rvalue casting and string literal type conversion to non-const types. Also enables generation of intrinsics for more functions.
>
> Patch by Alexander Riccio
>
> Modified:
>     llvm/trunk/cmake/modules/HandleLLVMOptions.cmake
>
> Modified: llvm/trunk/cmake/modules/HandleLLVMOptions.cmake
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/cmake/modules/HandleLLVMOptions.cmake?rev=258687&r1=258686&r2=258687&view=diff
> ==============================================================================
> --- llvm/trunk/cmake/modules/HandleLLVMOptions.cmake (original)
> +++ llvm/trunk/cmake/modules/HandleLLVMOptions.cmake Mon Jan 25 08:17:39 2016
> @@ -371,6 +371,23 @@ if( MSVC )
>
>    append("/Zc:inline" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
>
> +  # /Zc:strictStrings is incompatible with VS12's (Visual Studio 2013's)
> +  # debug mode headers. Instead of only enabling them in VS2013's debug mode,
> +  # we'll just enable them for Visual Studio 2015 (VS 14, MSVC_VERSION 1900)
> +  # and up.
> +  if (NOT (MSVC_VERSION LESS 1900))
> +    # 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)
> +  endif(NOT (MSVC_VERSION LESS 1900))
> +
> +  # "Generate Intrinsic Functions".
> +  append("/Oi" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
> +
> +  # "Enforce type conversion rules".
> +  append("/Zc:rvalueCast" CMAKE_CXX_FLAGS)
> +
>    if (NOT LLVM_ENABLE_TIMESTAMPS AND CMAKE_CXX_COMPILER_ID MATCHES "Clang")
>      # clang-cl and cl by default produce non-deterministic binaries because
>      # link.exe /incremental requires a timestamp in the .obj file.  clang-cl

This breaks OpenMP code:

..\projects\openmp\runtime\src\kmp_settings.c(5257): error C2440: '=':
cannot convert from 'const char [5]' to 'char *'
..\projects\openmp\runtime\src\kmp_settings.c(5257): note: Conversion
from string literal loses const qualifier (see /Zc:strictStrings)

which is:

char *str = NULL;
switch ( __kmp_affinity_gran ) {
    case affinity_gran_core: str = "core"; break;
    case affinity_gran_package: str = "package"; break;
    case affinity_gran_node: str = "node"; break;
   default: KMP_DEBUG_ASSERT( 0 );
}

Marking str as const fixes the issue but not sure if it's the right fix.

Regards,
ismail


More information about the llvm-commits mailing list