[CMake] Properly test if compiler supports compiler flags
authormcatanzaro@igalia.com <mcatanzaro@igalia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 8 Aug 2017 15:03:48 +0000 (15:03 +0000)
committermcatanzaro@igalia.com <mcatanzaro@igalia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 8 Aug 2017 15:03:48 +0000 (15:03 +0000)
https://bugs.webkit.org/show_bug.cgi?id=174490

Reviewed by Konstantin Tokarev.

.:

This turned out to be a massive pain. I didn't want to merely check options before using
them: I also wanted to organize the code to avoid setting similar flags in different places.
Right now we set a bunch of global flags in OptionsCommon.cmake, and a bunch more flags in
WEBKIT_SET_EXTRA_COMPILER_FLAGS on a per-target basis.

Setting flags per-target seems better in general, e.g. because it makes it very easy to
disable warnings for particular ThirdParty targets. But it turns out that all the flags set
on a per-target basis get passed to both the C compiler and the C++ compiler, so it's
impossible to pass C++-only flags there. That's terrible. It's possible to make the flags
language-conditional using generator expressions, but that doesn't work for the Visual
Studio backend, so we would have to drop support for that (not going to happen). The CMake
documentation suggests that C and C++ files ought to be built in separate targets to avoid
this. It's a mess, basically.

So I've wound up removing WEBKIT_SET_EXTRA_COMPILER_FLAGS and adding most of those flags to
CMAKE_C_FLAGS and CMAKE_CXX_FLAGS instead. Really the only disadvantage of this is we now
have to suppress individual warnings when building ANGLESupport in WebCore. That's not the
end of the world. The only remaining useful feature of WEBKIT_SET_EXTRA_COMPILER_FLAGS was
to add -fPIC to static library targets, but turns out CMake does that for us if we just set
the variable CMAKE_POSITION_INDEPENDENT_CODE, so we can get rid of it completely.

Of course there are also macros for setting target-specific compiler flags, which we
frequently need in order to suppress specific warnings, particularly warnings coming from
third-party libraries like ANGLE and gtest. But remember the footgun: these macros will test
the flag against only one compiler, but must work with both C and C++ compilers unless the
build target exclusively contains targets built with just one of those compilers. Yuck.

* CMakeLists.txt:
* Source/CMakeLists.txt:
* Source/PlatformGTK.cmake:
* Source/cmake/OptionsCommon.cmake:
* Source/cmake/WebKitCommon.cmake:
* Source/cmake/WebKitCompilerFlags.cmake: Added.
* Source/cmake/WebKitMacros.cmake:

Source/JavaScriptCore:

* API/tests/PingPongStackOverflowTest.cpp:
(testPingPongStackOverflow):
* API/tests/testapi.c:
* b3/testb3.cpp:
(JSC::B3::testPatchpointLotsOfLateAnys):

Source/ThirdParty:

* brotli/CMakeLists.txt:
* gtest/CMakeLists.txt:
* woff2/CMakeLists.txt:
* xdgmime/CMakeLists.txt:

Source/WebCore:

* CMakeLists.txt:
* PlatformGTK.cmake:
* PlatformWPE.cmake:

Source/WebDriver:

* WebDriverService.cpp:
(WebDriver::WebDriverService::run):
* glib/SessionHostGlib.cpp:

Source/WebKit:

* CMakeLists.txt:
* PlatformGTK.cmake:

Source/WTF:

* wtf/Compiler.h:

Tools:

* DumpRenderTree/TestNetscapePlugIn/CMakeLists.txt:
* MiniBrowser/gtk/CMakeLists.txt:
* TestRunnerShared/Bindings/JSWrapper.cpp:
(WTR::JSWrapper::initialize):
* TestWebKitAPI/CMakeLists.txt:
* TestWebKitAPI/PlatformGTK.cmake:
* TestWebKitAPI/Tests/WTF/CheckedArithmeticOperations.cpp:
(TestWebKitAPI::CheckedArithmeticTester::run):
* TestWebKitAPI/Tests/WebKitGLib/TestAutomationSession.cpp:
* TestWebKitAPI/Tests/WebKitGLib/TestWebExtensions.cpp:
* TestWebKitAPI/Tests/WebKitGLib/WebExtensionTest.cpp:
(formControlsAssociatedCallback):
* TestWebKitAPI/glib/CMakeLists.txt:
* TestWebKitAPI/glib/WebKitGLib/TestMain.h:
(Test::getResourcesDir):
* WebKitTestRunner/CMakeLists.txt:
* WebKitTestRunner/InjectedBundle/EventSendingController.cpp:
(WTR::menuItemClickCallback):
(WTR::staticConvertMenuItemToType):
* WebKitTestRunner/InjectedBundle/TestRunner.cpp:
(WTR::TestRunner::setUseDashboardCompatibilityMode):
* WebKitTestRunner/InjectedBundle/atk/AccessibilityNotificationHandlerAtk.cpp:
(WTR::AccessibilityNotificationHandler::disconnectAccessibilityCallbacks):
* WebKitTestRunner/InjectedBundle/atk/AccessibilityUIElementAtk.cpp:
(WTR::AccessibilityUIElement::helpText const):
(WTR::AccessibilityUIElement::attributedStringForRange):
* WebKitTestRunner/gtk/EventSenderProxyGtk.cpp:
(WTR::EventSenderProxy::updateTouchPoint):
(WTR::EventSenderProxy::releaseTouchPoint):

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

47 files changed:
CMakeLists.txt
ChangeLog
Source/CMakeLists.txt
Source/JavaScriptCore/API/tests/PingPongStackOverflowTest.cpp
Source/JavaScriptCore/API/tests/testapi.c
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/b3/testb3.cpp
Source/PlatformGTK.cmake
Source/ThirdParty/ChangeLog
Source/ThirdParty/brotli/CMakeLists.txt
Source/ThirdParty/gtest/CMakeLists.txt
Source/ThirdParty/woff2/CMakeLists.txt
Source/ThirdParty/xdgmime/CMakeLists.txt
Source/WTF/ChangeLog
Source/WTF/wtf/Compiler.h
Source/WebCore/CMakeLists.txt
Source/WebCore/ChangeLog
Source/WebCore/PlatformGTK.cmake
Source/WebCore/PlatformWPE.cmake
Source/WebDriver/ChangeLog
Source/WebDriver/WebDriverService.cpp
Source/WebDriver/glib/SessionHostGlib.cpp
Source/WebKit/CMakeLists.txt
Source/WebKit/ChangeLog
Source/WebKit/PlatformGTK.cmake
Source/cmake/OptionsCommon.cmake
Source/cmake/WebKitCommon.cmake
Source/cmake/WebKitCompilerFlags.cmake [new file with mode: 0644]
Source/cmake/WebKitMacros.cmake
Tools/ChangeLog
Tools/DumpRenderTree/TestNetscapePlugIn/CMakeLists.txt
Tools/MiniBrowser/gtk/CMakeLists.txt
Tools/TestRunnerShared/Bindings/JSWrapper.cpp
Tools/TestWebKitAPI/CMakeLists.txt
Tools/TestWebKitAPI/PlatformGTK.cmake
Tools/TestWebKitAPI/Tests/WTF/CheckedArithmeticOperations.cpp
Tools/TestWebKitAPI/Tests/WebKitGLib/TestAutomationSession.cpp
Tools/TestWebKitAPI/Tests/WebKitGLib/TestWebExtensions.cpp
Tools/TestWebKitAPI/Tests/WebKitGLib/WebExtensionTest.cpp
Tools/TestWebKitAPI/glib/CMakeLists.txt
Tools/TestWebKitAPI/glib/WebKitGLib/TestMain.h
Tools/WebKitTestRunner/CMakeLists.txt
Tools/WebKitTestRunner/InjectedBundle/EventSendingController.cpp
Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp
Tools/WebKitTestRunner/InjectedBundle/atk/AccessibilityNotificationHandlerAtk.cpp
Tools/WebKitTestRunner/InjectedBundle/atk/AccessibilityUIElementAtk.cpp
Tools/WebKitTestRunner/gtk/EventSenderProxyGtk.cpp

index f560345..1dbd16e 100644 (file)
@@ -126,6 +126,8 @@ set(WebKit_LIBRARY_TYPE SHARED)
 set(WebKit2_LIBRARY_TYPE SHARED)
 set(WebCoreTestSupport_LIBRARY_TYPE STATIC)
 
+set(CMAKE_POSITION_INDEPENDENT_CODE True)
+
 # -----------------------------------------------------------------------------
 # Install JavaScript shell
 # -----------------------------------------------------------------------------
