use ccache and gold to make compiling faster
diff --git a/aos/build/aos.gypi b/aos/build/aos.gypi
index 08a99c6..b0b9ec7 100644
--- a/aos/build/aos.gypi
+++ b/aos/build/aos.gypi
@@ -15,6 +15,8 @@
'so_dir': '<(PRODUCT_DIR)/lib',
# the directory that executables that depend on <(EXTERNALS):gtest get put into
'test_dir': '<(PRODUCT_DIR)/tests',
+
+ 'ccache': '<!(which ccache) ',
},
'conditions': [
['PLATFORM=="crio"', {
@@ -25,8 +27,8 @@
}
], ['PLATFORM=="linux-arm-gcc"', {
'make_global_settings': [
- ['CC', '<!(which arm-linux-gnueabihf-gcc-4.7)'],
- ['CXX', '<!(which arm-linux-gnueabihf-g++-4.7)'],
+ ['CC', '<(ccache)<!(which arm-linux-gnueabihf-gcc-4.7)'],
+ ['CXX', '<(ccache)<!(which arm-linux-gnueabihf-g++-4.7)'],
],
},
], ['PLATFORM=="linux-arm-clang"', {
@@ -42,8 +44,8 @@
],
},
'make_global_settings': [
- ['CC', '<(arm-clang-symlinks)/bin/clang'],
- ['CXX', '<(arm-clang-symlinks)/bin/clang++'],
+ ['CC', '<(ccache)<(arm-clang-symlinks)/bin/clang'],
+ ['CXX', '<(ccache)<(arm-clang-symlinks)/bin/clang++'],
],
'target_defaults': {
'cflags': [
@@ -60,16 +62,20 @@
},
], ['PLATFORM=="linux-amd64-clang"', {
'make_global_settings': [
- ['CC', '/opt/clang-3.5/bin/clang'],
- ['CXX', '/opt/clang-3.5/bin/clang++'],
+ ['CC', '<(ccache)/opt/clang-3.5/bin/clang'],
+ ['CXX', '<(ccache)/opt/clang-3.5/bin/clang++'],
],
},
], ['PLATFORM=="linux-amd64-gcc"', {
+ 'make_global_settings': [
+ ['CC', '<(ccache)<!(which gcc)'],
+ ['CXX', '<(ccache)<!(which g++)'],
+ ],
},
], ['PLATFORM=="linux-amd64-gcc_4.8"', {
'make_global_settings': [
- ['CC', '/opt/clang-3.5/bin/gcc'],
- ['CXX', '/opt/clang-3.5/bin/g++'],
+ ['CC', '<(ccache)/opt/clang-3.5/bin/gcc'],
+ ['CXX', '<(ccache)/opt/clang-3.5/bin/g++'],
],
},
], ['SANITIZER!="none"', {
diff --git a/aos/build/arm-clang-symlinks/bin/ld b/aos/build/arm-clang-symlinks/bin/ld
index d57f1ba..5981fc6 120000
--- a/aos/build/arm-clang-symlinks/bin/ld
+++ b/aos/build/arm-clang-symlinks/bin/ld
@@ -1 +1 @@
-/usr/arm-linux-gnueabihf/bin/ld
\ No newline at end of file
+/usr/arm-linux-gnueabihf/bin/ld.gold
\ No newline at end of file
diff --git a/aos/build/bin-ld.gold/ld b/aos/build/bin-ld.gold/ld
new file mode 120000
index 0000000..af8591b
--- /dev/null
+++ b/aos/build/bin-ld.gold/ld
@@ -0,0 +1 @@
+/usr/bin/ld.gold
\ No newline at end of file
diff --git a/aos/build/build.py b/aos/build/build.py
index a78b795..b35a02f 100755
--- a/aos/build/build.py
+++ b/aos/build/build.py
@@ -189,6 +189,25 @@
r['ASAN_OPTIONS'] = 'detect_leaks=1:check_initialization_order=1:strict_init_order=1'
elif self.sanitizer == 'memory':
r['MSAN_SYMBOLIZER_PATH'] = '/opt/clang-3.5/bin/llvm-symbolizer'
+
+ r['CCACHE_COMPRESS'] = 'yes'
+ r['CCACHE_DIR'] = \
+ os.path.abspath(os.path.join(aos_path(), '..', 'output', 'ccache_dir'))
+ r['CCACHE_HASHDIR'] = 'yes'
+ if self.compiler == 'clang':
+ # clang doesn't like being run directly on the preprocessed files.
+ r['CCACHE_CPP2'] = 'yes'
+ # Without this, ccache slows down because of the generated header files.
+ # The race condition that this opens up isn't a problem because the build
+ # system finishes modifying header files before compiling anything that
+ # uses them.
+ r['CCACHE_SLOPPINESS'] = 'include_file_mtime'
+ r['CCACHE_COMPILERCHECK'] = 'content'
+
+ if self.architecture == 'amd64':
+ r['PATH'] = os.path.join(aos_path(), 'build', 'bin-ld.gold') + \
+ ':' + os.environ['PATH']
+
return r
ARCHITECTURES = ('arm', 'amd64')
@@ -456,8 +475,10 @@
def env(platform):
build_env = dict(platform.build_env())
- build_env['TERM'] = os.environ['TERM']
- build_env['PATH'] = os.environ['PATH']
+ if not 'TERM' in build_env:
+ build_env['TERM'] = os.environ['TERM']
+ if not 'PATH' in build_env:
+ build_env['PATH'] = os.environ['PATH']
return build_env
to_build = []
diff --git a/output/.gitignore b/output/.gitignore
index b08d9c6..62a7a9b 100644
--- a/output/.gitignore
+++ b/output/.gitignore
@@ -3,6 +3,7 @@
/flasher/
/compiled-*/
/ip_base.txt
+/ccache_dir/
/crio/
/crio-debug/