Skip to content

Commit

Permalink
Reduce binary sizes by stripping symbols
Browse files Browse the repository at this point in the history
  • Loading branch information
OleksandrChaika committed Jun 21, 2023
1 parent cd51467 commit 6571f44
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 3 deletions.
14 changes: 13 additions & 1 deletion .github/actions/build-native-binary/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,19 @@ runs:
-DSUA_MEASURE_CODE_COVERAGE=NO \
..
make -j
make install
make install/strip
shell: bash

- name: Strip binaries for amd64
if: ${{ inputs.arch == 'amd64' }}
run: |
strip dist_${{ inputs.arch }}/lib/lib*
shell: bash

- name: Strip binaries for arm64
if: ${{ inputs.arch == 'arm64' }}
run: |
aarch64-linux-gnu-strip dist_${{ inputs.arch }}/lib/lib*
shell: bash

- name: Build for amd64 with code-coverage enabled
Expand Down
11 changes: 10 additions & 1 deletion Dockerfile.amd64
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,16 @@ RUN cd /work \

RUN cd /work \
&& cd build_amd64 \
&& make install
&& make install/strip

RUN cd /work \
&& strip dist_amd64/lib/lib* \
&& strip /work/build_amd64/glib/gio/libgio-2.0.so.0 \
&& strip /work/build_amd64/glib/gobject/libgobject-2.0.so.0 \
&& strip /work/build_amd64/glib/glib/libglib-2.0.so.0 \
&& strip /work/build_amd64/glib/gmodule/libgmodule-2.0.so.0 \
&& strip /work/build_amd64/glib/subprojects/libffi/src/libffi.so.7 \
&& strip /work/build_amd64/glib/subprojects/zlib-1.2.11/libz.so

#Define RUNTIME environment, the final image
FROM --platform=${TARGETPLATFORM} scratch as runtime
Expand Down
11 changes: 10 additions & 1 deletion Dockerfile.arm64
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,16 @@ RUN cd /work \

RUN cd /work \
&& cd build_arm64 \
&& make install
&& make install/strip

RUN cd /work \
&& aarch64-linux-gnu-strip dist_arm64/lib/lib* \
&& aarch64-linux-gnu-strip /work/build_arm64/glib/gio/libgio-2.0.so.0 \
&& aarch64-linux-gnu-strip /work/build_arm64/glib/gobject/libgobject-2.0.so.0 \
&& aarch64-linux-gnu-strip /work/build_arm64/glib/glib/libglib-2.0.so.0 \
&& aarch64-linux-gnu-strip /work/build_arm64/glib/gmodule/libgmodule-2.0.so.0 \
&& aarch64-linux-gnu-strip /work/build_arm64/glib/subprojects/libffi/src/libffi.so.7 \
&& aarch64-linux-gnu-strip /work/build_arm64/glib/subprojects/zlib-1.2.11/libz.so

#Define RUNTIME environment, the final image
FROM --platform=${TARGETPLATFORM} scratch as runtime
Expand Down
3 changes: 3 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,10 @@ list(FILTER SRCS EXCLUDE REGEX "main.cpp" )
list(APPEND SRCS ${CMAKE_CURRENT_BINARY_DIR}/version.cpp)

add_library(sua SHARED ${SRCS})
set_target_properties(sua PROPERTIES LINK_FLAGS -s)

add_executable(${PROJECT_NAME} ${SRCS} main.cpp)
set_target_properties(${PROJECT_NAME} PROPERTIES LINK_FLAGS -s)

link_directories(${CMAKE_BINARY_DIR}/3rdparty/curl/lib)

Expand Down

0 comments on commit 6571f44

Please sign in to comment.