index 37d45f7..0f191ab 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,45 @@
+2017-08-08  Michael Catanzaro  <mcatanzaro@igalia.com>
+
+        [CMake] Properly test if compiler supports compiler flags
+        https://bugs.webkit.org/show_bug.cgi?id=174490
+
+        Reviewed by Konstantin Tokarev.
+
+        This turned out to be a massive pain. I didn't want to merely check options before using
+        them: I also wanted to organize the code to avoid setting similar flags in different places.
+        Right now we set a bunch of global flags in OptionsCommon.cmake, and a bunch more flags in
+        WEBKIT_SET_EXTRA_COMPILER_FLAGS on a per-target basis.
+
+        Setting flags per-target seems better in general, e.g. because it makes it very easy to
+        disable warnings for particular ThirdParty targets. But it turns out that all the flags set
+        on a per-target basis get passed to both the C compiler and the C++ compiler, so it's
+        impossible to pass C++-only flags there. That's terrible. It's possible to make the flags
+        language-conditional using generator expressions, but that doesn't work for the Visual
+        Studio backend, so we would have to drop support for that (not going to happen). The CMake
+        documentation suggests that C and C++ files ought to be built in separate targets to avoid
+        this. It's a mess, basically.
+
+        So I've wound up removing WEBKIT_SET_EXTRA_COMPILER_FLAGS and adding most of those flags to
+        CMAKE_C_FLAGS and CMAKE_CXX_FLAGS instead. Really the only disadvantage of this is we now
+        have to suppress individual warnings when building ANGLESupport in WebCore. That's not the
+        end of the world. The only remaining useful feature of WEBKIT_SET_EXTRA_COMPILER_FLAGS was
+        to add -fPIC to static library targets, but turns out CMake does that for us if we just set
+        the variable CMAKE_POSITION_INDEPENDENT_CODE, so we can get rid of it completely.
+
+        Of course there are also macros for setting target-specific compiler flags, which we
+        frequently need in order to suppress specific warnings, particularly warnings coming from
+        third-party libraries like ANGLE and gtest. But remember the footgun: these macros will test
+        the flag against only one compiler, but must work with both C and C++ compilers unless the
+        build target exclusively contains targets built with just one of those compilers. Yuck.
+
+        * CMakeLists.txt:
+        * Source/CMakeLists.txt:
+        * Source/PlatformGTK.cmake:
+        * Source/cmake/OptionsCommon.cmake:
+        * Source/cmake/WebKitCommon.cmake:
+        * Source/cmake/WebKitCompilerFlags.cmake: Added.
+        * Source/cmake/WebKitMacros.cmake:
+
 2017-08-07  Brian Burg  <bburg@apple.com>
 
         Remove CANVAS_PATH compilation guard
index 0b38c50..31fcd89 100644 (file)
@@ -43,29 +43,3 @@ if (ENABLE_WEBDRIVER)
 endif ()
 
 WEBKIT_INCLUDE_CONFIG_FILES_IF_EXISTS()
-
-# -----------------------------------------------------------------------------
-# Set compiler flags for all targets
-# -----------------------------------------------------------------------------
-if (NOT USE_SYSTEM_MALLOC)
-    WEBKIT_SET_EXTRA_COMPILER_FLAGS(bmalloc ${ADDITIONAL_COMPILER_FLAGS})
-endif ()
-WEBKIT_SET_EXTRA_COMPILER_FLAGS(WTF ${ADDITIONAL_COMPILER_FLAGS})
-WEBKIT_SET_EXTRA_COMPILER_FLAGS(JavaScriptCore ${ADDITIONAL_COMPILER_FLAGS})
-
-if (ENABLE_WEBCORE)
-    WEBKIT_SET_EXTRA_COMPILER_FLAGS(PAL ${ADDITIONAL_COMPILER_FLAGS})
-    WEBKIT_SET_EXTRA_COMPILER_FLAGS(WebCoreTestSupport ${ADDITIONAL_COMPILER_FLAGS})
-    WEBKIT_SET_EXTRA_COMPILER_FLAGS(WebCore ${ADDITIONAL_COMPILER_FLAGS})
-    WEBKIT_SET_EXTRA_COMPILER_FLAGS(WebCoreDerivedSources ${ADDITIONAL_COMPILER_FLAGS})
-endif ()
-
-if (ENABLE_WEBKIT_LEGACY)
-    # FIXME: Rename this target to WebKitLegacy.
-    WEBKIT_SET_EXTRA_COMPILER_FLAGS(WebKit ${ADDITIONAL_COMPILER_FLAGS})
-endif ()
-
-if (ENABLE_WEBKIT)
-    # FIXME: Rename this target to WebKit.
-    WEBKIT_SET_EXTRA_COMPILER_FLAGS(WebKit2 ${ADDITIONAL_COMPILER_FLAGS})
-endif ()
index 235dcee..042bebf 100644 (file)
@@ -142,7 +142,6 @@ int testPingPongStackOverflow()
         "PingPongStackOverflowObject.__proto__ = undefined;" \
         "undefined instanceof PingPongStackOverflowObject;";
 
-    JSValueRef scriptResult = nullptr;
     JSValueRef exception = nullptr;
     JSStringRef script = JSStringCreateWithUTF8CString(scriptString);
 
@@ -161,7 +160,7 @@ int testPingPongStackOverflow()
     Options::maxPerThreadStackUsage() = stackSize + Options::softReservedZoneSize();
 
     exception = nullptr;
-    scriptResult = JSEvaluateScript(context, script, nullptr, nullptr, 1, &exception);
+    JSEvaluateScript(context, script, nullptr, nullptr, 1, &exception);
 
     if (!exception) {
         printf("FAIL: PingPongStackOverflowError not thrown in PingPongStackOverflow test\n");
index f12cc2e..92c22c5 100644 (file)
@@ -1134,6 +1134,10 @@ static bool globalContextNameTest()
     return result;
 }
 
+#if COMPILER(GCC)
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wunused-but-set-variable"
+#endif
 static void checkConstnessInJSObjectNames()
 {
     JSStaticFunction fun;
@@ -1141,6 +1145,9 @@ static void checkConstnessInJSObjectNames()
     JSStaticValue val;
     val.name = "something";
 }
+#if COMPILER(GCC)
+#pragma GCC diagnostic pop
+#endif
 
 #ifdef __cplusplus
 extern "C" {
index 45570b4..630e78e 100644 (file)
@@ -1,3 +1,16 @@
+2017-08-08  Michael Catanzaro  <mcatanzaro@igalia.com>
+
+        [CMake] Properly test if compiler supports compiler flags
+        https://bugs.webkit.org/show_bug.cgi?id=174490
+
+        Reviewed by Konstantin Tokarev.
+
+        * API/tests/PingPongStackOverflowTest.cpp:
+        (testPingPongStackOverflow):
+        * API/tests/testapi.c:
+        * b3/testb3.cpp:
+        (JSC::B3::testPatchpointLotsOfLateAnys):
+
 2017-08-06  Yusuke Suzuki  <utatane.tea@gmail.com>
 
         [Linux] Clear WasmMemory with madvice instead of memset
index be88253..d53b0d4 100644 (file)
@@ -8481,7 +8481,7 @@ void testPatchpointLotsOfLateAnys()
         });
     root->appendNewControlValue(proc, Return, Origin(), patchpoint);
 
-    CHECK(compileAndRun<int>(proc) == (things.size() * (things.size() - 1)) / 2);
+    CHECK(static_cast<size_t>(compileAndRun<int>(proc)) == (things.size() * (things.size() - 1)) / 2);
 }
 
 void testPatchpointAnyImm(ValueRep rep)
index 7275860..50b5393 100644 (file)
@@ -24,9 +24,10 @@ macro(ADD_GTKDOC_GENERATOR _stamp_name _extra_args)
     add_custom_command(
         OUTPUT "${CMAKE_BINARY_DIR}/${_stamp_name}"
         DEPENDS ${DocumentationDependencies}
-        COMMAND CC=${CMAKE_C_COMPILER} CFLAGS=${CMAKE_C_FLAGS} ${CMAKE_SOURCE_DIR}/Tools/gtk/generate-gtkdoc ${_extra_args}
+        COMMAND ${CMAKE_COMMAND} -E env "CC=${CMAKE_C_COMPILER}" "CFLAGS=${CMAKE_C_FLAGS} -Wno-unused-parameter" ${CMAKE_SOURCE_DIR}/Tools/gtk/generate-gtkdoc ${_extra_args}
         COMMAND touch ${_stamp_name}
         WORKING_DIRECTORY "${CMAKE_BINARY_DIR}"
+        VERBATIM
     )
 endmacro()
 
index 689976e..ed5fa58 100644 (file)
@@ -1,3 +1,15 @@
+2017-08-08  Michael Catanzaro  <mcatanzaro@igalia.com>
+
+        [CMake] Properly test if compiler supports compiler flags
+        https://bugs.webkit.org/show_bug.cgi?id=174490
+
+        Reviewed by Konstantin Tokarev.
+
+        * brotli/CMakeLists.txt:
+        * gtest/CMakeLists.txt:
+        * woff2/CMakeLists.txt:
+        * xdgmime/CMakeLists.txt:
+
 2017-07-17  Michael Catanzaro  <mcatanzaro@igalia.com>
 
         [CMake] Macros in WebKitMacros.cmake should be prefixed with WEBKIT_ namespace
