Skip to content

Commit 3c41f3f

Browse files
committed
[GCC][WPE] Building with LTO fails
https://bugs.webkit.org/show_bug.cgi?id=329015 Reviewed by Yusuke Suzuki. Building WPE with GCC and link-time optimization (LTO) fails in three places. I tested the fixes cross-building for ARM64 with GCC 13.4 and building natively for x86_64 with GCC 15.2. The first one is when linking JavaScriptCore: undefined reference to `slow_path_wasm_unwind_exception' undefined reference to `pinballHandlerImplantSlice' These functions, and the g_restoreFrameCalleeBoxed variable, are only used from the assembly that offlineasm generates, which GCC doesn't look at during LTO, so it drops them. They were just missing the REFERENCED_FROM_ASM (and WTF_INTERNAL) that the other functions called from offlineasm already have. The second one is when linking the WebKit library: lto1: fatal error: missing resolution data for _ZTVN7WebCore14VisualViewportE To check the vtable of the objects they wrap, the generated bindings declare the vtable of each class by its mangled name as an extern "C" array. That's undefined behaviour in C++, and GCC's LTO fails with it when the same file also has an inline constructor or destructor of the class, while the vtable is emitted in another file. See https://gcc.gnu.org/PR128194 Like 290697@main did for RTCDataChannel, move the constructors and destructor of the 13 classes that hit this to their .cpp files. The constructors of SVGNumberList, SVGPointList and SVGTransformList stay private, as the inherited ones were, because those classes are only created through create(). The third one is a crash of GCC 13.4: during GIMPLE pass: ccp Source/webrtc/call/call.cc: internal compiler error: Segmentation fault It's https://gcc.gnu.org/PR122620, fixed in GCC 13.5, 14.4 and 15.3, and it's triggered by the constructor of JitterEstimator once LTO inlines it into its callers. So for the GCC versions with that bug, the constructor is now marked noipa. It only runs when a video receive stream is created, so the cost is one extra function call per stream. * Source/JavaScriptCore/runtime/PinballCompletion.cpp: * Source/JavaScriptCore/wasm/WasmCallee.cpp: * Source/JavaScriptCore/wasm/WasmIPIntSlowPaths.h: * Source/JavaScriptCore/wasm/js/WebAssemblySuspending.cpp: * Source/ThirdParty/libwebrtc/Source/webrtc/video/timing/jitter_estimator.h: * Source/WebCore/Modules/WebGPU/GPUInternalError.cpp: (WebCore::GPUInternalError::GPUInternalError): * Source/WebCore/Modules/WebGPU/GPUInternalError.h: * Source/WebCore/Modules/WebGPU/GPUValidationError.cpp: (WebCore::GPUValidationError::GPUValidationError): * Source/WebCore/Modules/WebGPU/GPUValidationError.h: * Source/WebCore/Modules/screen-wake-lock/WakeLockSentinel.cpp: * Source/WebCore/Modules/screen-wake-lock/WakeLockSentinel.h: * Source/WebCore/Modules/webaudio/AudioParam.cpp: * Source/WebCore/Modules/webaudio/AudioParam.h: * Source/WebCore/animation/CSSAnimation.cpp: * Source/WebCore/animation/CSSAnimation.h: * Source/WebCore/animation/CustomEffect.cpp: * Source/WebCore/animation/CustomEffect.h: * Source/WebCore/html/canvas/Path2D.cpp: (WebCore::Path2D::Path2D): * Source/WebCore/html/canvas/Path2D.h: * Source/WebCore/html/closewatcher/CloseWatcher.cpp: * Source/WebCore/html/closewatcher/CloseWatcher.h: * Source/WebCore/html/track/TextTrackCueGeneric.cpp: * Source/WebCore/html/track/TextTrackCueGeneric.h: * Source/WebCore/page/VisualViewport.cpp: * Source/WebCore/page/VisualViewport.h: * Source/WebCore/svg/SVGNumberList.cpp: (WebCore::SVGNumberList::SVGNumberList): * Source/WebCore/svg/SVGNumberList.h: * Source/WebCore/svg/SVGPointList.cpp: (WebCore::SVGPointList::SVGPointList): * Source/WebCore/svg/SVGPointList.h: * Source/WebCore/svg/SVGTransformList.cpp: (WebCore::SVGTransformList::SVGTransformList): * Source/WebCore/svg/SVGTransformList.h: Canonical link: https://commits.webkit.org/324835@main
1 parent 88886f0 commit 3c41f3f

