You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kudu.apache.org by to...@apache.org on 2018/03/04 18:42:36 UTC
[2/2] kudu git commit: build: use thin static libraries on Linux
build: use thin static libraries on Linux
Thin static libraries just contain pointers to .o files rather than copying all
of the data. This reduces the amount of IO during the build as well as the required
disk space.
For example, comparing a clean build ('ninja clean kudu') before and after this
change, we can see that the build is about 40% faster and about 200x
less disk space in the lib/ directory.
Thick (original):
real 0m24.784s
user 0m58.643s
sys 0m37.701s
todd@ve0518:/data/1/todd/kudu$ du -sm build/release/lib/
594 build/release/lib/
Thin:
real 0m17.422s
user 0m56.092s
sys 0m34.131s
todd@ve0518:/data/1/todd/kudu$ du -sm build/release/lib/
3 build/release/lib/
For comparison, a release build with -DKUDU_LINK=dynamic:
real 0m24.008s
user 2m3.212s
sys 1m5.243s
todd@ve0518:/data/1/todd/kudu/build/release-shared$ du -sm lib/
256 lib/
Of course the dynamic build has a much smaller resulting 'kudu' binary, and if
we are compiling many binaries (eg all the tests), the dynamic build is still
faster and smaller than a thin-static build.
Change-Id: If662cea380e06eaddf45e52617e38e55e4613773
Reviewed-on: http://gerrit.cloudera.org:8080/9472
Reviewed-by: Adar Dembo <ad...@cloudera.com>
Tested-by: Kudu Jenkins
Project: http://git-wip-us.apache.org/repos/asf/kudu/repo
Commit: http://git-wip-us.apache.org/repos/asf/kudu/commit/726514ab
Tree: http://git-wip-us.apache.org/repos/asf/kudu/tree/726514ab
Diff: http://git-wip-us.apache.org/repos/asf/kudu/diff/726514ab
Branch: refs/heads/master
Commit: 726514abfe309b0b88a5d868129f494c379af954
Parents: b6682c7
Author: Todd Lipcon <to...@apache.org>
Authored: Fri Mar 2 16:10:39 2018 -0800
Committer: Todd Lipcon <to...@apache.org>
Committed: Sun Mar 4 18:15:06 2018 +0000
----------------------------------------------------------------------
CMakeLists.txt | 9 +++++++++
1 file changed, 9 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/kudu/blob/726514ab/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/CMakeLists.txt b/CMakeLists.txt
index c906cc3..4a766a9 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1123,6 +1123,15 @@ endif()
set(KUDU_MIN_TEST_LIBS kudu_test_main kudu_test_util ${KUDU_BASE_LIBS})
set(KUDU_TEST_LINK_LIBS ${KUDU_MIN_TEST_LIBS})
+# Use "thin archives" for our static libraries. We only use static libraries
+# internal to our own build, so thin ones are just as good and much smaller.
+if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
+ set(CMAKE_CXX_ARCHIVE_CREATE "<CMAKE_AR> cruT <TARGET> <LINK_FLAGS> <OBJECTS>")
+ set(CMAKE_C_ARCHIVE_CREATE "<CMAKE_AR> cruT <TARGET> <LINK_FLAGS> <OBJECTS>")
+ set(CMAKE_CXX_ARCHIVE_APPEND "<CMAKE_AR> ruT <TARGET> <LINK_FLAGS> <OBJECTS>")
+ set(CMAKE_C_ARCHIVE_APPEND "<CMAKE_AR> ruT <TARGET> <LINK_FLAGS> <OBJECTS>")
+endif()
+
############################################################
# "make ctags" target
############################################################