Skip to content

Commit 74eb1c6

Browse files
zdobersekpgorszkowski-igalia
authored andcommitted
OptionsWPE: compile with -ffunction-sections -fdata-sections, link with --gc-sections.
1 parent 9915aa1 commit 74eb1c6

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

Source/cmake/OptionsWPE.cmake

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -451,3 +451,10 @@ set(WPEWebProcessExtension_Uninstalled_PKGCONFIG_FILE ${CMAKE_BINARY_DIR}/${WPE_
451451

452452
include(BubblewrapSandboxChecks)
453453
include(GStreamerChecks)
454+
455+
# Optimize binary size for release builds by removing dead sections on unix/gcc.
456+
if (CMAKE_COMPILER_IS_GNUCC AND UNIX AND NOT APPLE)
457+
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -ffunction-sections -fdata-sections")
458+
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -ffunction-sections -fdata-sections -fno-rtti")
459+
set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} -Wl,--gc-sections")
460+
endif ()

0 commit comments

Comments
 (0)