31 files changed

Lines changed: 141 additions & 38 deletions

‎Source/JavaScriptCore/runtime/PinballCompletion.cpp‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -143,12 +143,12 @@ WTF_ALLOW_UNSAFE_BUFFER_USAGE_BEGIN
143143
in offlineasm.
144144
*/
145145

146-
extern "C" void SYSV_ABI pinballHandlerInitContextForFulfill(JSGlobalObject*, CallFrame*, PinballHandlerContext*);
147-
extern "C" void SYSV_ABI pinballHandlerInitContextForReject(JSGlobalObject*, CallFrame*, PinballHandlerContext*);
148-
extern "C" void SYSV_ABI pinballHandlerImplantSlice(PinballHandlerContext*, Register*, CallFrame*, CallerFrameAndPC*);
149-
extern "C" UCPURegister SYSV_ABI pinballHandlerFulfillFunctionContinue(PinballHandlerContext*);
150-
extern "C" void SYSV_ABI pinballHandlerFinishReject(PinballHandlerContext*);
151-
extern "C" void SYSV_ABI pinballHandlerRejectWithStackOverflow(PinballHandlerContext*);
146+
extern "C" void SYSV_ABI pinballHandlerInitContextForFulfill(JSGlobalObject*, CallFrame*, PinballHandlerContext*) REFERENCED_FROM_ASM WTF_INTERNAL;
147+
extern "C" void SYSV_ABI pinballHandlerInitContextForReject(JSGlobalObject*, CallFrame*, PinballHandlerContext*) REFERENCED_FROM_ASM WTF_INTERNAL;
148+
extern "C" void SYSV_ABI pinballHandlerImplantSlice(PinballHandlerContext*, Register*, CallFrame*, CallerFrameAndPC*) REFERENCED_FROM_ASM WTF_INTERNAL;
149+
extern "C" UCPURegister SYSV_ABI pinballHandlerFulfillFunctionContinue(PinballHandlerContext*) REFERENCED_FROM_ASM WTF_INTERNAL;
150+
extern "C" void SYSV_ABI pinballHandlerFinishReject(PinballHandlerContext*) REFERENCED_FROM_ASM WTF_INTERNAL;
151+
extern "C" void SYSV_ABI pinballHandlerRejectWithStackOverflow(PinballHandlerContext*) REFERENCED_FROM_ASM WTF_INTERNAL;
152152

153153
void pinballHandlerInitContextForFulfill(JSGlobalObject* globalObject, CallFrame* callFrame, PinballHandlerContext* context)
154154
{

‎Source/JavaScriptCore/wasm/WasmCallee.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ WasmToJSCallee& WasmToJSCallee::singleton()
287287
return callee.get().get();
288288
}
289289

290-
EncodedJSValue g_restoreFrameCalleeBoxed { };
290+
REFERENCED_FROM_ASM EncodedJSValue g_restoreFrameCalleeBoxed { };
291291

292292
RestoreFrameCallee::RestoreFrameCallee()
293293
: Callee(Wasm::CompilationMode::RestoreFrameMode)

