From 52a773ded943a19c880b2d2dd673d56d35aa3f03 Mon Sep 17 00:00:00 2001 From: Ivan Krasin Date: Mon, 8 Feb 2016 18:58:13 -0800 Subject: Link binutils with tcmalloc_minimal. This speeds up linking large targets with LTO by 10%. BUG=583551 R=thestig@chromium.org Review URL: https://codereview.chromium.org/1670073003 . Cr-Commit-Position: refs/heads/master@{#374283} --- .../binutils/Linux_ia32/binutils.tar.bz2.sha1 | 2 +- .../binutils/Linux_x64/binutils.tar.bz2.sha1 | 2 +- third_party/binutils/README.chromium | 3 ++- third_party/binutils/build-all.sh | 7 +++++- third_party/binutils/build-one.sh | 28 ++++++++++++++++++---- 5 files changed, 34 insertions(+), 8 deletions(-) (limited to 'third_party/binutils') diff --git a/third_party/binutils/Linux_ia32/binutils.tar.bz2.sha1 b/third_party/binutils/Linux_ia32/binutils.tar.bz2.sha1 index 334186c..193ff04 100644 --- a/third_party/binutils/Linux_ia32/binutils.tar.bz2.sha1 +++ b/third_party/binutils/Linux_ia32/binutils.tar.bz2.sha1 @@ -1 +1 @@ -b441a117dacb5996e4104e5a56cc40f3b7827090 \ No newline at end of file +2b69e02785cfc016cf586d40296e98adf0669310 \ No newline at end of file diff --git a/third_party/binutils/Linux_x64/binutils.tar.bz2.sha1 b/third_party/binutils/Linux_x64/binutils.tar.bz2.sha1 index fc15602..7ea4a74 100644 --- a/third_party/binutils/Linux_x64/binutils.tar.bz2.sha1 +++ b/third_party/binutils/Linux_x64/binutils.tar.bz2.sha1 @@ -1 +1 @@ -84702c49591e8994c32e0ded578c99d8dcb7a9f2 \ No newline at end of file +43ac0129d4f4fb570e14571e9e7510ba178d77cd \ No newline at end of file diff --git a/third_party/binutils/README.chromium b/third_party/binutils/README.chromium index 8c68129..5f32f89 100644 --- a/third_party/binutils/README.chromium +++ b/third_party/binutils/README.chromium @@ -13,7 +13,8 @@ They were built from binutils-2.25 using the "build-all.sh" script on a Ubuntu Precise. The script creates chroots for 32bit and 64bit Ubuntu Precise and then builds -binutils inside the roots. +binutils inside the roots. It also builds tcmalloc and links binutils with it +to improve the speed of LTO. Version 2.25 was released on Wed, 24 Dec 2014 diff --git a/third_party/binutils/build-all.sh b/third_party/binutils/build-all.sh index 30f1ee9..dc63683 100755 --- a/third_party/binutils/build-all.sh +++ b/third_party/binutils/build-all.sh @@ -35,6 +35,9 @@ if ! gpg --verify binutils-$VERSION.tar.bz2.sig; then exit 1 fi +if [ ! -d gperftools ]; then + git clone --branch gperftools-2.4 https://github.com/gperftools/gperftools +fi # Extract the source rm -rf binutils-$VERSION @@ -69,9 +72,10 @@ for ARCH in i386 amd64; do echo "" echo "Building chroot for $ARCH" echo "=============================" + GPERFTOOLS_DEPS=autoconf,automake,libtool sudo debootstrap \ --arch=$ARCH \ - --include=build-essential,flex,bison \ + --include=build-essential,flex,bison,$GPERFTOOLS_DEPS \ precise precise-chroot-$ARCH echo "=============================" fi @@ -87,6 +91,7 @@ for ARCH in i386 amd64; do sudo mkdir -p "$BUILDDIR" sudo cp -a binutils-$VERSION "$BUILDDIR" sudo cp -a build-one.sh "$BUILDDIR" + sudo cp -a gperftools "$BUILDDIR" # Do the build PREFIX= diff --git a/third_party/binutils/build-one.sh b/third_party/binutils/build-one.sh index 1a45638a0..7611d09 100755 --- a/third_party/binutils/build-one.sh +++ b/third_party/binutils/build-one.sh @@ -15,19 +15,39 @@ fi cd "$1" +# First, we need to build libtcmalloc_minimal + +cd ../gperftools/ +./autogen.sh +./configure --disable-static --enable-minimal --disable-heap-checker \ + --disable-heap-profiler --disable-cpu-profiler +make -j8 + +cd "$1" + # Ask the dynamic loader to load libstdc++ from the LLVM build directory if # available. That copy of libstdc++ is required by the gold plugin in the same -# directory. The dynamic loader expects the relative path to start with $ORIGIN, +# directory. Do the same for libtcmalloc_minimal, that is stored in ../lib. +# The dynamic loader expects the relative path to start with $ORIGIN, # but because of escaping issues # (https://sourceware.org/ml/binutils/2009-05/msg00252.html) # we embed a dummy path with $ replaced with z and fix it up later. -export LDFLAGS='-Wl,-rpath,zORIGIN/../../../../llvm-build/Release+Asserts/lib' + +readonly LIBSTDCPP_RPATH="zORIGIN/../../../../llvm-build/Release+Asserts/lib" +readonly LIBTCMALLOC_RPATH="zORIGIN/../lib" +export LDFLAGS="-Wl,-rpath,$LIBSTDCPP_RPATH:$LIBTCMALLOC_RPATH \ + -L$(pwd)/../gperftools/.libs/" +export LIBS='-ltcmalloc_minimal' ./configure --enable-gold=default --enable-threads --enable-plugins \ --prefix=/build/output + make -j8 all make install +# Copy libtcmalloc_minimal library and symlinks to the install lib dir. +cp -a ../gperftools/.libs/libtcmalloc_minimal.so* /build/output/*/lib/ + # Save the list of binaries. The sed -i command will leave .orig files behind. # We don't want them to appear in the for loop below. bins="$(echo /build/output/*/bin/*)" @@ -35,9 +55,9 @@ bins="$(echo /build/output/*/bin/*)" # Fix up zORIGIN -> $ORIGIN. sed -i.orig 's,zORIGIN,$ORIGIN,g' $bins -# Verify that we changed only one byte per executable. +# Verify that we changed only two bytes per executable. for bin in $bins; do - test "`cmp -l $bin.orig $bin | wc -l`" = 1 || \ + test "`cmp -l $bin.orig $bin | wc -l`" = 2 || \ (echo "$bin: verification failed" && exit 1) done -- cgit v1.1