index 7bfbe68..3612308 100644 (file)
@@ -15,8 +15,8 @@ set(BROTLI_SOURCES
 include_directories("${BROTLI_INCLUDE_DIRECTORIES}")
 add_definitions(-DBROTLI_BUILD_PORTABLE)
 add_library(brotli STATIC ${BROTLI_SOURCES})
-WEBKIT_SET_EXTRA_COMPILER_FLAGS(brotli)
 
 if (COMPILER_IS_GCC_OR_CLANG)
-    WEBKIT_ADD_TARGET_PROPERTIES(brotli COMPILE_FLAGS "-Wno-cast-align -Wno-implicit-fallthrough")
+    WEBKIT_ADD_TARGET_C_FLAGS(brotli -Wno-cast-align
+                                     -Wno-implicit-fallthrough)
 endif ()
index 451c58d..e921f95 100755 (executable)
@@ -35,6 +35,9 @@ endif ()
 include_directories(${GTEST_INCLUDE_DIRECTORIES})
 add_definitions(-DGTEST_HAS_RTTI=0)
 
+WEBKIT_ADD_TARGET_CXX_FLAGS(gtest -Wno-undef
+                                  -Wno-suggest-attribute=format)
+
 # FIXME: This works around compatibility problems in the old version of the third-pary
 # googletest source code checkout. It should be removed once we upgrade to a newer version.
 if (COMPILER_IS_CLANG)
index 12c414f..57ac462 100644 (file)
@@ -16,12 +16,12 @@ include_directories("${THIRDPARTY_DIR}/brotli/dec")
 include_directories("${WOFF2_INCLUDE_DIRECTORIES}")
 add_library(woff2 STATIC ${WOFF2_SOURCES})
 target_link_libraries(woff2 brotli)
-WEBKIT_SET_EXTRA_COMPILER_FLAGS(woff2)
 
 if (COMPILER_IS_GCC_OR_CLANG)
-    WEBKIT_ADD_TARGET_PROPERTIES(woff2 COMPILE_FLAGS "-Wno-sign-compare -Wno-unused-variable -Wno-unused-parameter")
-endif ()
-
-if (CMAKE_COMPILER_IS_GNUCXX)
-    WEBKIT_ADD_TARGET_PROPERTIES(woff2 COMPILE_FLAGS "-Wno-unused-but-set-variable")
+    WEBKIT_ADD_TARGET_CXX_FLAGS(woff2 -Wno-cast-align
+                                      -Wno-implicit-fallthrough
+                                      -Wno-sign-compare
+                                      -Wno-unused-variable
+                                      -Wno-unused-parameter
+                                      -Wno-unused-but-set-variable)
 endif ()
index fea3d29..73fee94 100644 (file)
@@ -19,8 +19,8 @@ set(XDGMIME_SOURCES
 include_directories("${XDGMIME_INCLUDE_DIRECTORIES}")
 add_definitions(-DXDG_PREFIX=_wk_xdg)
 add_library(xdgmime STATIC ${XDGMIME_SOURCES})
-WEBKIT_SET_EXTRA_COMPILER_FLAGS(xdgmime)
 
 if (COMPILER_IS_GCC_OR_CLANG)
-    WEBKIT_ADD_TARGET_PROPERTIES(xdgmime COMPILE_FLAGS "-Wno-sign-compare -Wno-unused-parameter")
+    WEBKIT_ADD_TARGET_C_FLAGS(xdgmime -Wno-sign-compare
+                                      -Wno-unused-parameter)
 endif ()
index 3287e79..7fbcd3e 100644 (file)
@@ -1,3 +1,12 @@
+2017-08-08  Michael Catanzaro  <mcatanzaro@igalia.com>
+
+        [CMake] Properly test if compiler supports compiler flags
+        https://bugs.webkit.org/show_bug.cgi?id=174490
+
+        Reviewed by Konstantin Tokarev.
+
+        * wtf/Compiler.h:
+
 2017-08-07  Filip Pizlo  <fpizlo@apple.com>
 
         Baseline JIT should do caging
index f2fed79..86eb14a 100644 (file)
 #define WTF_COMPILER_SUPPORTS_C_STATIC_ASSERT 1
 #endif
 
-#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
-
 #endif /* COMPILER(GCC) */
 
 /* COMPILER(MINGW) - MinGW GCC */
index 1377602..0fe2f6f 100644 (file)
@@ -4020,7 +4020,7 @@ endif ()
 # See https://bugs.webkit.org/show_bug.cgi?id=146440
 string(TOLOWER ${CMAKE_HOST_SYSTEM_PROCESSOR} LOWERCASE_CMAKE_HOST_SYSTEM_PROCESSOR)
 if (CMAKE_COMPILER_IS_GNUCXX AND "${LOWERCASE_CMAKE_HOST_SYSTEM_PROCESSOR}" MATCHES "(i[3-6]86|x86)$")
-    WEBKIT_ADD_TARGET_PROPERTIES(WebCore COMPILE_FLAGS "-fno-tree-sra")
+    WEBKIT_ADD_TARGET_CXX_FLAGS(WebCore -fno-tree-sra)
 endif ()
 
 if (MSVC)
@@ -4042,11 +4042,6 @@ endif ()
 if (ENABLE_GRAPHICS_CONTEXT_3D AND NOT WIN32)
     add_library(ANGLESupport STATIC ${ANGLESupport_SOURCES})
 
-    # Suppress null conversion warnings for sources in Source/ThirdParty/ANGLE
-    if (COMPILER_IS_CLANG)
-        WEBKIT_ADD_TARGET_PROPERTIES(ANGLESupport COMPILE_FLAGS "-Wno-null-conversion")
-    endif ()
-
     # Enable the ESSL and GLSL translators.
     set_property(TARGET ANGLESupport
         PROPERTY COMPILE_DEFINITIONS
@@ -4062,7 +4057,14 @@ if (ENABLE_GRAPHICS_CONTEXT_3D AND NOT WIN32)
         "${THIRDPARTY_DIR}/ANGLE/src/common/third_party/numerics"
     )
     list(APPEND WebCore_LIBRARIES ANGLESupport)
-    WEBKIT_SET_EXTRA_COMPILER_FLAGS(ANGLESupport IGNORECXX_WARNINGS)
+
+    if (COMPILER_IS_GCC_OR_CLANG)
+        WEBKIT_ADD_TARGET_CXX_FLAGS(ANGLESupport -Wno-implicit-fallthrough
+                                                 -Wno-null-conversion
+                                                 -Wno-suggest-attribute=format
+                                                 -Wno-unused-function
+                                                 -Wno-unused-parameter)
+    endif ()
 endif ()
 
 target_link_libraries(WebCore ${WebCore_LIBRARIES})
index e5704ba..a1ef4f8 100644 (file)
@@ -1,3 +1,14 @@
+2017-08-08  Michael Catanzaro  <mcatanzaro@igalia.com>
+
+        [CMake] Properly test if compiler supports compiler flags
+        https://bugs.webkit.org/show_bug.cgi?id=174490
+
+        Reviewed by Konstantin Tokarev.
+
+        * CMakeLists.txt:
+        * PlatformGTK.cmake:
+        * PlatformWPE.cmake:
+
 2017-08-08  Zan Dobersek  <zdobersek@igalia.com>
 
         [GStreamer] Don't use GraphicsContext3D in VideoTextureCoperGStreamer
index c1ffc94..1dcebc8 100644 (file)
@@ -272,7 +272,6 @@ if (ENABLE_PLUGIN_PROCESS_GTK2)
     # for the plugin process.
     add_library(WebCorePlatformGTK2 ${WebCore_LIBRARY_TYPE} ${WebCorePlatformGTK_SOURCES})
     add_dependencies(WebCorePlatformGTK2 WebCore)
-    WEBKIT_SET_EXTRA_COMPILER_FLAGS(WebCorePlatformGTK2)
     set_property(TARGET WebCorePlatformGTK2
         APPEND
         PROPERTY COMPILE_DEFINITIONS GTK_API_VERSION_2=1
@@ -303,7 +302,6 @@ endif ()
 
 add_library(WebCorePlatformGTK ${WebCore_LIBRARY_TYPE} ${WebCorePlatformGTK_SOURCES})
 add_dependencies(WebCorePlatformGTK WebCore)
-WEBKIT_SET_EXTRA_COMPILER_FLAGS(WebCorePlatformGTK)
 target_include_directories(WebCorePlatformGTK PRIVATE
     ${WebCore_INCLUDE_DIRECTORIES}
 )
index de4a63d..9293232 100644 (file)
@@ -193,7 +193,6 @@ list(APPEND WebCore_INCLUDE_DIRECTORIES
 
 add_library(WebCorePlatformWPE ${WebCore_LIBRARY_TYPE} ${WebCorePlatformWPE_SOURCES})
 add_dependencies(WebCorePlatformWPE WebCore)
-WEBKIT_SET_EXTRA_COMPILER_FLAGS(WebCorePlatformWPE)
 target_include_directories(WebCorePlatformWPE PRIVATE
     ${WebCore_INCLUDE_DIRECTORIES}
 )
index e8fc347..e3be42c 100644 (file)
@@ -1,3 +1,14 @@
+2017-08-08  Michael Catanzaro  <mcatanzaro@igalia.com>
+
+        [CMake] Properly test if compiler supports compiler flags
+        https://bugs.webkit.org/show_bug.cgi?id=174490
+
+        Reviewed by Konstantin Tokarev.
+
+        * WebDriverService.cpp:
+        (WebDriver::WebDriverService::run):
+        * glib/SessionHostGlib.cpp:
+
 2017-08-07  Carlos Garcia Campos  <cgarcia@igalia.com>
 
         Web Automation: setUserInputForCurrentJavaScriptPrompt should fail if current dialog is not a prompt
index 2242bb9..58cddd7 100644 (file)
@@ -53,7 +53,7 @@ static void printUsageStatement(const char* programName)
 int WebDriverService::run(int argc, char** argv)
 {
     String portString;
-    for (unsigned i = 1 ; i < argc; ++i) {
+    for (int i = 1 ; i < argc; ++i) {
         const char* arg = argv[i];
         if (!strcmp(arg, "-h") || !strcmp(arg, "--help")) {
             printUsageStatement(argv[0]);
index c70d390..e5b98f1 100644 (file)
@@ -62,7 +62,7 @@ static const char introspectionXML[] =
 
 const GDBusInterfaceVTable SessionHost::s_interfaceVTable = {
     // method_call
-    [](GDBusConnection* connection, const gchar* sender, const gchar* objectPath, const gchar* interfaceName, const gchar* methodName, GVariant* parameters, GDBusMethodInvocation* invocation, gpointer userData) {
+    [](GDBusConnection*, const gchar*, const gchar*, const gchar*, const gchar* methodName, GVariant* parameters, GDBusMethodInvocation* invocation, gpointer userData) {
         auto* sessionHost = static_cast<SessionHost*>(userData);
         if (!g_strcmp0(methodName, "SetTargetList")) {
             guint64 connectionID;
@@ -94,6 +94,8 @@ const GDBusInterfaceVTable SessionHost::s_interfaceVTable = {
     nullptr,
     // set_property
     nullptr,
+    // padding
+    nullptr
 };
 
 void SessionHost::connectToBrowser(Function<void (Succeeded)>&& completionHandler)
index 64b5abf..4bb1205 100644 (file)
@@ -880,11 +880,6 @@ if (COMPILER_IS_GCC_OR_CLANG AND NOT APPLE)
     target_link_libraries(WebKit2 -Wl,--start-group WebCore WebCoreDerivedSources -Wl,--end-group)
 endif ()
 
-# Suppress unused parameter warnings for sources in WebKit2.
-if (COMPILER_IS_GCC_OR_CLANG)
-    WEBKIT_ADD_TARGET_PROPERTIES(WebKit2 COMPILE_FLAGS "-Wno-unused-parameter")
-endif ()
-
 if (WebKit2_VERSION_SCRIPT)
     WEBKIT_ADD_TARGET_PROPERTIES(WebKit2 LINK_FLAGS "${WebKit2_VERSION_SCRIPT}")
 endif ()
@@ -911,11 +906,22 @@ if (NOT "${PORT}" STREQUAL "Mac")
     target_link_libraries(StorageProcess ${StorageProcess_LIBRARIES})
     install(TARGETS StorageProcess DESTINATION "${LIBEXEC_INSTALL_DIR}")
 
+    if (COMPILER_IS_GCC_OR_CLANG)
+        WEBKIT_ADD_TARGET_CXX_FLAGS(StorageProcess -Wno-unused-parameter)
+    endif ()
+
     if (WebKit2_StorageProcess_OUTPUT_NAME)
         set_target_properties(StorageProcess PROPERTIES OUTPUT_NAME ${WebKit2_StorageProcess_OUTPUT_NAME})
     endif ()
 endif ()
 
+# Suppress unused parameter warnings for sources in WebKit2.
+if (COMPILER_IS_GCC_OR_CLANG)
+    WEBKIT_ADD_TARGET_CXX_FLAGS(WebKit2 -Wno-unused-parameter)
+    WEBKIT_ADD_TARGET_CXX_FLAGS(WebProcess -Wno-unused-parameter)
+    WEBKIT_ADD_TARGET_CXX_FLAGS(NetworkProcess -Wno-unused-parameter)
+endif ()
+
 if (ENABLE_PLUGIN_PROCESS AND NOT "${PORT}" STREQUAL "Mac")
     add_definitions(-DENABLE_PLUGIN_PROCESS=1)
     add_executable(PluginProcess ${PluginProcess_SOURCES})
@@ -923,6 +929,10 @@ if (ENABLE_PLUGIN_PROCESS AND NOT "${PORT}" STREQUAL "Mac")
     target_link_libraries(PluginProcess ${PluginProcess_LIBRARIES})
     install(TARGETS PluginProcess DESTINATION "${LIBEXEC_INSTALL_DIR}")
 
+    if (COMPILER_IS_GCC_OR_CLANG)
+        WEBKIT_ADD_TARGET_CXX_FLAGS(PluginProcess -Wno-unused-parameter)
+    endif ()
+
     if (WebKit2_PluginProcess_OUTPUT_NAME)
       set_target_properties(PluginProcess PROPERTIES OUTPUT_NAME ${WebKit2_PluginProcess_OUTPUT_NAME})
     endif ()
index fa6cc89..0ea7bac 100644 (file)
@@ -1,3 +1,13 @@
+2017-08-08  Michael Catanzaro  <mcatanzaro@igalia.com>
+
+        [CMake] Properly test if compiler supports compiler flags
+        https://bugs.webkit.org/show_bug.cgi?id=174490
+
+        Reviewed by Konstantin Tokarev.
+
+        * CMakeLists.txt:
+        * PlatformGTK.cmake:
+
 2017-08-07  Carlos Garcia Campos  <cgarcia@igalia.com>
 
         Web Automation: setUserInputForCurrentJavaScriptPrompt should fail if current dialog is not a prompt
index 2594988..3dcbaa1 100644 (file)
@@ -1066,6 +1066,10 @@ if (ENABLE_PLUGIN_PROCESS_GTK2)
     add_dependencies(WebKitPluginProcess2 WebKit2)
 
     install(TARGETS WebKitPluginProcess2 DESTINATION "${LIBEXEC_INSTALL_DIR}")
+
+    if (COMPILER_IS_GCC_OR_CLANG)
+        WEBKIT_ADD_TARGET_CXX_FLAGS(WebKitPluginProcess2 -Wno-unused-parameter)
+    endif ()
 endif () # ENABLE_PLUGIN_PROCESS_GTK2
 
 # GTK3 PluginProcess
@@ -1090,6 +1094,10 @@ add_library(webkit2gtkinjectedbundle MODULE "${WEBKIT2_DIR}/WebProcess/InjectedB
 add_webkit2_prefix_header(webkit2gtkinjectedbundle)
 target_link_libraries(webkit2gtkinjectedbundle WebKit2)
 
+if (COMPILER_IS_GCC_OR_CLANG)
+    WEBKIT_ADD_TARGET_CXX_FLAGS(webkit2gtkinjectedbundle -Wno-unused-parameter)
+endif ()
+
 # Add ${CMAKE_LIBRARY_OUTPUT_DIRECTORY} to LD_LIBRARY_PATH or DYLD_LIBRARY_PATH
 if (APPLE)
     set(LOADER_LIBRARY_PATH_VAR "DYLD_LIBRARY_PATH")
index 6108b9b..158acbd 100644 (file)
@@ -1,21 +1,6 @@
 add_definitions(-DBUILDING_WITH_CMAKE=1)
 add_definitions(-DHAVE_CONFIG_H=1)
 
-# CODE_GENERATOR_PREPROCESSOR_WITH_LINEMARKERS only matters with GCC >= 4.7.0.  Since this
-# version, -P does not output empty lines, which currently breaks make_names.pl in
-# WebCore. Investigating whether make_names.pl should be changed instead is left as an exercise to
-# the reader.
-if (MSVC)
-    set(CODE_GENERATOR_PREPROCESSOR_ARGUMENTS "/nologo /EP /TP")
-    set(CODE_GENERATOR_PREPROCESSOR_WITH_LINEMARKERS_ARGUMENTS ${CODE_GENERATOR_PREPROCESSOR_ARGUMENTS})
-else ()
-    set(CODE_GENERATOR_PREPROCESSOR_ARGUMENTS "-E -P -x c++")
-    set(CODE_GENERATOR_PREPROCESSOR_WITH_LINEMARKERS_ARGUMENTS "-E -x c++")
-endif ()
-
-set(CODE_GENERATOR_PREPROCESSOR "\"${CMAKE_CXX_COMPILER}\" ${CODE_GENERATOR_PREPROCESSOR_ARGUMENTS}")
-set(CODE_GENERATOR_PREPROCESSOR_WITH_LINEMARKERS "\"${CMAKE_CXX_COMPILER}\" ${CODE_GENERATOR_PREPROCESSOR_WITH_LINEMARKERS_ARGUMENTS}")
-
 option(USE_THIN_ARCHIVES "Produce all static libraries as thin archives" ON)
 if (USE_THIN_ARCHIVES)
     execute_process(COMMAND ${CMAKE_AR} -V OUTPUT_VARIABLE AR_VERSION)
@@ -30,82 +15,6 @@ endif ()
 set_property(GLOBAL PROPERTY USE_FOLDERS ON)
 define_property(TARGET PROPERTY FOLDER INHERITED BRIEF_DOCS "folder" FULL_DOCS "IDE folder name")
 
-if (CMAKE_GENERATOR STREQUAL "Ninja")
-    if (COMPILER_IS_CLANG)
-        set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fcolor-diagnostics")
-        set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fcolor-diagnostics")
-    else ()
-        if (CMAKE_COMPILER_IS_GNUCC)
-            set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fdiagnostics-color=always")
-        endif ()
-        if (CMAKE_COMPILER_IS_GNUCXX)
-            set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fdiagnostics-color=always")
-        endif ()
-    endif ()
-endif ()
-
-# FIXME: Some warning flags should probably be set in WEBKIT_SET_EXTRA_COMPILER_FLAGS instead.
-# But language-specific warnings probably cannot be moved there.
-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 ()
-
-    if (CMAKE_COMPILER_IS_GNUCXX AND ${CMAKE_CXX_COMPILER_VERSION} VERSION_GREATER "7.0")
-        set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-noexcept-type")
-    endif ()
-endif ()
-
-# Ensure that the default include system directories are added to the list of CMake implicit includes.
-# This workarounds an issue that happens when using GCC 6 and using system includes (-isystem).
-# For more details check: https://bugs.webkit.org/show_bug.cgi?id=161697
-macro(DETERMINE_GCC_SYSTEM_INCLUDE_DIRS _lang _compiler _flags _result)
-    file(WRITE "${CMAKE_BINARY_DIR}/CMakeFiles/dummy" "\n")
-    separate_arguments(_buildFlags UNIX_COMMAND "${_flags}")
-    execute_process(COMMAND ${_compiler} ${_buildFlags} -v -E -x ${_lang} -dD dummy
-                    WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/CMakeFiles OUTPUT_QUIET
-                    ERROR_VARIABLE _gccOutput)
-    file(REMOVE "${CMAKE_BINARY_DIR}/CMakeFiles/dummy")
-    if ("${_gccOutput}" MATCHES "> search starts here[^\n]+\n *(.+) *\n *End of (search) list")
-        set(${_result} ${CMAKE_MATCH_1})
-        string(REPLACE "\n" " " ${_result} "${${_result}}")
-        separate_arguments(${_result})
-    endif ()
-endmacro()
-
-if (CMAKE_COMPILER_IS_GNUCC)
-   DETERMINE_GCC_SYSTEM_INCLUDE_DIRS("c" "${CMAKE_C_COMPILER}" "${CMAKE_C_FLAGS}" SYSTEM_INCLUDE_DIRS)
-   set(CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES ${CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES} ${SYSTEM_INCLUDE_DIRS})
-endif ()
-
-if (CMAKE_COMPILER_IS_GNUCXX)
-   DETERMINE_GCC_SYSTEM_INCLUDE_DIRS("c++" "${CMAKE_CXX_COMPILER}" "${CMAKE_CXX_FLAGS}" SYSTEM_INCLUDE_DIRS)
-   set(CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES ${CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES} ${SYSTEM_INCLUDE_DIRS})
-endif ()
-
 # Detect Cortex-A53 core if CPU is ARM64 and OS is Linux.
 # Query /proc/cpuinfo for each available core and check reported CPU part number: 0xd03 signals Cortex-A53.
 # (see Main ID Register in ARM Cortex-A53 MPCore Processor Technical Reference Manual)
@@ -127,12 +36,7 @@ if (WTF_CPU_ARM64_CORTEXA53)
     if (NOT WTF_CPU_ARM64)
         message(FATAL_ERROR "WTF_CPU_ARM64_CORTEXA53 set without WTF_CPU_ARM64")
     endif ()
-    CHECK_CXX_ACCEPTS_FLAG(-mfix-cortex-a53-835769 CXX_ACCEPTS_MFIX_CORTEX_A53_835769)
-    if (CXX_ACCEPTS_MFIX_CORTEX_A53_835769)
-        set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mfix-cortex-a53-835769")
-        set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mfix-cortex-a53-835769")
-        message(STATUS "Enabling Cortex-A53 workaround for compiler and disabling GNU gold linker, because it doesn't support this workaround.")
-    endif ()
+    WEBKIT_PREPEND_GLOBAL_COMPILER_FLAG(-mfix-cortex-a53-835769)
 endif ()
 
 EXPOSE_VARIABLE_TO_BUILD(WTF_CPU_ARM64_CORTEXA53)
@@ -171,8 +75,8 @@ endif ()
 
 set(ENABLE_DEBUG_FISSION_DEFAULT OFF)
 if (USE_LD_GOLD AND CMAKE_BUILD_TYPE STREQUAL "Debug")
-    CHECK_CXX_ACCEPTS_FLAG(-gsplit-dwarf CXX_ACCEPTS_GSPLIT_DWARF)
-    if (CXX_ACCEPTS_GSPLIT_DWARF)
+    check_cxx_compiler_flag(-gsplit-dwarf CXX_COMPILER_SUPPORTS_GSPLIT_DWARF)
+    if (CXX_COMPILER_SUPPORTS_GSPLIT_DWARF)
         set(ENABLE_DEBUG_FISSION_DEFAULT ON)
     endif ()
 endif ()
@@ -189,26 +93,6 @@ if (DEBUG_FISSION)
     set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--gdb-index")
 endif ()
 
-if (COMPILER_IS_CLANG)
-    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Qunused-arguments")
-    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Qunused-arguments")
-endif ()
-
-string(TOLOWER ${CMAKE_HOST_SYSTEM_PROCESSOR} LOWERCASE_CMAKE_HOST_SYSTEM_PROCESSOR)
-if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" AND NOT "${LOWERCASE_CMAKE_HOST_SYSTEM_PROCESSOR}" MATCHES "x86_64")
-    # To avoid out of memory when building with debug option in 32bit system.
-    # See https://bugs.webkit.org/show_bug.cgi?id=77327
-    set(CMAKE_SHARED_LINKER_FLAGS_DEBUG "-Wl,--no-keep-memory ${CMAKE_SHARED_LINKER_FLAGS_DEBUG}")
-endif ()
-
-if (NOT MSVC)
-    string(REGEX MATCHALL "-fsanitize=[^ ]*" ENABLED_COMPILER_SANITIZERS ${CMAKE_CXX_FLAGS})
-endif ()
-
-if (UNIX AND NOT APPLE AND NOT ENABLED_COMPILER_SANITIZERS)
-    set(CMAKE_SHARED_LINKER_FLAGS "-Wl,--no-undefined ${CMAKE_SHARED_LINKER_FLAGS}")
-endif ()
-
 if (USE_ARM_LLVM_DISASSEMBLER)
     find_package(LLVM REQUIRED)
     SET_AND_EXPOSE_TO_BUILD(HAVE_LLVM TRUE)
index 9864996..79717b4 100644 (file)
@@ -37,6 +37,8 @@ if (NOT HAS_RUN_WEBKIT_COMMON)
     # -----------------------------------------------------------------------------
 
     # To prevent multiple inclusion, most modules should be included once here.
+    include(CheckCCompilerFlag)
+    include(CheckCXXCompilerFlag)
     include(CheckCXXSourceCompiles)
     include(CheckFunctionExists)
     include(CheckIncludeFile)
@@ -46,11 +48,11 @@ if (NOT HAS_RUN_WEBKIT_COMMON)
     include(CMakeDependentOption)
     include(CMakeParseArguments)
     include(ProcessorCount)
-    include(TestCXXAcceptsFlag)
 
     include(WebKitPackaging)
     include(WebKitMacros)
     include(WebKitFS)
+    include(WebKitCompilerFlags)
     include(WebKitFeatures)
 
     include(OptionsCommon)
diff --git a/Source/cmake/WebKitCompilerFlags.cmake b/Source/cmake/WebKitCompilerFlags.cmake
new file mode 100644 (file)
index 0000000..d99bc1f
--- /dev/null
@@ -0,0 +1,200 @@
+# Prepends flags to CMAKE_C_FLAGS if supported by the C compiler. Almost all
+# flags should be prepended to allow the user to override them.
+macro(WEBKIT_PREPEND_GLOBAL_C_FLAGS)
+    foreach (_flag ${ARGN})
+        check_c_compiler_flag("${_flag}" C_COMPILER_SUPPORTS_${_flag})
+        if (C_COMPILER_SUPPORTS_${_flag})
+            set(CMAKE_C_FLAGS "${_flag} ${CMAKE_C_FLAGS}")
+        endif ()
+    endforeach ()
+endmacro()
+
+# Appends flags to CMAKE_C_FLAGS if supported by the C compiler. This macro
+# should be used sparingly. Only append flags if the user must not be allowed to
+# override them.
+macro(WEBKIT_APPEND_GLOBAL_C_FLAGS)
+    foreach (_flag ${ARGN})
+        check_c_compiler_flag("${_flag}" C_COMPILER_SUPPORTS_${_flag})
+        if (C_COMPILER_SUPPORTS_${_flag})
+            set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${_flag}")
+        endif ()
+    endforeach ()
+endmacro()
+
+# Prepends flags to CMAKE_CXX_FLAGS if supported by the C++ compiler. Almost all
+# flags should be prepended to allow the user to override them.
+macro(WEBKIT_PREPEND_GLOBAL_CXX_FLAGS)
+    foreach (_flag ${ARGN})
+        check_cxx_compiler_flag("${_flag}" CXX_COMPILER_SUPPORTS_${_flag})
+        if (CXX_COMPILER_SUPPORTS_${_flag})
+            set(CMAKE_CXX_FLAGS "${_flag} ${CMAKE_CXX_FLAGS}")
+        endif ()
+    endforeach ()
+endmacro()
+
+# Appends flags to CMAKE_CXX_FLAGS if supported by the C++ compiler. This macro
+# should be used sparingly. Only append flags if the user must not be allowed to
+# override them.
+macro(WEBKIT_APPEND_GLOBAL_CXX_FLAGS)
+    foreach (_flag ${ARGN})
+        check_cxx_compiler_flag("${_flag}" CXX_COMPILER_SUPPORTS_${_flag})
+        if (CXX_COMPILER_SUPPORTS_${_flag})
+            set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${_flag}")
+        endif ()
+    endforeach ()
+endmacro()
+
+# Prepends flags to CMAKE_C_FLAGS and CMAKE_CXX_FLAGS if supported by the C
+# or C++ compiler, respectively. Almost all flags should be prepended to allow
+# the user to override them.
+macro(WEBKIT_PREPEND_GLOBAL_COMPILER_FLAGS)
+    WEBKIT_PREPEND_GLOBAL_C_FLAGS(${ARGN})
+    WEBKIT_PREPEND_GLOBAL_CXX_FLAGS(${ARGN})
+endmacro()
+
+# Appends flags to CMAKE_C_FLAGS and CMAKE_CXX_FLAGS if supported by the C or
+# C++ compiler, respectively. This macro should be used sparingly. Only append
+# flags if the user must not be allowed to override them.
+macro(WEBKIT_APPEND_GLOBAL_COMPILER_FLAGS)
+    WEBKIT_APPEND_GLOBAL_C_FLAGS(${ARGN})
+    WEBKIT_APPEND_GLOBAL_CXX_FLAGS(${ARGN})
+endmacro()
+
+# Appends flags to COMPILE_FLAGS of _target if supported by the C compiler.
+# Note that it is simply not possible to pass different C and C++ flags, unless
+# we drop support for the Visual Studio backend and use the COMPILE_LANGUAGE
+# generator expression. This is a very serious limitation.
+macro(WEBKIT_ADD_TARGET_C_FLAGS _target)
+    foreach (_flag ${ARGN})
+        check_c_compiler_flag("${_flag}" C_COMPILER_SUPPORTS_${_flag})
+        if (C_COMPILER_SUPPORTS_${_flag})
+            target_compile_options(${_target} PRIVATE ${_flag})
+        endif ()
+    endforeach ()
+endmacro()
+
+# Appends flags to COMPILE_FLAGS of _target if supported by the C++ compiler.
+# Note that it is simply not possible to pass different C and C++ flags, unless
+# we drop support for the Visual Studio backend and use the COMPILE_LANGUAGE
+# generator expression. This is a very serious limitation.
+macro(WEBKIT_ADD_TARGET_CXX_FLAGS _target)
+    foreach (_flag ${ARGN})
+        check_cxx_compiler_flag("${_flag}" CXX_COMPILER_SUPPORTS_${_flag})
+        if (CXX_COMPILER_SUPPORTS_${_flag})
+            target_compile_options(${_target} PRIVATE ${_flag})
+        endif ()
+    endforeach ()
+endmacro()
+
+
+if (COMPILER_IS_GCC_OR_CLANG)
+    WEBKIT_APPEND_GLOBAL_COMPILER_FLAGS(-fno-strict-aliasing)
+
+    # 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
+    if (COMPILER_IS_CLANG_CL)
+        # FIXME: These warnings should be addressed
+        WEBKIT_PREPEND_GLOBAL_COMPILER_FLAGS(-Wno-undef
+                                             -Wno-macro-redefined
+                                             -Wno-unknown-pragmas
+                                             -Wno-nonportable-include-path
+                                             -Wno-unknown-argument)
+    else ()
+        WEBKIT_APPEND_GLOBAL_COMPILER_FLAGS(-fno-exceptions)
+        WEBKIT_APPEND_GLOBAL_CXX_FLAGS(-std=c++14
+                                       -fno-rtti)
+
+        if (WIN32)
+            WEBKIT_APPEND_GLOBAL_COMPILER_FLAGS(-mno-ms-bitfields)
+            WEBKIT_PREPEND_GLOBAL_COMPILER_FLAGS(-Wno-unknown-pragmas)
+            add_definitions(-D__USE_MINGW_ANSI_STDIO=1)
+        endif ()
+    endif ()
+
+    # Warnings to be enabled
+    WEBKIT_PREPEND_GLOBAL_COMPILER_FLAGS(-Wall
+                                         -Wextra
+                                         -Wcast-align
+                                         -Wformat-security
+                                         -Wmissing-format-attribute
+                                         -Wpointer-arith
+                                         -Wundef
+                                         -Wwrite-strings)
+
+    # Warnings to be disabled
+    # FIXME: We should probably not be disabling -Wno-maybe-uninitialized?
+    WEBKIT_PREPEND_GLOBAL_COMPILER_FLAGS(-Qunused-arguments
+                                         -Wno-expansion-to-defined
+                                         -Wno-maybe-uninitialized
+                                         -Wno-noexcept-type
+                                         -Wno-parentheses-equality)
+endif ()
+
+
+# Ninja tricks compilers into turning off color support.
+if (CMAKE_GENERATOR STREQUAL "Ninja")
+    WEBKIT_PREPEND_GLOBAL_COMPILER_FLAGS(-fcolor-diagnostics
+                                         -fdiagnostics-color=always)
+endif ()
+
+
+string(TOLOWER ${CMAKE_HOST_SYSTEM_PROCESSOR} LOWERCASE_CMAKE_HOST_SYSTEM_PROCESSOR)
+if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" AND NOT "${LOWERCASE_CMAKE_HOST_SYSTEM_PROCESSOR}" MATCHES "x86_64")
+    # To avoid out of memory when building with debug option in 32bit system.
+    # See https://bugs.webkit.org/show_bug.cgi?id=77327
+    set(CMAKE_SHARED_LINKER_FLAGS_DEBUG "-Wl,--no-keep-memory ${CMAKE_SHARED_LINKER_FLAGS_DEBUG}")
+endif ()
+
+
+if (NOT MSVC)
+    string(REGEX MATCHALL "-fsanitize=[^ ]*" ENABLED_COMPILER_SANITIZERS ${CMAKE_CXX_FLAGS})
+endif ()
+
+if (UNIX AND NOT APPLE AND NOT ENABLED_COMPILER_SANITIZERS)
+    set(CMAKE_SHARED_LINKER_FLAGS "-Wl,--no-undefined ${CMAKE_SHARED_LINKER_FLAGS}")
+endif ()
+
+
+# CODE_GENERATOR_PREPROCESSOR_WITH_LINEMARKERS only matters with GCC >= 4.7.0.  Since this
+# version, -P does not output empty lines, which currently breaks make_names.pl in
+# WebCore. Investigating whether make_names.pl should be changed instead is left as an exercise to
+# the reader.
+if (MSVC)
+    set(CODE_GENERATOR_PREPROCESSOR_ARGUMENTS "/nologo /EP /TP")
+    set(CODE_GENERATOR_PREPROCESSOR_WITH_LINEMARKERS_ARGUMENTS ${CODE_GENERATOR_PREPROCESSOR_ARGUMENTS})
+else ()
+    set(CODE_GENERATOR_PREPROCESSOR_ARGUMENTS "-E -P -x c++")
+    set(CODE_GENERATOR_PREPROCESSOR_WITH_LINEMARKERS_ARGUMENTS "-E -x c++")
+endif ()
+
+set(CODE_GENERATOR_PREPROCESSOR "\"${CMAKE_CXX_COMPILER}\" ${CODE_GENERATOR_PREPROCESSOR_ARGUMENTS}")
+set(CODE_GENERATOR_PREPROCESSOR_WITH_LINEMARKERS "\"${CMAKE_CXX_COMPILER}\" ${CODE_GENERATOR_PREPROCESSOR_WITH_LINEMARKERS_ARGUMENTS}")
+
+
+# Ensure that the default include system directories are added to the list of CMake implicit includes.
+# This workarounds an issue that happens when using GCC 6 and using system includes (-isystem).
+# For more details check: https://bugs.webkit.org/show_bug.cgi?id=161697
+macro(DETERMINE_GCC_SYSTEM_INCLUDE_DIRS _lang _compiler _flags _result)
+    file(WRITE "${CMAKE_BINARY_DIR}/CMakeFiles/dummy" "\n")
+    separate_arguments(_buildFlags UNIX_COMMAND "${_flags}")
+    execute_process(COMMAND ${_compiler} ${_buildFlags} -v -E -x ${_lang} -dD dummy
+                    WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/CMakeFiles OUTPUT_QUIET
+                    ERROR_VARIABLE _gccOutput)
+    file(REMOVE "${CMAKE_BINARY_DIR}/CMakeFiles/dummy")
+    if ("${_gccOutput}" MATCHES "> search starts here[^\n]+\n *(.+) *\n *End of (search) list")
+        set(${_result} ${CMAKE_MATCH_1})
+        string(REPLACE "\n" " " ${_result} "${${_result}}")
+        separate_arguments(${_result})
+    endif ()
+endmacro()
+
+if (CMAKE_COMPILER_IS_GNUCC)
+   DETERMINE_GCC_SYSTEM_INCLUDE_DIRS("c" "${CMAKE_C_COMPILER}" "${CMAKE_C_FLAGS}" SYSTEM_INCLUDE_DIRS)
+   set(CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES ${CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES} ${SYSTEM_INCLUDE_DIRS})
+endif ()
+
+if (CMAKE_COMPILER_IS_GNUCXX)
+   DETERMINE_GCC_SYSTEM_INCLUDE_DIRS("c++" "${CMAKE_CXX_COMPILER}" "${CMAKE_CXX_FLAGS}" SYSTEM_INCLUDE_DIRS)
+   set(CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES ${CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES} ${SYSTEM_INCLUDE_DIRS})
+endif ()
index 89334e6..7bc8954 100644 (file)
@@ -176,46 +176,6 @@ macro(WEBKIT_DEBUG_DUMP_VARIABLES)
     endforeach ()
 endmacro()
 
-# Sets extra compile flags for a target, depending on the compiler being used.
-# Currently, only GCC is supported.
-macro(WEBKIT_SET_EXTRA_COMPILER_FLAGS _target)
-    set(options ENABLE_WERROR IGNORECXX_WARNINGS)
-    CMAKE_PARSE_ARGUMENTS("OPTION" "${options}" "" "" ${ARGN})
-    if (COMPILER_IS_GCC_OR_CLANG)
-        get_target_property(OLD_COMPILE_FLAGS ${_target} COMPILE_FLAGS)
-        if (${OLD_COMPILE_FLAGS} STREQUAL "OLD_COMPILE_FLAGS-NOTFOUND")
-            set(OLD_COMPILE_FLAGS "")
-        endif ()
-
-        if (NOT WIN32)
-            get_target_property(TARGET_TYPE ${_target} TYPE)
-            if (${TARGET_TYPE} STREQUAL "STATIC_LIBRARY") # -fPIC is automatically added to shared libraries
-                set(OLD_COMPILE_FLAGS "-fPIC ${OLD_COMPILE_FLAGS}")
-            endif ()
-        endif ()
-
-        # Suppress -Wparentheses-equality warning of Clang
-        if (COMPILER_IS_CLANG)
-            set(OLD_COMPILE_FLAGS "-Wno-parentheses-equality ${OLD_COMPILE_FLAGS}")
-        endif ()
-
-        # Enable warnings by default
-        if (NOT ${OPTION_IGNORECXX_WARNINGS})
-            set(OLD_COMPILE_FLAGS "-Wall -Wextra -Wcast-align -Wformat-security -Wmissing-format-attribute -Wpointer-arith -Wundef -Wwrite-strings ${OLD_COMPILE_FLAGS}")
-        endif ()
-
-        # Enable errors on warning
-        if (OPTION_ENABLE_WERROR)
-            set(OLD_COMPILE_FLAGS "-Werror ${OLD_COMPILE_FLAGS}")
-        endif ()
-
-        set_target_properties(${_target} PROPERTIES
-            COMPILE_FLAGS "${OLD_COMPILE_FLAGS}")
-
-        unset(OLD_COMPILE_FLAGS)
-    endif ()
-endmacro()
-
 # Append the given flag to the target property.
 # Builds on top of get_target_property() and set_target_properties()
 macro(WEBKIT_ADD_TARGET_PROPERTIES _target _property _flags)
index bdd3019..8b595b6 100644 (file)
@@ -1,3 +1,40 @@
+2017-08-08  Michael Catanzaro  <mcatanzaro@igalia.com>
+
+        [CMake] Properly test if compiler supports compiler flags
+        https://bugs.webkit.org/show_bug.cgi?id=174490
+
+        Reviewed by Konstantin Tokarev.
+
+        * DumpRenderTree/TestNetscapePlugIn/CMakeLists.txt:
+        * MiniBrowser/gtk/CMakeLists.txt:
+        * TestRunnerShared/Bindings/JSWrapper.cpp:
+        (WTR::JSWrapper::initialize):
+        * TestWebKitAPI/CMakeLists.txt:
+        * TestWebKitAPI/PlatformGTK.cmake:
+        * TestWebKitAPI/Tests/WTF/CheckedArithmeticOperations.cpp:
+        (TestWebKitAPI::CheckedArithmeticTester::run):
+        * TestWebKitAPI/Tests/WebKitGLib/TestAutomationSession.cpp:
+        * TestWebKitAPI/Tests/WebKitGLib/TestWebExtensions.cpp:
+        * TestWebKitAPI/Tests/WebKitGLib/WebExtensionTest.cpp:
+        (formControlsAssociatedCallback):
+        * TestWebKitAPI/glib/CMakeLists.txt:
+        * TestWebKitAPI/glib/WebKitGLib/TestMain.h:
+        (Test::getResourcesDir):
+        * WebKitTestRunner/CMakeLists.txt:
+        * WebKitTestRunner/InjectedBundle/EventSendingController.cpp:
+        (WTR::menuItemClickCallback):
+        (WTR::staticConvertMenuItemToType):
+        * WebKitTestRunner/InjectedBundle/TestRunner.cpp:
+        (WTR::TestRunner::setUseDashboardCompatibilityMode):
+        * WebKitTestRunner/InjectedBundle/atk/AccessibilityNotificationHandlerAtk.cpp:
+        (WTR::AccessibilityNotificationHandler::disconnectAccessibilityCallbacks):
+        * WebKitTestRunner/InjectedBundle/atk/AccessibilityUIElementAtk.cpp:
+        (WTR::AccessibilityUIElement::helpText const):
+        (WTR::AccessibilityUIElement::attributedStringForRange):
+        * WebKitTestRunner/gtk/EventSenderProxyGtk.cpp:
+        (WTR::EventSenderProxy::updateTouchPoint):
+        (WTR::EventSenderProxy::releaseTouchPoint):
+
 2017-08-08  Wenson Hsieh  <wenson_hsieh@apple.com>
 
         [iOS WK2] WKWebView schedules nonstop layout after pressing cmb+b,i,u inside a contenteditable div
index 8a19e78..3847d01 100644 (file)
@@ -55,7 +55,5 @@ endif ()
 add_library(TestNetscapePlugIn SHARED ${WebKitTestNetscapePlugIn_SOURCES})
 target_link_libraries(TestNetscapePlugIn ${WebKitTestNetscapePlugIn_LIBRARIES})
 set_target_properties(TestNetscapePlugIn PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/plugins)
-WEBKIT_SET_EXTRA_COMPILER_FLAGS(TestNetscapePlugIn)
 
-# Suppress unused parameter warnings for sources in WebKit2.
-WEBKIT_ADD_TARGET_PROPERTIES(TestNetscapePlugIn COMPILE_FLAGS "-Wno-unused-parameter")
+WEBKIT_ADD_TARGET_CXX_FLAGS(TestNetscapePlugIn -Wno-unused-parameter)
index e38bc6d..e832a86 100644 (file)
@@ -61,4 +61,6 @@ include_directories(SYSTEM ${MiniBrowser_SYSTEM_INCLUDE_DIRECTORIES})
 add_executable(MiniBrowser ${MiniBrowser_SOURCES})
 target_link_libraries(MiniBrowser ${MiniBrowser_LIBRARIES})
 
+WEBKIT_ADD_TARGET_CXX_FLAGS(MiniBrowser -Wno-unused-parameter)
+
 install(TARGETS MiniBrowser DESTINATION "${LIBEXEC_INSTALL_DIR}")
index e3cf58c..6f47c10 100644 (file)
@@ -61,7 +61,7 @@ static JSWrappable* unwrapObject(JSObjectRef object)
     return wrappable;
 }
 
-void JSWrapper::initialize(JSContextRef ctx, JSObjectRef object)
+void JSWrapper::initialize(JSContextRef, JSObjectRef object)
 {
     JSWrappable* wrappable = unwrapObject(object);
     if (!wrappable)
index dddf063..539758f 100644 (file)
@@ -151,6 +151,13 @@ if (ENABLE_WEBKIT)
 
     target_link_libraries(TestWebKitAPIInjectedBundle ${TestWebKitAPI_LIBRARIES})
     add_dependencies(TestWebKitAPIInjectedBundle WTF ${ForwardingHeadersForTestWebKitAPI_NAME})
+
+    if (COMPILER_IS_GCC_OR_CLANG)
+        WEBKIT_ADD_TARGET_CXX_FLAGS(TestWebKitAPIInjectedBundle -Wno-dangling-else
+                                                                -Wno-sign-compare
+                                                                -Wno-undef
+                                                                -Wno-unused-parameter)
+    endif ()
 endif ()
 
 if (WIN32)
@@ -186,6 +193,13 @@ set_target_properties(TestWTF PROPERTIES
     RUNTIME_OUTPUT_DIRECTORY ${TESTWEBKITAPI_RUNTIME_OUTPUT_DIRECTORY_WTF}
 )
 
+if (COMPILER_IS_GCC_OR_CLANG)
+    WEBKIT_ADD_TARGET_CXX_FLAGS(TestWTF -Wno-dangling-else
+                                        -Wno-sign-compare
+                                        -Wno-undef
+                                        -Wno-unused-parameter)
+endif ()
+
 if (ENABLE_WEBKIT)
     add_library(TestWebKitAPIBase
         ${test_main_SOURCES}
@@ -198,4 +212,10 @@ if (ENABLE_WEBKIT)
     target_link_libraries(TestWebKitAPIBase JavaScriptCore WTF WebKit2 gtest)
 
     add_dependencies(TestWebKitAPIBase WebKit2 ${ForwardingHeadersForTestWebKitAPI_NAME} ${ForwardingNetworkHeadersForTestWebKitAPI_NAME})
+
+    if (COMPILER_IS_GCC_OR_CLANG)
+        WEBKIT_ADD_TARGET_CXX_FLAGS(TestWebKitAPIBase -Wno-sign-compare
+                                                      -Wno-undef
+                                                      -Wno-unused-parameter)
+    endif ()
 endif ()
index ffc72f2..03da341 100644 (file)
@@ -156,3 +156,13 @@ list(APPEND TestWTF_SOURCES
     ${TESTWEBKITAPI_DIR}/Tests/WTF/glib/GUniquePtr.cpp
     ${TESTWEBKITAPI_DIR}/Tests/WTF/glib/WorkQueueGLib.cpp
 )
+
+if (COMPILER_IS_GCC_OR_CLANG)
+    WEBKIT_ADD_TARGET_CXX_FLAGS(TestWebKit2 -Wno-sign-compare
+                                            -Wno-undef
+                                            -Wno-unused-parameter)
+
+    WEBKIT_ADD_TARGET_CXX_FLAGS(TestWebCore -Wno-sign-compare
+                                            -Wno-undef
+                                            -Wno-unused-parameter)
+endif ()
index d6b5483..92cd4e4 100644 (file)
@@ -168,7 +168,15 @@ public:
 
         Checked<type, OverflowCrashLogger> nvalue; // to hold a not overflowed value.
         Checked<type, OverflowCrashLogger> ovalue; // to hold an overflowed value.
+
+#if COMPILER(GCC)
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wunused-but-set-variable"
+#endif
         bool unused;
+#if COMPILER(GCC)
+#pragma GCC diagnostic pop
+#endif
 
         _value = 75;
         type _largeValue = 100;
index 6dda286..cb611ac 100644 (file)
@@ -96,6 +96,8 @@ public:
         nullptr,
         // set_property
         nullptr,
+        // padding
+        nullptr
     };
 
     void registerDBusObject()
index 2168842..ccb11da 100644 (file)
@@ -23,7 +23,6 @@
 #include "WebViewTest.h"
 #include <wtf/glib/GRefPtr.h>
 
-static const char* webExtensionsUserData = "Web Extensions user data";
 static WebKitTestBus* bus;
 static GUniquePtr<char> scriptDialogResult;
 
index 37a2764..b581fab 100644 (file)
@@ -290,7 +290,7 @@ static void emitFormControlsAssociated(GDBusConnection* connection, const char*
 static void formControlsAssociatedCallback(WebKitWebPage* webPage, GPtrArray* formElements, WebKitWebExtension* extension)
 {
     GString* formIdsBuilder = g_string_new(nullptr);
-    for (int i = 0; i < formElements->len; ++i) {
+    for (guint i = 0; i < formElements->len; ++i) {
         g_assert(WEBKIT_DOM_IS_ELEMENT(g_ptr_array_index(formElements, i)));
         auto domElement = WEBKIT_DOM_ELEMENT(g_ptr_array_index(formElements, i));
         GUniquePtr<char> elementID(webkit_dom_element_get_id(domElement));
index d091165..073cbb4 100644 (file)
@@ -51,6 +51,10 @@ macro(ADD_WK2_TEST_WEB_EXTENSION extension_name)
         LIBRARY_OUTPUT_DIRECTORY ${TEST_LIBRARY_DIR}
     )
     target_link_libraries(${extension_name} ${WebKitGLibAPITestExtension_LIBRARIES})
+
+    if (COMPILER_IS_GCC_OR_CLANG)
+        WEBKIT_ADD_TARGET_CXX_FLAGS(${extension_name} -Wno-unused-parameter)
+    endif ()
 endmacro()
 
 macro(ADD_WK2_TEST test_name)
@@ -63,6 +67,10 @@ macro(ADD_WK2_TEST test_name)
         RUNTIME_OUTPUT_DIRECTORY ${TEST_BINARY_DIR}
     )
     target_link_libraries(${test_name} ${WebKitGLibAPITest_LIBRARIES})
+
+    if (COMPILER_IS_GCC_OR_CLANG)
+        WEBKIT_ADD_TARGET_CXX_FLAGS(${test_name} -Wno-unused-parameter)
+    endif ()
 endmacro()
 
 WEBKIT_INCLUDE_CONFIG_FILES_IF_EXISTS()
@@ -85,6 +93,10 @@ include_directories(SYSTEM ${WebKitGLibAPITests_SYSTEM_INCLUDE_DIRECTORIES})
 add_library(WebKitGLibAPITestsCore STATIC ${WebKitGLibAPITests_SOURCES})
 target_link_libraries(WebKitGLibAPITestsCore WebKit2)
 
+if (COMPILER_IS_GCC_OR_CLANG)
+    WEBKIT_ADD_TARGET_CXX_FLAGS(WebKitGLibAPITestsCore -Wno-unused-parameter)
+endif ()
+
 add_custom_command(
     OUTPUT ${TEST_RESOURCES_DIR}/webkitglib-tests-resources.gresource
     DEPENDS ${TOOLS_DIR}/TestWebKitAPI/Tests/WebKitGLib/resources/webkitglib-tests.gresource.xml
index 36e03fd..d9c2ee1 100644 (file)
 #define MAKE_GLIB_TEST_FIXTURE_WITH_SETUP_TEARDOWN(ClassName, setup, teardown) \
     static void setUp(ClassName* fixture, gconstpointer data) \
     { \
-        if (setup) \
-            setup(); \
+        setup(); \
         new (fixture) ClassName; \
     } \
     static void tearDown(ClassName* fixture, gconstpointer data) \
     { \
         fixture->~ClassName(); \
-        if (teardown) \
-            teardown(); \
+        teardown(); \
     } \
     static void add(const char* suiteName, const char* testName, void (*testFunc)(ClassName*, const void*)) \
     { \
@@ -173,6 +171,7 @@ public:
             return resourcesDir.get();
         }
         }
+        RELEASE_ASSERT_NOT_REACHED();
     }
 
     void addLogFatalFlag(unsigned flag)
index fb7d523..846c944 100644 (file)
@@ -116,6 +116,11 @@ add_executable(WebKitTestRunner ${WebKitTestRunner_SOURCES})
 target_link_libraries(WebKitTestRunner ${WebKitTestRunner_LIBRARIES})
 add_dependencies(WebKitTestRunner WebKitTestRunnerBindings)
 
+if (COMPILER_IS_GCC_OR_CLANG)
+    WEBKIT_ADD_TARGET_CXX_FLAGS(TestRunnerInjectedBundle -Wno-unused-parameter)
+    WEBKIT_ADD_TARGET_CXX_FLAGS(WebKitTestRunner -Wno-unused-parameter)
+endif ()
+
 if (NOT APPLE)
     add_dependencies(WebKit2 ${ForwardingHeadersForWebKitTestRunner_NAME})
-endif ()
\ No newline at end of file
+endif ()
index b5c4e68..76384d5 100644 (file)
@@ -52,7 +52,7 @@ struct MenuItemPrivateData {
 };
 
 #if ENABLE(CONTEXT_MENUS)
-static JSValueRef menuItemClickCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
+static JSValueRef menuItemClickCallback(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t, const JSValueRef[], JSValueRef*)
 {
     MenuItemPrivateData* privateData = static_cast<MenuItemPrivateData*>(JSObjectGetPrivate(thisObject));
     WKBundlePageClickMenuItem(privateData->m_page, privateData->m_item.get());
@@ -81,7 +81,7 @@ static void staticMenuItemFinalize(JSObjectRef object)
     delete static_cast<MenuItemPrivateData*>(JSObjectGetPrivate(object));
 }
 
-static JSValueRef staticConvertMenuItemToType(JSContextRef context, JSObjectRef object, JSType type, JSValueRef* exception)
+static JSValueRef staticConvertMenuItemToType(JSContextRef context, JSObjectRef object, JSType type, JSValueRef*)
 {
     if (kJSTypeString == type)
         return getMenuItemTitleCallback(context, object, 0, 0);
index de62ddb..e722e47 100644 (file)
@@ -467,6 +467,8 @@ void TestRunner::setUseDashboardCompatibilityMode(bool enabled)
 #if ENABLE(DASHBOARD_SUPPORT)
     auto& injectedBundle = InjectedBundle::singleton();
     WKBundleSetUseDashboardCompatibilityMode(injectedBundle.bundle(), injectedBundle.pageGroup(), enabled);
+#else
+    UNUSED_PARAM(enabled);
 #endif
 }
     
index e8304ab..2ac7b9d 100644 (file)
@@ -112,7 +112,7 @@ gboolean axObjectEventListener(GSignalInvocationHint* signalHint, unsigned numPa
         arguments[0] = toJS(jsContext, WTF::getPtr(WTR::AccessibilityUIElement::create(accessible)));
         arguments[1] = notificationNameArgument;
         size_t numOfExtraArgs = extraArgs.size();
-        for (int i = 0; i < numOfExtraArgs; i++)
+        for (size_t i = 0; i < numOfExtraArgs; i++)
             arguments[i + 2] = extraArgs[i];
         if (elementNotificationHandler != notificationHandlers.end()) {
             // Listener for one element. As arguments, it gets the notification name
@@ -256,7 +256,7 @@ bool AccessibilityNotificationHandler::disconnectAccessibilityCallbacks()
         return false;
 
     // AtkObject signals.
-    for (int i = 0; i < listenerIds.size(); i++) {
+    for (size_t i = 0; i < listenerIds.size(); i++) {
         ASSERT(listenerIds[i]);
         atk_remove_global_event_listener(listenerIds[i]);
     }
index 832c36b..1430d94 100644 (file)
@@ -1415,7 +1415,7 @@ JSRetainPtr<JSStringRef> AccessibilityUIElement::helpText() const
     StringBuilder builder;
     builder.append("AXHelp: ");
 
-    for (int targetCount = 0; targetCount < targetList->len; targetCount++) {
+    for (guint targetCount = 0; targetCount < targetList->len; targetCount++) {
         if (AtkObject* target = static_cast<AtkObject*>(g_ptr_array_index(targetList, targetCount))) {
             GUniquePtr<gchar> text(atk_text_get_text(ATK_TEXT(target), 0, -1));
             if (targetCount)
@@ -1756,7 +1756,7 @@ JSRetainPtr<JSStringRef> AccessibilityUIElement::attributedStringForRange(unsign
     AtkAttributeSet* attributeSet;
     AtkText* text = ATK_TEXT(m_element.get());
     gint start = 0, end = 0;
-    for (int i = location; i < location + length; i = end) {
+    for (unsigned i = location; i < location + length; i = end) {
         AtkAttributeSet* attributeSet = atk_text_get_run_attributes(text, i, &start, &end);
         GUniquePtr<gchar> substring(replaceCharactersForResults(atk_text_get_text(text, start, end)));
         builder.append(String::format("\n\tRange attributes for '%s':\n\t\t", substring.get()));
index 6da0dd2..8508b71 100644 (file)
@@ -505,7 +505,7 @@ void EventSenderProxy::addTouchPoint(int x, int y)
 
 void EventSenderProxy::updateTouchPoint(int index, int x, int y)
 {
-    ASSERT(index >= 0 && index < m_touchEvents.size());
+    ASSERT(index >= 0 && static_cast<size_t>(index) < m_touchEvents.size());
 
     const auto& event = m_touchEvents[index];
     ASSERT(event);
@@ -551,7 +551,7 @@ void EventSenderProxy::clearTouchPoints()
 
 void EventSenderProxy::releaseTouchPoint(int index)
 {
-    ASSERT(index >= 0 && index < m_touchEvents.size());
+    ASSERT(index >= 0 && static_cast<size_t>(index) < m_touchEvents.size());
 
     const auto& event = m_touchEvents[index];
     event->type = GDK_TOUCH_END;