When investigating why WebKitGTK fails to build with LTO (link-time optimization) enabled, one of the GCC developers noticed that we are missing __attribute__ (("used")) on several C++ functions declared in LLIntSlowPaths.h and WasmSlowPaths.h that are called only from asm. Without this attribute, GCC assumes the functions are unused and drops them, then linking fails because they really are used. Turns out, this is the *only* problem that prevents building WebKit with LTO, so this patch should allow distros like Fedora and SUSE to drop downstream workarounds to turn off LTO. To test building with LTO, I used -DCMAKE_C_FLAGS="-flto=auto -ffat-lto-objects" -DCMAKE_CXX_FLAGS="-flto=auto -ffat-lto-objects" with GCC. Note that is GCC-specific. Clang uses "-flto" instead, simpler.
(In reply to Michael Catanzaro from comment #0) > Turns out, this is the *only* problem that prevents building WebKit with > LTO, so this patch should allow distros like Fedora and SUSE to drop > downstream workarounds to turn off LTO. Oh, well I'm actually getting an ld.gold internal error as well. Workaround for that is -DUSE_LD_GOLD=OFF. We might want to get rid of ld.gold anyway since it's no longer well-maintained.
Created attachment 435072 [details] Patch
Comment on attachment 435072 [details] Patch Nice find. I think the patch is correct 😉
Comment on attachment 435072 [details] Patch r=me
Committed r280770 (240354@main): <https://commits.webkit.org/240354@main> All reviewed patches have been landed. Closing bug and clearing flags on attachment 435072 [details].
<rdar://problem/81689158>
(In reply to Michael Catanzaro from comment #0) > To test building with LTO, I used -DCMAKE_C_FLAGS="-flto=auto > -ffat-lto-objects" -DCMAKE_CXX_FLAGS="-flto=auto -ffat-lto-objects" with > GCC. Note that is GCC-specific. Clang uses "-flto" instead, simpler. Correction: according to https://fedoraproject.org/wiki/Changes/LTOBuildImprovements#Detailed_Description actually do not want to use -ffat-lto-objects because we don't install any .o or .a files. Huh.
*** Bug 202346 has been marked as a duplicate of this bug. ***