[Win] Build JSCOnly on Windows with clang-cl
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 28 Jun 2017 23:04:38 +0000 (23:04 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 28 Jun 2017 23:04:38 +0000 (23:04 +0000)
https://bugs.webkit.org/show_bug.cgi?id=173889

Patch by Stephan Szabo <stephan.szabo@am.sony.com> on 2017-06-28
Reviewed by Konstantin Tokarev.

* CMakeLists.txt:
* Source/cmake/OptionsCommon.cmake:
* Source/cmake/OptionsMSVC.cmake:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@218900 268f45cc-cd09-0410-ab3c-d52691b4dbfc

CMakeLists.txt
ChangeLog
Source/cmake/OptionsCommon.cmake
Source/cmake/OptionsMSVC.cmake

index 398f55f..49ae9fa 100644 (file)
@@ -50,6 +50,10 @@ if (CMAKE_COMPILER_IS_GNUCXX OR COMPILER_IS_CLANG)
     set(COMPILER_IS_GCC_OR_CLANG ON)
 endif ()
 
+if (MSVC AND COMPILER_IS_CLANG)
+    set(COMPILER_IS_CLANG_CL ON)
+endif ()
+
 # -----------------------------------------------------------------------------
 # Determine the target processor
 # -----------------------------------------------------------------------------
index e58d52f..6bfd230 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2017-06-28  Stephan Szabo  <stephan.szabo@am.sony.com>
+
+        [Win] Build JSCOnly on Windows with clang-cl
+        https://bugs.webkit.org/show_bug.cgi?id=173889
+
+        Reviewed by Konstantin Tokarev.
+
+        * CMakeLists.txt:
+        * Source/cmake/OptionsCommon.cmake:
+        * Source/cmake/OptionsMSVC.cmake:
+
 2017-06-23  Carlos Garcia Campos  <cgarcia@igalia.com>
 
         [WPE] User script messages don't work
index c0befa0..61a0ae7 100644 (file)
@@ -30,16 +30,6 @@ endif ()
 set_property(GLOBAL PROPERTY USE_FOLDERS ON)
 define_property(TARGET PROPERTY FOLDER INHERITED BRIEF_DOCS "folder" FULL_DOCS "IDE folder name")
 
-if (COMPILER_IS_GCC_OR_CLANG)
-    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-exceptions -fno-strict-aliasing")
-    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-exceptions -fno-strict-aliasing -fno-rtti")
-    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++1y")
-    if (NOT (COMPILER_IS_CLANG AND "${CLANG_VERSION}" VERSION_LESS 4.0.0))
-        set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-expansion-to-defined")
-        set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-expansion-to-defined")
-    endif ()
-endif ()
-
 if (CMAKE_GENERATOR STREQUAL "Ninja")
     if (COMPILER_IS_CLANG)
         set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fcolor-diagnostics")
@@ -54,9 +44,33 @@ if (CMAKE_GENERATOR STREQUAL "Ninja")
     endif ()
 endif ()
 
-if (WIN32 AND COMPILER_IS_GCC_OR_CLANG)
-    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mno-ms-bitfields -Wno-unknown-pragmas")
-    add_definitions(-D__USE_MINGW_ANSI_STDIO=1)
+if (COMPILER_IS_GCC_OR_CLANG)
+    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-strict-aliasing")
+    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-strict-aliasing")
+
+    if (COMPILER_IS_CLANG_CL)
+        # clang-cl.exe impersonates cl.exe so some clang arguments like -fno-rtti are
+        # represented using cl.exe's options and should not be passed as flags, so 
+        # we do not add -fno-rtti or -fno-exceptions for clang-cl
+
+        # FIXME: These warnings should be addressed
+        set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-undef -Wno-macro-redefined -Wno-unknown-pragmas -Wno-nonportable-include-path -Wno-unknown-argument")
+        set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-undef -Wno-macro-redefined -Wno-unknown-pragmas -Wno-nonportable-include-path -Wno-unknown-argument")
+    else ()
+        set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-exceptions")
+        set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++1y -fno-exceptions -fno-rtti")
+
+        if (WIN32)
+            set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mno-ms-bitfields -Wno-unknown-pragmas")
+            add_definitions(-D{CMAKE_CXX_FLAGS} -mno-ms-bitfields -Wno-unknown-pragmas)
+            add_definitions(-D__USE_MINGW_ANSI_STDIO=1)
+        endif ()
+    endif ()
+
+    if (NOT (COMPILER_IS_CLANG AND "${CLANG_VERSION}" VERSION_LESS 4.0.0))
+        set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-expansion-to-defined")
+        set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-expansion-to-defined")
+    endif ()
 endif ()
 
 # Ensure that the default include system directories are added to the list of CMake implicit includes.
index 8da0624..2bff8dc 100644 (file)
@@ -21,7 +21,10 @@ add_compile_options(/EHa- /EHc- /EHs- /fp:except-)
 add_compile_options(/analyze- /bigobj)
 
 # Use CRT security features
-add_definitions(-D_CRT_SECURE_NO_WARNINGS -D_CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES=1)
+add_definitions(-D_CRT_SECURE_NO_WARNINGS)
+if (NOT COMPILER_IS_CLANG_CL)
+    add_definitions(-D_CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES=1)
+endif ()
 
 # Turn off certain link features
 add_compile_options(/Gy- /openmp- /GF-)
@@ -82,3 +85,14 @@ string(REPLACE "INCREMENTAL:YES" "INCREMENTAL:NO" replace_CMAKE_SHARED_LINKER_FL
 set(CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO "${replace_CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO} /INCREMENTAL:NO")
 string(REPLACE "INCREMENTAL:YES" "INCREMENTAL:NO" replace_CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO ${CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO})
 set(CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO "${replace_CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO} /INCREMENTAL:NO")
+
+if (COMPILER_IS_CLANG_CL)
+    # FIXME: We need to set the msc-version above the one it defaults to
+    # when using clang-cl with VS2015. This might be unnecessary when moving to
+    # VS2017 as part of https://bugs.webkit.org/show_bug.cgi?id=172412
+    add_compile_options(-fmsc-version=190023918)
+
+    # FIXME: Building with clang-cl seemed to fail with 128 bit int support
+    set(HAVE_INT128_T OFF)
+    list(REMOVE_ITEM _WEBKIT_CONFIG_FILE_VARIABLES HAVE_INT128_T)
+endif ()