OLD | NEW |
1 #!/bin/bash -e | 1 #!/bin/bash -e |
2 | 2 |
3 # Copyright (c) 2011 The Chromium Authors. All rights reserved. | 3 # Copyright (c) 2011 The Chromium Authors. All rights reserved. |
4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
6 | 6 |
7 # Script to install everything needed to build chromium (well, ideally, anyway) | 7 # Script to install everything needed to build chromium (well, ideally, anyway) |
8 # See http://code.google.com/p/chromium/wiki/LinuxBuildInstructions | 8 # See http://code.google.com/p/chromium/wiki/LinuxBuildInstructions |
9 # and http://code.google.com/p/chromium/wiki/LinuxBuild64Bit | 9 # and http://code.google.com/p/chromium/wiki/LinuxBuild64Bit |
10 | 10 |
11 usage() { | 11 usage() { |
12 echo "Usage: $0 [--options]" | 12 echo "Usage: $0 [--options]" |
13 echo "Options:" | 13 echo "Options:" |
14 echo "--[no-]syms: enable or disable installation of debugging symbols" | 14 echo "--[no-]syms: enable or disable installation of debugging symbols" |
15 echo "--[no-]gold: enable or disable installation of gold linker" | 15 echo "--[no-]gold: enable or disable installation of gold linker" |
16 echo "--[no-]lib32: enable or disable installation of 32 bit libraries" | 16 echo "--[no-]lib32: enable or disable installation of 32 bit libraries" |
| 17 echo "--[no-]restore-usr-bin-ld: enable or disable restoring /usr/bin/ld to" |
| 18 echo " ld.bfd if it is currently gold" |
17 echo "Script will prompt interactively if options not given." | 19 echo "Script will prompt interactively if options not given." |
18 exit 1 | 20 exit 1 |
19 } | 21 } |
20 | 22 |
21 while test "$1" != "" | 23 while test "$1" != "" |
22 do | 24 do |
23 case "$1" in | 25 case "$1" in |
24 --syms) do_inst_syms=1;; | 26 --syms) do_inst_syms=1;; |
25 --no-syms) do_inst_syms=0;; | 27 --no-syms) do_inst_syms=0;; |
26 --gold) do_inst_gold=1;; | 28 --gold) do_inst_gold=1;; |
27 --no-gold) do_inst_gold=0;; | 29 --no-gold) do_inst_gold=0;; |
28 --lib32) do_inst_lib32=1;; | 30 --lib32) do_inst_lib32=1;; |
29 --no-lib32) do_inst_lib32=0;; | 31 --no-lib32) do_inst_lib32=0;; |
| 32 --restore-usr-bin-ld) do_restore_usr_bin_ld=1;; |
| 33 --no-restore-usr-bin-ld) do_restore_usr_bin_ld=0;; |
30 *) usage;; | 34 *) usage;; |
31 esac | 35 esac |
32 shift | 36 shift |
33 done | 37 done |
34 | 38 |
35 install_gold() { | 39 install_gold() { |
36 # Gold is optional; it's a faster replacement for ld, | 40 # Gold is optional; it's a faster replacement for ld, |
37 # and makes life on 2GB machines much more pleasant. | 41 # and makes life on 2GB machines much more pleasant. |
38 | 42 |
39 # First make sure root can access this directory, as that's tripped | 43 # First make sure root can access this directory, as that's tripped |
(...skipping 12 matching lines...) Expand all Loading... |
52 | 56 |
53 test -f $BINUTILS.tar.bz2 || wget $BINUTILS_URL | 57 test -f $BINUTILS.tar.bz2 || wget $BINUTILS_URL |
54 if test "`sha1sum $BINUTILS.tar.bz2|cut -d' ' -f1`" != "$BINUTILS_SHA1" | 58 if test "`sha1sum $BINUTILS.tar.bz2|cut -d' ' -f1`" != "$BINUTILS_SHA1" |
55 then | 59 then |
56 echo Bad sha1sum for $BINUTILS.tar.bz2 | 60 echo Bad sha1sum for $BINUTILS.tar.bz2 |
57 exit 1 | 61 exit 1 |
58 fi | 62 fi |
59 | 63 |
60 tar -xjvf $BINUTILS.tar.bz2 | 64 tar -xjvf $BINUTILS.tar.bz2 |
61 cd $BINUTILS | 65 cd $BINUTILS |
62 ./configure --prefix=/usr/local/gold --enable-gold --enable-threads | 66 ./configure --prefix=/usr/local/gold --enable-gold=default --enable-threads \ |
63 make maybe-all-binutils maybe-all-gold -j4 | 67 --enable-bfd=yes |
64 if sudo make maybe-install-binutils maybe-install-gold | 68 NCPU=`cat /proc/cpuinfo |grep ^processor|wc -l` |
| 69 make maybe-all-binutils maybe-all-gold maybe-all-ld -j${NCPU} |
| 70 if sudo make maybe-install-binutils maybe-install-gold maybe-install-ld |
65 then | 71 then |
66 # Still need to figure out graceful way of pointing gyp to use | 72 # Still need to figure out graceful way of pointing gyp to use |
67 # /usr/local/gold/bin/ld without requiring him to set environment | 73 # /usr/local/gold/bin/ld without requiring him to set environment |
68 # variables. That will go into bootstrap-linux.sh when it's ready. | 74 # variables. |
69 echo "Installing gold as /usr/bin/ld." | 75 sudo strip /usr/local/gold/bin/ld.gold |
70 echo "To uninstall, do 'cd /usr/bin; sudo rm ld; sudo mv ld.orig ld'" | 76 sudo strip /usr/local/gold/bin/ld.bfd |
71 test -f /usr/bin/ld && test ! -f /usr/bin/ld.orig && \ | |
72 sudo mv /usr/bin/ld /usr/bin/ld.orig | |
73 sudo strip /usr/local/gold/bin/ld | |
74 sudo ln -fs /usr/local/gold/bin/ld /usr/bin/ld.gold | |
75 sudo ln -fs /usr/bin/ld.gold /usr/bin/ld | |
76 else | 77 else |
77 echo "make install failed, not installing gold" | 78 echo "make install failed, not installing gold" |
78 fi | 79 fi |
79 } | 80 } |
80 | 81 |
81 if ! egrep -q \ | 82 if ! egrep -q \ |
82 'Ubuntu (10\.04|10\.10|11\.04|lucid|maverick|natty)' \ | 83 'Ubuntu (10\.04|10\.10|11\.04|lucid|maverick|natty)' \ |
83 /etc/issue; then | 84 /etc/issue; then |
84 echo "Only Ubuntu 10.04 (lucid) through 11.04 (natty) are currently" \ | 85 echo "Only Ubuntu 10.04 (lucid) through 11.04 (natty) are currently" \ |
85 "supported" >&2 | 86 "supported" >&2 |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
245 fi | 246 fi |
246 | 247 |
247 # Some operating systems already ship gold (on recent Debian and | 248 # Some operating systems already ship gold (on recent Debian and |
248 # Ubuntu you can do "apt-get install binutils-gold" to get it), but | 249 # Ubuntu you can do "apt-get install binutils-gold" to get it), but |
249 # older releases didn't. Additionally, gold 2.20 (included in Ubuntu | 250 # older releases didn't. Additionally, gold 2.20 (included in Ubuntu |
250 # Lucid) makes binaries that just segfault, and 2.20.1 does not support | 251 # Lucid) makes binaries that just segfault, and 2.20.1 does not support |
251 # --map-whole-files. | 252 # --map-whole-files. |
252 # So install from source if we don't have a good version. | 253 # So install from source if we don't have a good version. |
253 | 254 |
254 case `ld --version` in | 255 case `ld --version` in |
| 256 *gold*2.2[1-9].*) |
| 257 echo "*** Warning ***" |
| 258 echo "If the default linker is gold, linking may fail for:" |
| 259 echo "the Linux kernel, kernel modules, Valgrind, and Wine." |
| 260 echo "If you previously installed gold as the default linker," |
| 261 echo "you can restore the original linker by running:" |
| 262 echo "'cd /usr/bin; sudo rm ld; sudo mv ld.orig ld'" |
| 263 echo |
| 264 if [ "$do_restore_usr_bin_ld" = "" ] |
| 265 then |
| 266 echo -n "Restore /usr/bin/ld to the original linker? (Y/n) " |
| 267 if yes_no 0 |
| 268 then |
| 269 do_restore_usr_bin_ld=1 |
| 270 fi |
| 271 echo |
| 272 fi |
| 273 if [ "$do_restore_usr_bin_ld" = "1" ] |
| 274 then |
| 275 if sudo mv /usr/bin/ld.orig /usr/bin/ld |
| 276 then |
| 277 echo "Restored /usr/bin/ld.orig as /usr/bin/ld" |
| 278 else |
| 279 echo "Failed to restore /usr/bin/ld.orig as /usr/bin/ld" |
| 280 fi |
| 281 echo |
| 282 fi |
| 283 ;; |
| 284 esac |
| 285 |
| 286 # Check the gold version first. |
| 287 gold_up_to_date="1" |
| 288 case `/usr/local/gold/bin/ld --version` in |
255 *gold*2.2[1-9].*) ;; | 289 *gold*2.2[1-9].*) ;; |
256 * ) | 290 * ) |
| 291 gold_up_to_date="0" |
| 292 esac |
| 293 |
| 294 # Then check and make sure ld.bfd exists. |
| 295 if [ "$gold_up_to_date" = "1" ] && [ ! -x "/usr/local/gold/bin/ld.bfd" ] |
| 296 then |
| 297 gold_up_to_date="0" |
| 298 fi |
| 299 |
| 300 if [ "$gold_up_to_date" = "0" ] |
| 301 then |
257 if test "$do_inst_gold" = "" | 302 if test "$do_inst_gold" = "" |
258 then | 303 then |
259 echo "Gold is a new linker that links Chrome 5x faster than ld." | 304 echo "Gold is a new linker that links Chrome 5x faster than GNU ld." |
260 echo "Don't use it if you need to link other apps (e.g. valgrind, wine)" | 305 echo -n "*** To use the gold linker, " |
261 echo -n "REPLACE SYSTEM LINKER ld with gold and back up ld? (y/N) " | 306 echo "you must pass -B/usr/local/gold/bin/ to g++ ***" |
| 307 echo -n "Install the gold linker? (y/N) " |
262 if yes_no 1; then | 308 if yes_no 1; then |
263 do_inst_gold=1 | 309 do_inst_gold=1 |
264 fi | 310 fi |
265 fi | 311 fi |
266 if test "$do_inst_gold" = "1" | 312 if test "$do_inst_gold" = "1" |
267 then | 313 then |
268 # If the system provides a good version of gold, just install it. | 314 # If the system provides a good version of gold, just install it. |
269 if apt-cache show binutils-gold | grep -Eq 'Version: 2.2[1-9].*'; then | 315 if apt-cache show binutils-gold | grep -Eq 'Version: 2.2[1-9].*'; then |
270 echo "Installing binutils-gold. Backing up ld as ld.single." | 316 echo "Installing binutils-gold. Backing up ld as ld.single." |
271 sudo apt-get install binutils-gold | 317 sudo apt-get install binutils-gold |
272 else | 318 else |
273 # FIXME: avoid installing as /usr/bin/ld | 319 echo "Building binutils with gold..." |
274 echo "Building binutils. Backing up ld as ld.orig." | |
275 install_gold || exit 99 | 320 install_gold || exit 99 |
276 fi | 321 fi |
277 else | 322 else |
278 echo "Not installing gold." | 323 echo "Not installing gold." |
279 fi | 324 fi |
280 esac | 325 fi |
281 | 326 |
282 # Install 32bit backwards compatibility support for 64bit systems | 327 # Install 32bit backwards compatibility support for 64bit systems |
283 if [ "$(uname -m)" = "x86_64" ]; then | 328 if [ "$(uname -m)" = "x86_64" ]; then |
284 if test "$do_inst_lib32" = "" | 329 if test "$do_inst_lib32" = "" |
285 then | 330 then |
286 echo "Installing 32bit libraries not already provided by the system" | 331 echo "Installing 32bit libraries not already provided by the system" |
287 echo | 332 echo |
288 echo "This is only needed to build a 32-bit Chrome on your 64-bit system." | 333 echo "This is only needed to build a 32-bit Chrome on your 64-bit system." |
289 echo | 334 echo |
290 echo "While we only need to install a relatively small number of library" | 335 echo "While we only need to install a relatively small number of library" |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
456 sed -e 's/[.]so[.][0-9].*/.so/' | | 501 sed -e 's/[.]so[.][0-9].*/.so/' | |
457 sort -u); do | 502 sort -u); do |
458 [ "x${i##*/}" = "xld-linux.so" ] && continue | 503 [ "x${i##*/}" = "xld-linux.so" ] && continue |
459 [ -r "$i" ] && continue | 504 [ -r "$i" ] && continue |
460 j="$(ls "$i."* | sed -e 's/.*[.]so[.]\([^.]*\)$/\1/;t;d' | | 505 j="$(ls "$i."* | sed -e 's/.*[.]so[.]\([^.]*\)$/\1/;t;d' | |
461 sort -n | tail -n 1)" | 506 sort -n | tail -n 1)" |
462 [ -r "$i.$j" ] || continue | 507 [ -r "$i.$j" ] || continue |
463 sudo ln -s "${i##*/}.$j" "$i" | 508 sudo ln -s "${i##*/}.$j" "$i" |
464 done | 509 done |
465 fi | 510 fi |
OLD | NEW |