‎Source/JavaScriptCore/wasm/WasmIPIntSlowPaths.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ namespace IPInt {
4646

4747
extern "C" [[noreturn]] void SYSV_ABI wasm_log_crash(CallFrame*, JSWebAssemblyInstance* instance) REFERENCED_FROM_ASM WTF_INTERNAL;
4848
extern "C" UGPRPair SYSV_ABI slow_path_wasm_throw_exception(CallFrame*, JSWebAssemblyInstance* instance, Wasm::ExceptionType) REFERENCED_FROM_ASM WTF_INTERNAL;
49-
extern "C" UCPURegister SYSV_ABI slow_path_wasm_unwind_exception(CallFrame* callFrame, JSWebAssemblyInstance* instance);
49+
extern "C" UCPURegister SYSV_ABI slow_path_wasm_unwind_exception(CallFrame* callFrame, JSWebAssemblyInstance* instance) REFERENCED_FROM_ASM WTF_INTERNAL;
5050
extern "C" UGPRPair SYSV_ABI LEGACY_NODELETE slow_path_wasm_popcount(const void* pc, uint32_t) REFERENCED_FROM_ASM WTF_INTERNAL;
5151
extern "C" UGPRPair SYSV_ABI LEGACY_NODELETE slow_path_wasm_popcountll(const void* pc, uint64_t) REFERENCED_FROM_ASM WTF_INTERNAL;
5252

@@ -139,7 +139,7 @@ WASM_IPINT_EXTERN_CPP_HIDDEN_DECL(memory_atomic_wait64, IPIntStackEntry*);
139139
WASM_IPINT_EXTERN_CPP_HIDDEN_DECL(memory_atomic_notify, IPIntStackEntry*);
140140

141141
WASM_IPINT_EXTERN_CPP_HIDDEN_DECL(check_stack_and_vm_traps, void* candidateNewStackPointer, Wasm::IPIntCallee*, CallFrame*);
142-
WASM_IPINT_EXTERN_CPP_DECL(handle_debugger_trap_if_needed, CallFrame*, Register*);
142+
WASM_IPINT_EXTERN_CPP_HIDDEN_DECL(handle_debugger_trap_if_needed, CallFrame*, Register*);
143143

144144

145145
class FrameAccess {

‎Source/JavaScriptCore/wasm/js/WebAssemblySuspending.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ struct SlicerDriver {
8686
}
8787
};
8888

89-
extern "C" void* SYSV_ABI runWebAssemblySuspendingFunction(JSGlobalObject* globalObject, CallFrame* callFrame, CPURegister* originalCalleeSaves);
89+
extern "C" void* SYSV_ABI runWebAssemblySuspendingFunction(JSGlobalObject* globalObject, CallFrame* callFrame, CPURegister* originalCalleeSaves) REFERENCED_FROM_ASM WTF_INTERNAL;
9090

9191
// Executes when a function produced by the expression 'new WebAssembly.Suspending(wrappedFunction)'
9292
// is called. The initial entry point is the offlineasm function

‎Source/ThirdParty/libwebrtc/Source/webrtc/video/timing/jitter_estimator.h‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,14 @@ class JitterEstimator {
115115
std::optional<TimeDelta> nack_count_timeout = std::nullopt;
116116
};
117117

118+
#if defined(WEBRTC_WEBKIT_BUILD) && defined(__GNUC__) && !defined(__clang__) && \
119+
(__GNUC__ < 13 || (__GNUC__ == 13 && __GNUC_MINOR__ < 5) || \
120+
(__GNUC__ == 14 && __GNUC_MINOR__ < 4) || \
121+
(__GNUC__ == 15 && __GNUC_MINOR__ < 3))
122+
// GCC crashes (ICE) building with LTO when this constructor is inlined into its callers,
123+
// because of https://gcc.gnu.org/PR122620 which is fixed in GCC 13.5, 14.4, 15.3 and >=16
124+
__attribute__((noipa))
125+
#endif
118126
JitterEstimator(Clock* clock, const FieldTrialsView& field_trials);
119127
JitterEstimator(const JitterEstimator&) = delete;
120128
JitterEstimator& operator=(const JitterEstimator&) = delete;

‎Source/WebCore/Modules/WebGPU/GPUInternalError.cpp‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,18 @@
2828

2929
namespace WebCore {
3030

31+
GPUInternalError::GPUInternalError(String&& message)
32+
: m_message(WTF::move(message))
33+
{
34+
}
35+
36+
GPUInternalError::GPUInternalError(Ref<WebGPUInternalError>&& backing)
37+
: m_backing(WTF::move(backing))
38+
{
39+
}
40+
41+
GPUInternalError::~GPUInternalError() = default;
42+
3143
const String& GPUInternalError::message() const
3244
{
3345
if (m_backing)

‎Source/WebCore/Modules/WebGPU/GPUInternalError.h‎

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ class GPUInternalError final : public GPUError {
4545
return adoptRef(*new GPUInternalError(WTF::move(backing)));
4646
}
4747

48+
~GPUInternalError();
49+
4850
Type type() const final { return Type::Internal; }
4951
const String& LEGACY_NODELETE message() const LIFETIME_BOUND final;
5052

@@ -53,15 +55,8 @@ class GPUInternalError final : public GPUError {
5355
String stack() const { return "_"_s; }
5456

5557
private:
56-
GPUInternalError(String&& message)
57-
: m_message(WTF::move(message))
58-
{
59-
}
60-
61-
GPUInternalError(Ref<WebGPUInternalError>&& backing)
62-
: m_backing(WTF::move(backing))
63-
{
64-
}
58+
GPUInternalError(String&& message);
59+
GPUInternalError(Ref<WebGPUInternalError>&&);
6560

6661
String m_message;
6762
const RefPtr<WebGPUInternalError> m_backing;

‎Source/WebCore/Modules/WebGPU/GPUValidationError.cpp‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,18 @@
2828

2929
namespace WebCore {
3030

31+
GPUValidationError::GPUValidationError(String&& message)
32+
: m_message(WTF::move(message))
33+
{
34+
}
35+
36+
GPUValidationError::GPUValidationError(Ref<WebGPUValidationError>&& backing)
37+
: m_backing(WTF::move(backing))
38+
{
39+
}
40+
41+
GPUValidationError::~GPUValidationError() = default;
42+
3143
const String& GPUValidationError::message() const
3244
{
3345
if (m_backing)

‎Source/WebCore/Modules/WebGPU/GPUValidationError.h‎

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ class GPUValidationError final : public GPUError {
4545
return adoptRef(*new GPUValidationError(WTF::move(backing)));
4646
}
4747

48+
~GPUValidationError();
49+
4850
Type type() const final { return Type::Validation; }
4951
const String& LEGACY_NODELETE message() const LIFETIME_BOUND final;
5052

@@ -53,15 +55,8 @@ class GPUValidationError final : public GPUError {
5355
String stack() const { return "_"_s; }
5456

5557
private:
56-
GPUValidationError(String&& message)
57-
: m_message(WTF::move(message))
58-
{
59-
}
60-
61-
GPUValidationError(Ref<WebGPUValidationError>&& backing)
62-
: m_backing(WTF::move(backing))
63-
{
64-
}
58+
GPUValidationError(String&& message);
59+
GPUValidationError(Ref<WebGPUValidationError>&&);
6560

6661
String m_message;
6762
const RefPtr<WebGPUValidationError> m_backing;

‎Source/WebCore/Modules/screen-wake-lock/WakeLockSentinel.cpp‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ WakeLockSentinel::WakeLockSentinel(Document& document, WakeLockType type)
4747
{
4848
}
4949

50+
WakeLockSentinel::~WakeLockSentinel() = default;
51+
5052
void WakeLockSentinel::release(Ref<DeferredPromise>&& promise)
5153
{
5254
if (!m_wasReleased) {

0 commit comments

Comments
 (0)