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
This commit is contained in:
David Korth 2018-06-30 11:46:46 -04:00
parent a9841e4fc4
commit 72458c1cff
1 changed files with 9 additions and 0 deletions

View File

@ -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")