Bug 249368 - REGRESSION(257515@main): breaks build with -flto=auto
Summary: REGRESSION(257515@main): breaks build with -flto=auto
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKitGTK (show other bugs)
Version: WebKit Nightly Build
Hardware: PC Unspecified
: P2 Normal
Assignee: Adrian Perez
URL:
Keywords:
: 249983 (view as bug list)
Depends on:
Blocks:
 
Reported: 2022-12-14 19:49 PST by Michael Catanzaro
Modified: 2023-03-16 01:16 PDT (History)
10 users (show)

See Also:


Attachments
Suspicious, ugly patch (1.63 KB, patch)
2023-03-14 14:45 PDT, Adrian Perez
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Catanzaro 2022-12-14 19:49:58 PST
WebKitGTK 2.39.3 fails to link lib/libwebkitgtk-6.0.so.0.0.0 with -flto=auto. The rror message is:

lto1: fatal error: missing resolution data for _ZTVN7WebCore17SpeechRecognitionE

I had no clue what this error message meant, and there seem to be zero relevant search results on the internet, and also zero changes to Speech Recognition code between 2.39.2 and 2.39.3. So I bisected it and found the first bad commit is 257515@main "[JSC] Clean up Structure transition watchpoint firing to pave a way to faster / cheap adaptive watchpoint" which makes no sense.

This result is so weird that I will double check the results of my bisect tomorrow, just to be certain. My checkout is on 257514@main right now and it builds fine, so I will test 257515@main again.

I wonder if there might be a toolchain bug here.
Comment 1 Michael Catanzaro 2022-12-15 07:25:54 PST
(In reply to Michael Catanzaro from comment #0)
> This result is so weird that I will double check the results of my bisect
> tomorrow, just to be certain.

It's true. This is definitely somehow caused by 257515@main "[JSC] Clean up Structure transition watchpoint firing to pave a way to faster / cheap adaptive watchpoint"
Comment 2 Michael Catanzaro 2022-12-15 13:52:15 PST
I decided to just disable LTO and move on.
Comment 3 Fujii Hironori 2023-01-02 04:11:22 PST
*** Bug 249983 has been marked as a duplicate of this bug. ***
Comment 4 Michael Catanzaro 2023-01-10 09:57:37 PST
GCC bug report: https://bugzilla.redhat.com/show_bug.cgi?id=2159783
Comment 5 Fabian Bornschein 2023-01-17 02:02:16 PST
For WebKitGTK 2.39.4 I was able to build with LTO, by using mold as linker.

Toolchain in use: (Arch Linux)
linux-api-headers 5.18.15
binutils 2.39
gcc 12.2.0
glibc 2.36
Comment 6 Adrian Perez 2023-03-14 14:45:07 PDT
Created attachment 465438 [details]
Suspicious, ugly patch

I have been able to get a build of 2.39.91 with LTO using the BFD linker
applying this patch; I have to try and see if I can shuffle things around
to 1.) make it palatable for review, and 2.) keep the linker happy.
Comment 7 Adrian Perez 2023-03-15 03:12:34 PDT
More fun... I cannot easily reproduce the build failure on my build box
with the following CMake incantation:

  CC=gcc CXX=g++ \
  LDFLAGS='-flto=auto -fuse-ld=bfd'
  CFLAGS='-flto=auto' CXXFLAGS='-flto=auto' \
    cmake -S. -Bbuild-lto -DPORT=WPE -DCMAKE_BUILD_TYPE=Release -GNinja

That is using GCC 12.2.1 and Binutils 2.40; OTOH, it's 100% reproducible
doing Yocto from ToT, which has 11.3.0 and Binutils 2.38. Probably this
got fixed in the newer versions, but we need to support the ones from
Yocto because supported distros may have them as well.

It will be slower to try and make a proper fix having to do cross builds 🥴️
Comment 8 Adrian Perez 2023-03-15 10:33:07 PDT
Pull request: https://github.com/WebKit/WebKit/pull/11562
Comment 9 EWS 2023-03-15 18:06:34 PDT
Committed 261724@main (ee58c2ab8371): <https://commits.webkit.org/261724@main>

Reviewed commits have been landed. Closing PR #11562 and removing active labels.
Comment 10 Adrian Perez 2023-03-16 01:16:10 PDT
(In reply to EWS from comment #9)
> Committed 261724@main (ee58c2ab8371):
> <https://commits.webkit.org/261724@main>
> 
> Reviewed commits have been landed. Closing PR #11562 and removing active
> labels.

Also: backported into the 2.38 and 2.40 release branches 👍️