Skip to content

[CMake] Pack relative relocations when supported - #77413

Open
TingPing wants to merge 1 commit into
WebKit:mainfrom
TingPing:pgriffis/pack-relative-relocs
Open

TingPing wants to merge 1 commit into
WebKit:mainfrom
TingPing:pgriffis/pack-relative-relocs

Conversation

@TingPing

@TingPing TingPing commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

e61c0ca

[CMake] Pack relative relocations when supported
https://bugs.webkit.org/show_bug.cgi?id=327969

Reviewed by NOBODY (OOPS!).

Most of the dynamic relocations of the WebKit libraries are relative ones, and
every process reads all of them when it starts. Link with
-z pack-relative-relocs, which stores them in the much smaller DT_RELR format,
when the toolchain and the C library support it.

On WPE, the relocations of libWPEWebKit go from 8.1 MB to 2 MB, the library is
6 MB smaller, and the total PSS of the UI, Web and Network processes is about
7.5 MB lower.

* Source/cmake/OptionsCommon.cmake:

e61c0ca

Misc iOS, visionOS, tvOS & watchOS macOS Linux Windows
✅ 🧪 style ✅ 🛠 ios ✅ 🛠 mac ✅ 🛠 wpe ✅ 🛠 win
✅ 🛠 ios-sim ✅ 🛠 mac-AS-debug ✅ 🧪 wpe-wk2 ✅ 🧪 win-tests
✅ 🧪 webkitperl ✅ 🧪 ios-wk2 ✅ 🧪 api-mac ✅ 🧪 api-wpe
✅ 🧪 ios-wk2-wpt ⏳ 🧪 api-mac-debug ✅ 🧪 jsc-wpe
✅ 🧪 jsc-x86-64 ✅ 🧪 api-ios ✅ 🧪 mac-wk2 ✅ 🛠 gtk3-gcc
✅ 🛠 🧪 jsc-debug-arm64 ✅ 🧪 mac-AS-debug-wk2 ✅ 🛠 gtk
✅ 🛠 vision ✅ 🧪 gtk-wk2
✅ 🛠 vision-sim ⏳ 🧪 mac-intel-wk2 ✅ 🧪 api-gtk
✅ 🧪 vision-wk2 ✅ 🛠 playstation
✅ 🛠 tv ✅ 🧪 mac-site-isolation
✅ 🛠 tv-sim
✅ 🛠 watch
✅ 🛠 watch-sim

@TingPing TingPing self-assigned this Oct 17, 2026
@webkit-early-warning-system

This comment was marked as outdated.

@TingPing TingPing added the WebKitGTK Bugs related to the Gtk API layer. label Oct 17, 2026
@TingPing
TingPing force-pushed the pgriffis/pack-relative-relocs branch from c4e0f6b to 8655b68 Compare October 17, 2026 22:31
@webkit-early-warning-system

This comment was marked as outdated.

@TingPing
TingPing marked this pull request as ready for review October 17, 2026 22:41
@TingPing
TingPing requested a review from mcatanzaro as a code owner October 17, 2026 22:41

@aperezdc aperezdc left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are a number of issues with this, and the main one is that the environment used for building, when the test program runs, may not be the same where the built library will run. This is typical when building packages.

The other part I don't like much about this is that this is not a glibc-exclusive feature: the Musl libc has support for DT_RELR since version 1.2.4 (May 2023), and uCLibc-ng since version 1.0.46 (March 2024).

All in all, I think it would be better to make LD_SUPPORTS_PACK_RELATIVE_RELOCS detect whether the LD_USAGE variable contains pack-relative-relocs in its output, and then have an option(LD_PACK_RELATIVE_RELOCS ..) which by default takes the detected value, but can be overriden in the CMake command line. This would effectively always use the feature if the linker supports it, under the assumption that runtime support will be available. I expect that's fine because glibc 2.36 was released in August 2018. All the systems we support have glibc 2.36 or newer, and for embedded use cases that may use Musl or uCLibc we need to trust that the people doing the builds know what they are doing (and also we would provide the option that can be disabled).

Thoughts?

Comment thread Source/cmake/OptionsCommon.cmake Outdated
Comment thread Source/cmake/OptionsCommon.cmake Outdated
https://bugs.webkit.org/show_bug.cgi?id=327969

Reviewed by NOBODY (OOPS!).

Most of the dynamic relocations of the WebKit libraries are relative ones, and
every process reads all of them when it starts. Link with
-z pack-relative-relocs, which stores them in the much smaller DT_RELR format,
when the toolchain and the C library support it.

On WPE, the relocations of libWPEWebKit go from 8.1 MB to 2 MB, the library is
6 MB smaller, and the total PSS of the UI, Web and Network processes is about
7.5 MB lower.

* Source/cmake/OptionsCommon.cmake:
@TingPing
TingPing force-pushed the pgriffis/pack-relative-relocs branch from 8655b68 to e61c0ca Compare October 17, 2026 23:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

WebKitGTK Bugs related to the Gtk API layer.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants