Permalink
Browse files

CMake: Use thin archives on Linux.

Thin archives contain pathnames pointing to the object files instead of
full copies of the object files. This significantly reduces the disk
usage when building Dolphin.

Size of *.a files: (gcc-8.1.0, Linux amd64)
- Before: 83,876 KB
- After:   1,876 KB
- Diff:  -82,000 KB

The resulting binaries are the same as before.

A similar change was implemented in the Linux kernel v4.8:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=a5967db9af51a84f5e181600954714a9e4c69f1f
  • Loading branch information...
GerbilSoft committed Jun 30, 2018
1 parent a9841e4 commit 72458c1cff9572fa17b1dc5f29d15e16a8da1bdf
Showing with 9 additions and 0 deletions.
  1. +9 −0 CMakeLists.txt
@@ -259,6 +259,15 @@ else()
dolphin_compile_definitions(_DEBUG DEBUG_ONLY)
check_and_add_flag(GGDB -ggdb DEBUG_ONLY)
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
# GNU ar: Create thin archive files.
# Requires binutils-2.19 or later.
set(CMAKE_C_ARCHIVE_CREATE "<CMAKE_AR> qcTP <TARGET> <LINK_FLAGS> <OBJECTS>")
set(CMAKE_C_ARCHIVE_APPEND "<CMAKE_AR> qTP <TARGET> <LINK_FLAGS> <OBJECTS>")
set(CMAKE_CXX_ARCHIVE_CREATE "<CMAKE_AR> qcTP <TARGET> <LINK_FLAGS> <OBJECTS>")
set(CMAKE_CXX_ARCHIVE_APPEND "<CMAKE_AR> qTP <TARGET> <LINK_FLAGS> <OBJECTS>")
endif()
endif()
if(CMAKE_SYSTEM_NAME MATCHES "Darwin")

0 comments on commit 72458c1

Please sign in to comment.