Skip to content

Commit a5cc1c4

Browse files
blinomagomez
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 8b0c09d commit a5cc1c4

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
@@ -475,8 +475,11 @@ include(BubblewrapSandboxChecks)
475475
include(GStreamerChecks)
476476

477477
# Optimize binary size for release builds by removing dead sections on unix/gcc.
478-
if (CMAKE_COMPILER_IS_GNUCC AND UNIX AND NOT APPLE)
479-
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -ffunction-sections -fdata-sections")
480-
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -ffunction-sections -fdata-sections -fno-rtti")
478+
if (COMPILER_IS_GCC_OR_CLANG AND UNIX AND NOT APPLE)
479+
if (CMAKE_COMPILER_IS_GNUCC)
480+
set(CMAKE_COMPILER_SIZE_OPT_FLAGS " -finline-limit=90 -fsection-anchors")
481+
endif ()
482+
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}${CMAKE_COMPILER_SIZE_OPT_FLAGS} -ffunction-sections -fdata-sections")
483+
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}${CMAKE_COMPILER_SIZE_OPT_FLAGS} -ffunction-sections -fdata-sections -fno-rtti")
481484
set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} -Wl,--gc-sections")
482485
endif ()

0 commit comments

Comments
 (0)