OLD | NEW |
1 #!/bin/sh | 1 #!/bin/sh |
2 # Copyright 2014 The Chromium Authors. All rights reserved. | 2 # Copyright 2014 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 # Script to build binutils found in /build/binutils-XXXX when inside a chroot. | 6 # Script to build binutils found in /build/binutils-XXXX when inside a chroot. |
7 # Don't call this script yourself, instead use the build-all.sh script. | 7 # Don't call this script yourself, instead use the build-all.sh script. |
8 | 8 |
9 set -e | 9 set -e |
| 10 set -x |
10 | 11 |
11 if [ -z "$1" ]; then | 12 if [ -z "$1" ]; then |
12 echo "Directory of binutils not given." | 13 echo "Directory of binutils not given." |
13 exit 1 | 14 exit 1 |
14 fi | 15 fi |
15 | 16 |
16 cd "$1" | 17 cd "$1" |
17 | 18 |
18 # First, we need to build libtcmalloc_minimal | 19 # First, we need to build libtcmalloc_minimal |
19 | 20 |
20 cd ../gperftools/ | 21 cd ../gperftools/ |
21 ./autogen.sh | 22 ./autogen.sh |
22 ./configure --disable-static --enable-minimal --disable-heap-checker \ | 23 ./configure \ |
23 --disable-heap-profiler --disable-cpu-profiler | 24 --disable-cpu-profiler \ |
| 25 --disable-heap-checker \ |
| 26 --disable-heap-profiler \ |
| 27 --disable-static \ |
| 28 --enable-minimal |
| 29 |
| 30 echo |
| 31 echo "= gperftools src/config.h ==========================================" |
| 32 cat src/config.h |
| 33 echo "====================================================================" |
| 34 echo |
| 35 |
24 make -j8 | 36 make -j8 |
25 | 37 |
26 cd "$1" | 38 cd "$1" |
27 | 39 |
28 # Ask the dynamic loader to load libstdc++ from the LLVM build directory if | 40 # Ask the dynamic loader to load libstdc++ from the LLVM build directory if |
29 # available. That copy of libstdc++ is required by the gold plugin in the same | 41 # available. That copy of libstdc++ is required by the gold plugin in the same |
30 # directory. Do the same for libtcmalloc_minimal, that is stored in ../lib. | 42 # directory. Do the same for libtcmalloc_minimal, that is stored in ../lib. |
31 # The dynamic loader expects the relative path to start with $ORIGIN, | 43 # The dynamic loader expects the relative path to start with $ORIGIN, |
32 # but because of escaping issues | 44 # but because of escaping issues |
33 # (https://sourceware.org/ml/binutils/2009-05/msg00252.html) | 45 # (https://sourceware.org/ml/binutils/2009-05/msg00252.html) |
34 # we embed a dummy path with $ replaced with z and fix it up later. | 46 # we embed a dummy path with $ replaced with z and fix it up later. |
35 | 47 |
36 readonly LIBSTDCPP_RPATH="zORIGIN/../../../../llvm-build/Release+Asserts/lib" | 48 readonly LIBSTDCPP_RPATH="zORIGIN/../../../../llvm-build/Release+Asserts/lib" |
37 readonly LIBTCMALLOC_RPATH="zORIGIN/../lib" | 49 readonly LIBTCMALLOC_RPATH="zORIGIN/../lib" |
38 export LDFLAGS="-Wl,-rpath,$LIBSTDCPP_RPATH:$LIBTCMALLOC_RPATH \ | 50 export LDFLAGS="-Wl,-rpath,$LIBSTDCPP_RPATH:$LIBTCMALLOC_RPATH \ |
39 -L$(pwd)/../gperftools/.libs/" | 51 -L$(pwd)/../gperftools/.libs/" |
40 export LIBS='-ltcmalloc_minimal' | 52 export LIBS='-ltcmalloc_minimal' |
41 | 53 |
42 ./configure --enable-gold=default --enable-threads --enable-plugins \ | 54 ./configure \ |
| 55 --enable-deterministic-archives \ |
| 56 --enable-gold=default \ |
| 57 --enable-plugins \ |
| 58 --enable-threads \ |
43 --prefix=/build/output | 59 --prefix=/build/output |
44 | 60 |
| 61 |
45 make -j8 all | 62 make -j8 all |
| 63 echo |
| 64 echo "= binutils/config.h ================================================" |
| 65 cat binutils/config.h |
| 66 echo "====================================================================" |
| 67 echo |
46 make install | 68 make install |
47 | 69 |
48 # Copy libtcmalloc_minimal library and symlinks to the install lib dir. | 70 # Copy libtcmalloc_minimal library and symlinks to the install lib dir. |
49 cp -a ../gperftools/.libs/libtcmalloc_minimal.so* /build/output/*/lib/ | 71 cp -a ../gperftools/.libs/libtcmalloc_minimal.so* /build/output/*/lib/ |
50 | 72 |
51 # Save the list of binaries. The sed -i command will leave .orig files behind. | 73 # Save the list of binaries. The sed -i command will leave .orig files behind. |
52 # We don't want them to appear in the for loop below. | 74 # We don't want them to appear in the for loop below. |
53 bins="$(echo /build/output/*/bin/*)" | 75 bins="$(echo /build/output/*/bin/*)" |
54 | 76 |
55 # Fix up zORIGIN -> $ORIGIN. | 77 # Fix up zORIGIN -> $ORIGIN. |
56 sed -i.orig 's,zORIGIN,$ORIGIN,g' $bins | 78 sed -i.orig 's,zORIGIN,$ORIGIN,g' $bins |
57 | 79 |
58 # Verify that we changed only two bytes per executable. | 80 # Verify that we changed only two bytes per executable. |
59 for bin in $bins; do | 81 for bin in $bins; do |
60 test "`cmp -l $bin.orig $bin | wc -l`" = 2 || \ | 82 test "`cmp -l $bin.orig $bin | wc -l`" = 2 || \ |
61 (echo "$bin: verification failed" && exit 1) | 83 (echo "$bin: verification failed" && exit 1) |
62 done | 84 done |
63 | 85 |
64 rm /build/output/*/bin/*.orig | 86 rm /build/output/*/bin/*.orig |
OLD | NEW |