Skip to content

Commit

Permalink
chore(CI): Reduce the target size when build on GitHub actions (#2086)
Browse files Browse the repository at this point in the history
The GitHub action runners for free plan is very limit, it's easy to exceed
the disk space.

This patch adds some build and link flags to reduce the target size to ensure
the actions can be completed without disk exhaust issues.

Now the release packge is reduced from about 2,600,468,480 bytes to 686,325,578
bytes, and the ASAN package can be built completly now.
  • Loading branch information
acelyc111 authored Aug 2, 2024
1 parent 097068d commit 581a811
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions cmake_modules/BaseFunctions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -193,12 +193,20 @@ endfunction()
function(dsn_setup_compiler_flags)
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
add_definitions(-DDSN_BUILD_TYPE=Debug)
add_definitions(-g)
else()
add_definitions(-g)
add_definitions(-O2)
add_definitions(-DDSN_BUILD_TYPE=Release)
endif()

if("$ENV{GITHUB_ACTION}" STREQUAL "" OR APPLE)
add_definitions(-g)
else()
# Reduce the target size when build on GitHub actions and non-macOS.
message(WARNING "Running GitHub actions, the target size will be reduced!")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Os -ffunction-sections -fdata-sections -fno-unwind-tables -fno-asynchronous-unwind-tables")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-s -Wl,--gc-sections")
endif()

cmake_host_system_information(RESULT BUILD_HOSTNAME QUERY HOSTNAME)
add_definitions(-DDSN_BUILD_HOSTNAME=${BUILD_HOSTNAME})

Expand Down

0 comments on commit 581a811

Please sign in to comment.