Skip to content

[Clang] Segmentation fault when Building WebKitGTK with Thin LTO and mold #143539

Open
@zyxhere

Description

@zyxhere

Hello I have been getting Segmentation faults when building WebKit with both clang-19.1.7 and 20.1.6

Steps to reproduce:

  • wget https://webkitgtk.org/releases/webkitgtk-2.48.3.tar.xz
  • tar xf webkit*
  • export CC="/usr/lib/llvm/20/bin/clang"
  • export CXX="/usr/lib/llvm/20/bin/clang++"
  • export CPP="/usr/lib/llvm/20/bin/clang-cpp"
  • export LD="ld.mold"
  • cd webkit* && mkdir build && cd build
  • export CFLAGS="-march=x86-64-v3 -flto=thin -fomit-frame-pointer -ftrivial-auto-var-init=zero -Werror=format-security"
  • export CXXFLAGS="$CFLAGS"
  • export LDFLAGS="-Wl,-O1 -Wl,--as-needed -Wl,-z,pack-relative-relocs -flto=thin -fuse-ld=mold"
  • ulimit -n 65536 # this is to avoid Potenial fd leak with clang lto and cause too many open files rui314/mold#1362
cmake .. -DPORT=GTK -DCMAKE_BUILD_TYPE=RelWithDebInfo -G Ninja -DENABLE_API_TESTS=OFF  \
-DENABLE_BUBBLEWRAP_SANDBOX=yes -DENABLE_DRAG_SUPPORT=OFF -DENABLE_GAMEPAD=no \
-DENABLE_GEOLOCATION=ON -DENABLE_MINIBROWSER=no -DENABLE_PDFJS=no \
-DENABLE_SPEECH_SYNTHESIS=OFF -DENABLE_SPELLCHECK=OFF -DENABLE_TOUCH_EVENTS=ON \
-DENABLE_UNIFIED_BUILDS=yes -DENABLE_VIDEO=yes -DENABLE_WEB_AUDIO=yes \
-DENABLE_WEB_CODECS=yes -DENABLE_WEBDRIVER=ON -DENABLE_WEBGL=ON -DUSE_AVIF=yes \
-DUSE_GSTREAMER_WEBRTC=yes -DUSE_GSTREAMER_TRANSCODER=yes -DENABLE_DOCUMENTATION=OFF \
-DENABLE_INTROSPECTION=yes -DENABLE_JOURNALD_LOG=no -DENABLE_QUARTZ_TARGET=no \
-DENABLE_WAYLAND_TARGET=yes -DENABLE_X11_TARGET=no -DUSE_GBM=ON -DUSE_GTK4=ON \
-DUSE_JPEGXL=No -DUSE_LCMS=NO -DUSE_LIBBACKTRACE=OFF -DUSE_LIBDRM=ON -DUSE_LIBHYPHEN=ON \
-DUSE_LIBSECRET=yes -DUSE_SOUP2=OFF -DUSE_SYSPROF_CAPTURE=OFF -DUSE_WOFF2=ON \
-DCMAKE_BUILD_TYPE=RelWithDebInfo
  • ninja -v -j6

Error:

[8202/8211] : && /usr/lib/llvm/20/bin/clang++ -fPIC -fdiagnostics-color=always -fcolor-diagnostics -Wextra -Wall -Werror=undefined-internal -Werror=undefined-inline -pipe -Wno-noexcept-type -Wno-psabi -Wno-misleading-indentation -Wno-parentheses-equality -Qunused-arguments -Wundef -Wpointer-arith -Wmissing-format-attribute -Wformat-security -Wcast-align -Wno-tautological-compare -fasynchronous-unwind-tables -fdebug-types-section -march=x86-64-v3 -flto=thin -fomit-frame-pointer -ftrivial-auto-var-init=zero -Werror=format-security -fno-strict-aliasing -fno-exceptions -fno-rtti -fcoroutines -ffunction-sections -fdata-sections -O2 -g -DNDEBUG  -Wl,--no-undefined -Wl,-O1 -Wl,--as-needed -Wl,-z,pack-relative-relocs -flto=thin -fuse-ld=mold -Wl,--gc-sections -Wl,--disable-new-dtags   -Wl,--version-script,/home/user/Documents/src/webkitgtk-2.48.3/Source/WebKit/webkitglib-symbols.map -shared -Wl,-soname,libwebkitgtk-6.0.so.4 -o lib/libwebkitgtk-6.0.so.4.11.8 @CMakeFiles/WebKit.rsp && :
clang++: error: unable to execute command: Segmentation fault
clang++: error: linker command failed due to signal (use -v to see invocation)`

System:
Gentoo Linux
Kernel 6.12.31
Using musl-1.2.5 instead of glibc

It takes hours to build llvm and WebKit on my laptop so I probably won't be able to get more logs (as I didn't build clang with debug symbols) until the weekend. The issue is very reproducible for me so I opened this here first

Metadata

Metadata

Assignees

No one assigned

    Labels

    LTOLink time optimization (regular/full LTO or ThinLTO)crashPrefer [crash-on-valid] or [crash-on-invalid]needs-reductionLarge reproducer that should be reduced into a simpler form

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions