Skip to content

Commit c47b7c0

Browse files
committed
[CMake] Pack relative relocations when supported
https://bugs.webkit.org/show_bug.cgi?id=327969 Reviewed by Adrian Perez de Castro. 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: Canonical link: https://commits.webkit.org/324642@main
1 parent 5c707db commit c47b7c0

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

‎Source/cmake/OptionsCommon.cmake‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,10 @@ set(LD_SUPPORTS_ALLOW_MULTIPLE_DEFINITION FALSE)
102102
if (LD_USAGE MATCHES "allow-multiple-definition")
103103
set(LD_SUPPORTS_ALLOW_MULTIPLE_DEFINITION TRUE)
104104
endif ()
105+
set(LD_SUPPORTS_PACK_RELATIVE_RELOCS FALSE)
106+
if (LD_USAGE MATCHES "pack-relative-relocs" OR LD_USAGE MATCHES "--pack-dyn-relocs=[^ ]*relr")
107+
set(LD_SUPPORTS_PACK_RELATIVE_RELOCS TRUE)
108+
endif ()
105109
unset(LD_USAGE)
106110

107111
message(STATUS "Linker variant in use: ${LD_VARIANT} ")
@@ -110,6 +114,7 @@ message(STATUS " Linker supports split debug info - ${LD_SUPPORTS_SPLIT_DEBUG}"
110114
message(STATUS " Linker supports --gdb-index - ${LD_SUPPORTS_GDB_INDEX}")
111115
message(STATUS " Linker supports --disable-new-dtags - ${LD_SUPPORTS_DISABLE_NEW_DTAGS}")
112116
message(STATUS " Linker supports --gc-sections - ${LD_SUPPORTS_GC_SECTIONS}")
117+
message(STATUS " Linker supports -z pack-relative-relocs - ${LD_SUPPORTS_PACK_RELATIVE_RELOCS}")
113118

114119
# Determine whether the archiver in use supports thin archives.
115120
separate_arguments(AR_VERSION_COMMAND UNIX_COMMAND "${CMAKE_AR} -V")
@@ -155,6 +160,11 @@ if (LD_SUPPORTS_DISABLE_NEW_DTAGS)
155160
add_link_options("LINKER:--disable-new-dtags")
156161
endif ()
157162

163+
option(LD_PACK_RELATIVE_RELOCS "Pack relative relocations using DT_RELR" ${LD_SUPPORTS_PACK_RELATIVE_RELOCS})
164+
if (LD_PACK_RELATIVE_RELOCS)
165+
add_link_options("LINKER:-z,pack-relative-relocs")
166+
endif ()
167+
158168
# Prefer thin archives by default if they can be both created by the
159169
# archiver and read back by the linker.
160170
if (AR_SUPPORTS_THIN_ARCHIVES AND LD_SUPPORTS_THIN_ARCHIVES)

0 commit comments

Comments
 (0)