Bug 239036 - WebKit-GTK 2.36.0 fails to build with Webassembly/JIT disabled
Summary: WebKit-GTK 2.36.0 fails to build with Webassembly/JIT disabled
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: WebKit Local Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-04-09 11:56 PDT by dave
Modified: 2022-04-10 06:06 PDT (History)
0 users

See Also:


Attachments
Add a missing system include needed for debug build (332 bytes, patch)
2022-04-09 11:57 PDT, dave
no flags Details | Formatted Diff | Diff
Fix building with accessibility disabled (1.03 KB, patch)
2022-04-09 11:57 PDT, dave
no flags Details | Formatted Diff | Diff
broken patch; obsolete (1.63 KB, patch)
2022-04-09 11:58 PDT, dave
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description dave 2022-04-09 11:56:08 PDT
This is in relation to another bug which I have not filed because at this time I don't have any kind of usable backtrace, or knowledge of how to generate one. That bug started when I moved my hard drive with existing Linux install from an AMD Ryzen system to an older AMD desktop, because the CPU is apparently going bad in the former. Everything continued to work flawlessly, except for WebKit, which started crashing on a certain web site. After compiling a debug build and connecting to WebKitWebProcess with gdb to observe the crash, it was triggering a SIGILL "Illegal Instruction" exception.

The backtrace was totally worthless as it was just a long string of memory addresses with no function names, and after looking up one of the functions that was actually named, it appears the crash may be in code that was generated by JIT--which makes sense as it appears to be triggered when certain Javascript on the page executes. 

So I tried to compile a version of WebKit with webassembly disabled, to hopefully work around the bug as I need this browser working ASAP. I did this by patching ./Source/cmake/WebKitFeatures.cmake to set the default WebAssembly/JIT options under "if (WTF_CPU_ARM64 OR WTF_CPU_X86_64)" to be the same as in the final "else" clause down at the bottom, which would be used in the event of a 32-bit compile; i.e. JIT disabled and C-LOOP enabled. 

With this setting, now there is an error with missing symbols when linking JavaScriptCore. Specifically the (worthless) output from Gold linker:

