Skip to content

Commit 44b1aa5

Browse files
blinopgorszkowski-igalia
authored andcommitted
Use -ffunction-sections/-fdata-sections/--gc-sections with clang too
This saves about 1500 kB on a production build on ARMv7.
1 parent 74eb1c6 commit 44b1aa5

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

Source/cmake/OptionsWPE.cmake

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -453,8 +453,11 @@ include(BubblewrapSandboxChecks)
453453
include(GStreamerChecks)
454454

455455
# 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")
456+
if (COMPILER_IS_GCC_OR_CLANG AND UNIX AND NOT APPLE)
457+
if (CMAKE_COMPILER_IS_GNUCC)
458+
set(CMAKE_COMPILER_SIZE_OPT_FLAGS " -finline-limit=90 -fsection-anchors")
459+
endif ()
460+
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}${CMAKE_COMPILER_SIZE_OPT_FLAGS} -ffunction-sections -fdata-sections")
461+
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}${CMAKE_COMPILER_SIZE_OPT_FLAGS} -ffunction-sections -fdata-sections -fno-rtti")
459462
set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} -Wl,--gc-sections")
460463
endif ()

0 commit comments

Comments
 (0)