Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 3b87c975ae69e16933fed6cca212b4dd4b781af7
      
https://github.com/WebKit/WebKit/commit/3b87c975ae69e16933fed6cca212b4dd4b781af7
  Author: Carlos Alberto Lopez Perez <[email protected]>
  Date:   2026-08-06 (Thu, 06 Aug 2026)

  Changed paths:
    M Source/cmake/WebKitFeatures.cmake
    M Source/cmake/WebKitMacros.cmake

  Log Message:
  -----------
  REGRESSION(314923@main): [CMake] Give the Swift Clang importer the same 
global preprocessor definitions as C++
https://bugs.webkit.org/show_bug.cgi?id=316878

Reviewed by Adrian Taylor.

On a Release+Asserts build with Clang, every layout test crashes with
ASSERTION FAILED: !m_adoptionIsRequired at wtf/RefCountDebugger.h

The object causing the assertion is WebBackForwardListMessageForwarder, the
generated C++ shim that forwards WebBackForwardList IPC messages into Swift.
This object is allocated from Swift by calling the inline createFromWeak()
function.

The Swift compiler uses its clang importer to compile inline C++ functions.
The problem is that the importer was compiling the WTF headers with different
preprocessor definitions than the regular C++ compilation.

The C++ compilation received both -DNDEBUG and -DASSERT_ENABLED=1, but only
NDEBUG was forwarded to the importer. Because of this, PlatformEnable.h
derived ASSERT_ENABLED as 0 for the importer. ASSERT_ENABLED controls data
members in refcounted classes, so C++ and the importer ended up with different
layouts for the same objects:

                                            C++ TUs   importer
  ASSERT_ENABLED                                  1          0
  CHECK_REF_COUNTED_LIFECYCLE                     1          0
  ENABLE_REFTRACKER                               1          0
  sizeof(RefCountedBase)                         12          4
  sizeof(WebBackForwardListMessageForwarder)     48         32

As a result, the createFromWeak() generated by the importer allocated 32 bytes
for an object that needs 48 bytes. It also compiled adoptRef() without the
adopted() call, leaving m_adoptionIsRequired set.

Adding ASSERT_ENABLED to the hand-written list would fix this particular
crash, but it would not be future-proof, as any other preprocessor definition
would still be lost in the same way.

Fix this by adding _webkit_cxx_preprocessor_definitions(), which obtains the
definitions from the same places used by the C++ compilation: the
COMPILE_DEFINITIONS directory property, CMAKE_CXX_FLAGS and
CMAKE_CXX_FLAGS_<CONFIG>.

The flags are parsed with separate_arguments() so definitions with quoted
values are handled correctly. Definitions from CMAKE_CXX_FLAGS are added last,
matching the order in the real compiler command and allowing definitions from
CXXFLAGS to override directory definitions.

Finally, this enables the Swift features again by default on GTK and WPE,
reverting the workaround from 318624@main that disabled them because the
bots build Release+Asserts and were hitting these crashes after switching
the bots to use Clang instead of GCC at 318539@main.

* Source/cmake/WebKitFeatures.cmake:
* Source/cmake/WebKitMacros.cmake:

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Canonical link: https://commits.webkit.org/318749@main



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications

Reply via email to