/usr/bin/ld: /sources/stage4/webkitgtk-2.36.0/build/lib/libjavascriptcoregtk-4.1.so: undefined reference to `JSC::JSCell::inherits(JSC::VM&, JSC::ClassInfo const*) const'
/usr/bin/ld: /sources/stage4/webkitgtk-2.36.0/build/lib/libjavascriptcoregtk-4.1.so: undefined reference to `JSC::HeapCell::vm() const'
/usr/bin/ld: /sources/stage4/webkitgtk-2.36.0/build/lib/libjavascriptcoregtk-4.1.so: undefined reference to `JSC::JSCell::structure() const'
collect2: error: ld returned 1 exit status

The output from BFD linker is much more detailed, showing exact source files etc, but is almost impossible for me to decipher as the problem seems to be some kind of macro/template issue that isn't at all obvious.

Now at this point if you'll permit me to rant: EVERY TIME I upgrade to a new WebKit version, it never is a smooth process. NEVER. It always involves hours of compiling mixed with writing numerous patches to fix compile errors which are caused by my configuration being not exactly the same config as you use in house. It's almost like you NEVER test compile WebKit in different configurations before shipping it out. 

2.36.0 has actually been better than usual in this regard, but so far I've had to write three patches just to get it to compile a) in debug mode; b) with accessibility disabled, because I don't use dbus; and now a patch in process, c) to fix building with WebAssembly/JIT disabled. (See attachments in comments below.) I've hit a stumbling block on that last patch due to this crazy missing symbol error which I'm at my wits' end trying to figure out. 

Could you PLEASE expand your testing of WebKit under various build configurations before shipping it out the door, so the end user doesn't have to apply 3-5+ different, ever changing patches each upgrade cycle just to get it to build in non-default configuration? I don't understand this huge, complicated code base well enough to always be having to write patches just to do something that should be easy and simple, like building with JIT disabled. And in the mean time my WebKit browser is useless until I can somehow get this problem figured out! Infuriating.
Comment 1 dave 2022-04-09 11:57:01 PDT
Created attachment 457175 [details]
Add a missing system include needed for debug build
Comment 2 dave 2022-04-09 11:57:42 PDT
Created attachment 457176 [details]
Fix building with accessibility disabled
Comment 3 dave 2022-04-09 11:58:35 PDT
Created attachment 457177 [details]
broken patch; obsolete
Comment 4 dave 2022-04-09 11:59:08 PDT
Patches enclosed; copyright disclaimed; do whatever you want with them.
Comment 5 dave 2022-04-09 12:06:43 PDT
More information--here's the full error output from BFD when linking JavaScriptCore:


[ 26%] Linking CXX shared library ../../lib/libjavascriptcoregtk-4.1.so
/usr/bin/ld: CMakeFiles/JavaScriptCore.dir/dfg/DFGCapabilities.cpp.o: in function `JSC::DFG::capabilityLevel(JSC::CodeBlock*)':
/sources/stage4/webkitgtk-2.36.0/build/Source/JavaScriptCore/../../../Source/JavaScriptCore/runtime/WriteBarrier.h:59: undefined reference to `JSC::JSCell::structure() const'
/usr/bin/ld: /sources/stage4/webkitgtk-2.36.0/build/Source/JavaScriptCore/../../../Source/JavaScriptCore/runtime/WriteBarrier.h:59: undefined reference to `JSC::JSCell::structure() const'
/usr/bin/ld: /sources/stage4/webkitgtk-2.36.0/build/Source/JavaScriptCore/../../../Source/JavaScriptCore/runtime/WriteBarrier.h:59: undefined reference to `JSC::JSCell::structure() const'
/usr/bin/ld: /sources/stage4/webkitgtk-2.36.0/build/Source/JavaScriptCore/../../../Source/JavaScriptCore/runtime/WriteBarrier.h:59: undefined reference to `JSC::JSCell::structure() const'
/usr/bin/ld: /sources/stage4/webkitgtk-2.36.0/build/Source/JavaScriptCore/../../../Source/JavaScriptCore/runtime/WriteBarrier.h:59: undefined reference to `JSC::JSCell::structure() const'
/usr/bin/ld: /sources/stage4/webkitgtk-2.36.0/build/Source/JavaScriptCore/../../../Source/JavaScriptCore/runtime/WriteBarrier.h:59: undefined reference to `JSC::HeapCell::vm() const'
/usr/bin/ld: /sources/stage4/webkitgtk-2.36.0/build/Source/JavaScriptCore/../../../Source/JavaScriptCore/runtime/WriteBarrier.h:59: undefined reference to `JSC::JSCell::inherits(JSC::VM&, JSC::ClassInfo const*) const'
/usr/bin/ld: CMakeFiles/JavaScriptCore.dir/jit/JITDisassembler.cpp.o: in function `JSC::JITDisassembler::JITDisassembler(JSC::CodeBlock*)':
/sources/stage4/webkitgtk-2.36.0/build/Source/JavaScriptCore/../../../Source/JavaScriptCore/runtime/WriteBarrier.h:59: undefined reference to `JSC::JSCell::structure() const'
/usr/bin/ld: /sources/stage4/webkitgtk-2.36.0/build/Source/JavaScriptCore/../../../Source/JavaScriptCore/runtime/WriteBarrier.h:59: undefined reference to `JSC::JSCell::structure() const'
/usr/bin/ld: /sources/stage4/webkitgtk-2.36.0/build/Source/JavaScriptCore/../../../Source/JavaScriptCore/runtime/WriteBarrier.h:59: undefined reference to `JSC::JSCell::structure() const'
/usr/bin/ld: /sources/stage4/webkitgtk-2.36.0/build/Source/JavaScriptCore/../../../Source/JavaScriptCore/runtime/WriteBarrier.h:59: undefined reference to `JSC::JSCell::structure() const'
/usr/bin/ld: /sources/stage4/webkitgtk-2.36.0/build/Source/JavaScriptCore/../../../Source/JavaScriptCore/runtime/WriteBarrier.h:59: undefined reference to `JSC::JSCell::structure() const'
/usr/bin/ld: /sources/stage4/webkitgtk-2.36.0/build/Source/JavaScriptCore/../../../Source/JavaScriptCore/runtime/WriteBarrier.h:59: undefined reference to `JSC::HeapCell::vm() const'
/usr/bin/ld: /sources/stage4/webkitgtk-2.36.0/build/Source/JavaScriptCore/../../../Source/JavaScriptCore/runtime/WriteBarrier.h:59: undefined reference to `JSC::JSCell::inherits(JSC::VM&, JSC::ClassInfo const*) const'
/usr/bin/ld: /sources/stage4/webkitgtk-2.36.0/build/Source/JavaScriptCore/../../../Source/JavaScriptCore/runtime/WriteBarrier.h:59: undefined reference to `JSC::JSCell::structure() const'
/usr/bin/ld: /sources/stage4/webkitgtk-2.36.0/build/Source/JavaScriptCore/../../../Source/JavaScriptCore/runtime/WriteBarrier.h:59: undefined reference to `JSC::JSCell::structure() const'
/usr/bin/ld: /sources/stage4/webkitgtk-2.36.0/build/Source/JavaScriptCore/../../../Source/JavaScriptCore/runtime/WriteBarrier.h:59: undefined reference to `JSC::JSCell::structure() const'
/usr/bin/ld: /sources/stage4/webkitgtk-2.36.0/build/Source/JavaScriptCore/../../../Source/JavaScriptCore/runtime/WriteBarrier.h:59: undefined reference to `JSC::JSCell::structure() const'
/usr/bin/ld: /sources/stage4/webkitgtk-2.36.0/build/Source/JavaScriptCore/../../../Source/JavaScriptCore/runtime/WriteBarrier.h:59: undefined reference to `JSC::JSCell::structure() const'
/usr/bin/ld: /sources/stage4/webkitgtk-2.36.0/build/Source/JavaScriptCore/../../../Source/JavaScriptCore/runtime/WriteBarrier.h:59: undefined reference to `JSC::HeapCell::vm() const'
/usr/bin/ld: /sources/stage4/webkitgtk-2.36.0/build/Source/JavaScriptCore/../../../Source/JavaScriptCore/runtime/WriteBarrier.h:59: undefined reference to `JSC::JSCell::inherits(JSC::VM&, JSC::ClassInfo const*) const'
/usr/bin/ld: CMakeFiles/JavaScriptCore.dir/jit/JITDisassembler.cpp.o: in function `JSC::JITDisassembler::dumpHeader(WTF::PrintStream&, JSC::LinkBuffer&)':
/sources/stage4/webkitgtk-2.36.0/build/Source/JavaScriptCore/../../../Source/JavaScriptCore/runtime/WriteBarrier.h:59: undefined reference to `JSC::JSCell::structure() const'
/usr/bin/ld: /sources/stage4/webkitgtk-2.36.0/build/Source/JavaScriptCore/../../../Source/JavaScriptCore/runtime/WriteBarrier.h:59: undefined reference to `JSC::JSCell::structure() const'
/usr/bin/ld: /sources/stage4/webkitgtk-2.36.0/build/Source/JavaScriptCore/../../../Source/JavaScriptCore/runtime/WriteBarrier.h:59: undefined reference to `JSC::JSCell::structure() const'
/usr/bin/ld: /sources/stage4/webkitgtk-2.36.0/build/Source/JavaScriptCore/../../../Source/JavaScriptCore/runtime/WriteBarrier.h:59: undefined reference to `JSC::JSCell::structure() const'
/usr/bin/ld: /sources/stage4/webkitgtk-2.36.0/build/Source/JavaScriptCore/../../../Source/JavaScriptCore/runtime/WriteBarrier.h:59: undefined reference to `JSC::JSCell::structure() const'
/usr/bin/ld: /sources/stage4/webkitgtk-2.36.0/build/Source/JavaScriptCore/../../../Source/JavaScriptCore/runtime/WriteBarrier.h:59: undefined reference to `JSC::HeapCell::vm() const'
/usr/bin/ld: /sources/stage4/webkitgtk-2.36.0/build/Source/JavaScriptCore/../../../Source/JavaScriptCore/runtime/WriteBarrier.h:59: undefined reference to `JSC::JSCell::inherits(JSC::VM&, JSC::ClassInfo const*) const'
/usr/bin/ld: CMakeFiles/JavaScriptCore.dir/jit/JITPlan.cpp.o: in function `JSC::JITPlan::compileInThread(JSC::JITWorklistThread*)':
/sources/stage4/webkitgtk-2.36.0/build/Source/JavaScriptCore/../../../Source/JavaScriptCore/runtime/WriteBarrier.h:59: undefined reference to `JSC::JSCell::structure() const'
/usr/bin/ld: /sources/stage4/webkitgtk-2.36.0/build/Source/JavaScriptCore/../../../Source/JavaScriptCore/runtime/WriteBarrier.h:59: undefined reference to `JSC::JSCell::structure() const'
/usr/bin/ld: /sources/stage4/webkitgtk-2.36.0/build/Source/JavaScriptCore/../../../Source/JavaScriptCore/runtime/WriteBarrier.h:59: undefined reference to `JSC::JSCell::structure() const'
/usr/bin/ld: /sources/stage4/webkitgtk-2.36.0/build/Source/JavaScriptCore/../../../Source/JavaScriptCore/runtime/WriteBarrier.h:59: undefined reference to `JSC::JSCell::structure() const'
/usr/bin/ld: /sources/stage4/webkitgtk-2.36.0/build/Source/JavaScriptCore/../../../Source/JavaScriptCore/runtime/WriteBarrier.h:59: undefined reference to `JSC::JSCell::structure() const'
/usr/bin/ld: /sources/stage4/webkitgtk-2.36.0/build/Source/JavaScriptCore/../../../Source/JavaScriptCore/runtime/WriteBarrier.h:59: undefined reference to `JSC::JSCell::inherits(JSC::VM&, JSC::ClassInfo const*) const'
/usr/bin/ld: CMakeFiles/JavaScriptCore.dir/llint/LLIntEntrypoint.cpp.o: in function `JSC::LLInt::setFunctionEntrypoint(JSC::CodeBlock*)':
/sources/stage4/webkitgtk-2.36.0/build/Source/JavaScriptCore/../../../Source/JavaScriptCore/runtime/WriteBarrier.h:59: undefined reference to `JSC::JSCell::structure() const'
/usr/bin/ld: /sources/stage4/webkitgtk-2.36.0/build/Source/JavaScriptCore/../../../Source/JavaScriptCore/runtime/WriteBarrier.h:59: undefined reference to `JSC::JSCell::structure() const'
/usr/bin/ld: /sources/stage4/webkitgtk-2.36.0/build/Source/JavaScriptCore/../../../Source/JavaScriptCore/runtime/WriteBarrier.h:59: undefined reference to `JSC::JSCell::structure() const'
/usr/bin/ld: /sources/stage4/webkitgtk-2.36.0/build/Source/JavaScriptCore/../../../Source/JavaScriptCore/runtime/WriteBarrier.h:59: undefined reference to `JSC::JSCell::structure() const'
/usr/bin/ld: /sources/stage4/webkitgtk-2.36.0/build/Source/JavaScriptCore/../../../Source/JavaScriptCore/runtime/WriteBarrier.h:59: undefined reference to `JSC::JSCell::structure() const'
/usr/bin/ld: /sources/stage4/webkitgtk-2.36.0/build/Source/JavaScriptCore/../../../Source/JavaScriptCore/runtime/WriteBarrier.h:59: undefined reference to `JSC::JSCell::inherits(JSC::VM&, JSC::ClassInfo const*) const'
/usr/bin/ld: CMakeFiles/JavaScriptCore.dir/llint/LLIntEntrypoint.cpp.o: in function `JSC::LLInt::setEntrypoint(JSC::CodeBlock*)':
/sources/stage4/webkitgtk-2.36.0/build/Source/JavaScriptCore/../../../Source/JavaScriptCore/runtime/WriteBarrier.h:59: undefined reference to `JSC::JSCell::structure() const'
/usr/bin/ld: /sources/stage4/webkitgtk-2.36.0/build/Source/JavaScriptCore/../../../Source/JavaScriptCore/runtime/WriteBarrier.h:59: undefined reference to `JSC::JSCell::structure() const'
/usr/bin/ld: /sources/stage4/webkitgtk-2.36.0/build/Source/JavaScriptCore/../../../Source/JavaScriptCore/runtime/WriteBarrier.h:59: undefined reference to `JSC::JSCell::structure() const'
/usr/bin/ld: /sources/stage4/webkitgtk-2.36.0/build/Source/JavaScriptCore/../../../Source/JavaScriptCore/runtime/WriteBarrier.h:59: undefined reference to `JSC::JSCell::structure() const'
/usr/bin/ld: /sources/stage4/webkitgtk-2.36.0/build/Source/JavaScriptCore/../../../Source/JavaScriptCore/runtime/WriteBarrier.h:59: undefined reference to `JSC::JSCell::structure() const'
/usr/bin/ld: /sources/stage4/webkitgtk-2.36.0/build/Source/JavaScriptCore/../../../Source/JavaScriptCore/runtime/WriteBarrier.h:59: undefined reference to `JSC::JSCell::inherits(JSC::VM&, JSC::ClassInfo const*) const'
/usr/bin/ld: CMakeFiles/JavaScriptCore.dir/runtime/FileBasedFuzzerAgentBase.cpp.o: in function `JSC::FileBasedFuzzerAgentBase::getPrediction(JSC::CodeBlock*, JSC::CodeOrigin const&, unsigned long)':
/sources/stage4/webkitgtk-2.36.0/build/Source/JavaScriptCore/../../../Source/JavaScriptCore/runtime/WriteBarrier.h:59: undefined reference to `JSC::JSCell::structure() const'
/usr/bin/ld: /sources/stage4/webkitgtk-2.36.0/build/Source/JavaScriptCore/../../../Source/JavaScriptCore/runtime/WriteBarrier.h:59: undefined reference to `JSC::JSCell::structure() const'
/usr/bin/ld: /sources/stage4/webkitgtk-2.36.0/build/Source/JavaScriptCore/../../../Source/JavaScriptCore/runtime/WriteBarrier.h:59: undefined reference to `JSC::JSCell::structure() const'
/usr/bin/ld: /sources/stage4/webkitgtk-2.36.0/build/Source/JavaScriptCore/../../../Source/JavaScriptCore/runtime/WriteBarrier.h:59: undefined reference to `JSC::JSCell::structure() const'
/usr/bin/ld: /sources/stage4/webkitgtk-2.36.0/build/Source/JavaScriptCore/../../../Source/JavaScriptCore/runtime/WriteBarrier.h:59: undefined reference to `JSC::JSCell::structure() const'
/usr/bin/ld: /sources/stage4/webkitgtk-2.36.0/build/Source/JavaScriptCore/../../../Source/JavaScriptCore/runtime/WriteBarrier.h:59: undefined reference to `JSC::HeapCell::vm() const'
/usr/bin/ld: /sources/stage4/webkitgtk-2.36.0/build/Source/JavaScriptCore/../../../Source/JavaScriptCore/runtime/WriteBarrier.h:59: undefined reference to `JSC::JSCell::inherits(JSC::VM&, JSC::ClassInfo const*) const'
collect2: error: ld returned 1 exit status
make[2]: *** [Source/JavaScriptCore/CMakeFiles/JavaScriptCore.dir/build.make:19673: lib/libjavascriptcoregtk-4.1.so.0.1.4] Error 1
make[1]: *** [CMakeFiles/Makefile2:873: Source/JavaScriptCore/CMakeFiles/JavaScriptCore.dir/all] Error 2
make: *** [Makefile:156: all] Error 2
Comment 6 dave 2022-04-10 06:05:29 PDT
OK--after much head banging against the wall, I got this figured out. 

First off, all those link errors were due to my faulty/incomplete patch, which was an attempt to fix various compile errors when disabling WebAssembly. I didn't know in the beginning that just setting WEBKIT_ENABLE_WEBASSEMBLY=OFF isn't enough to properly disable it. After patching /Source/cmake/WebKitFeatures.cmake as described above to set the 5-6 different flags the same as the 32-bit build, and removing the faulty patch, that successfully builds WebKit with JIT disabled.

But it turns out I didn't even have to do that at all. How's this for a kick in the nuts: 

Turns out my two browsers were both linking to webkit2gtk-4.0, not -4.1. This change of course came about when libsoup3 was introduced. So this whole time I've been linking to and using the old webkit 2.32.x, even when I thought I'd long since upgraded to 2.34.x, and then to 2.36.x; and also explaining why the Debug build wouldn't give a usable backtrace.

With JIT fully enabled and just the "Debug build fix" and "accessibility disabled" patches applied, WebKit 2.36.0 builds and works just fine on the web site where 2.32.0 was crashing. So whatever the JIT bug was in 2.32.x, it's already been patched out. Meanwhile I've been unknowingly stuck on an old WebKit version, and presumably would have continued to be stuck there for a few more upgrade cycles until finally discovering the API change...and probably wondering the whole time why the hell none of these supposed fixes and upgrades in each version were taking effect.

SMH...