From 72458c1cff9572fa17b1dc5f29d15e16a8da1bdf Mon Sep 17 00:00:00 2001 From: David Korth Date: Sat, 30 Jun 2018 11:46:46 -0400 Subject: [PATCH] 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 --- CMakeLists.txt | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 92b0a2d849..99dec1a297 100644 --- a/CMakeLists.txt +++ b/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 " qcTP ") + set(CMAKE_C_ARCHIVE_APPEND " qTP ") + set(CMAKE_CXX_ARCHIVE_CREATE " qcTP ") + set(CMAKE_CXX_ARCHIVE_APPEND " qTP ") + endif() endif() if(CMAKE_SYSTEM_NAME MATCHES "Darwin")