Changeset 220403 in webkit for trunk/Source/JavaScriptCore/API


Ignore:
Timestamp:
Aug 8, 2017, 8:03:48 AM (8 years ago)
Author:
Michael Catanzaro
Message:

[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:

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):

Location:
trunk/Source/JavaScriptCore/API/tests
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/API/tests/PingPongStackOverflowTest.cpp

    r216914 r220403  
    143143        "undefined instanceof PingPongStackOverflowObject;";
    144144
    145     JSValueRef scriptResult = nullptr;
    146145    JSValueRef exception = nullptr;
    147146    JSStringRef script = JSStringCreateWithUTF8CString(scriptString);
     
    162161
    163162    exception = nullptr;
    164     scriptResult = JSEvaluateScript(context, script, nullptr, nullptr, 1, &exception);
     163    JSEvaluateScript(context, script, nullptr, nullptr, 1, &exception);
    165164
    166165    if (!exception) {
  • trunk/Source/JavaScriptCore/API/tests/testapi.c

    r218936 r220403  
    11351135}
    11361136
     1137#if COMPILER(GCC)
     1138#pragma GCC diagnostic push
     1139#pragma GCC diagnostic ignored "-Wunused-but-set-variable"
     1140#endif
    11371141static void checkConstnessInJSObjectNames()
    11381142{
     
    11421146    val.name = "something";
    11431147}
     1148#if COMPILER(GCC)
     1149#pragma GCC diagnostic pop
     1150#endif
    11441151
    11451152#ifdef __cplusplus
Note: See TracChangeset for help on using the changeset viewer.