Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(338)

Side by Side Diff: build/install-build-deps.sh

Issue 7355033: Linux: Stop installing the gold linker as /usr/bin/ld. Ask users to pass -B/usr/local/gold/bin in... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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-urs-bin-ld) do_restore_usr_bin_ld=0;;
Evan Martin 2011/09/12 19:19:24 typo: usr
Lei Zhang 2011/09/12 22:00:09 Done.
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
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
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 "Automatically restore /usr/bin/ld to the original linker? (Y/n) "
Evan Martin 2011/09/12 19:19:24 suggestion: s/Automatically r/R/
Lei Zhang 2011/09/12 22:00:09 Done.
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 restore_success=0
276 sudo mv /usr/bin/ld.orig /usr/bin/ld && restore_success=1
277 if [ "$restore_success" = "1" ]
Evan Martin 2011/09/12 19:19:24 Three lines above can become this, no? if sudo mv
Lei Zhang 2011/09/12 22:00:09 Done.
278 then
279 echo "Restored /usr/bin/ld.orig as /usr/bin/ld"
280 else
281 echo "Failed to restore /usr/bin/ld.orig as /usr/bin/ld"
282 fi
283 echo
284 fi
285 ;;
286 esac
287
288 # Check the gold version first.
289 gold_up_to_date="1"
290 case `/usr/local/gold/bin/ld --version` in
255 *gold*2.2[1-9].*) ;; 291 *gold*2.2[1-9].*) ;;
256 * ) 292 * )
293 gold_up_to_date="0"
294 esac
295
296 # Then check and make sure ld.bfd exists.
297 if [ "$gold_up_to_date" = "1" ] && [ ! -x "/usr/local/gold/bin/ld.bfd" ]
298 then
299 gold_up_to_date="0"
300 fi
301
302 if [ "$gold_up_to_date" = "0" ]
303 then
257 if test "$do_inst_gold" = "" 304 if test "$do_inst_gold" = ""
258 then 305 then
259 echo "Gold is a new linker that links Chrome 5x faster than ld." 306 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)" 307 echo -n "*** To use the gold linker, "
261 echo -n "REPLACE SYSTEM LINKER ld with gold and back up ld? (y/N) " 308 echo "you must pass -B/usr/local/gold/bin/ to g++ ***"
309 echo -n "Install the gold linker? (y/N) "
262 if yes_no 1; then 310 if yes_no 1; then
263 do_inst_gold=1 311 do_inst_gold=1
264 fi 312 fi
265 fi 313 fi
266 if test "$do_inst_gold" = "1" 314 if test "$do_inst_gold" = "1"
267 then 315 then
268 # If the system provides a good version of gold, just install it. 316 # 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 317 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." 318 echo "Installing binutils-gold. Backing up ld as ld.single."
271 sudo apt-get install binutils-gold 319 sudo apt-get install binutils-gold
272 else 320 else
273 # FIXME: avoid installing as /usr/bin/ld 321 echo "Building binutils with gold..."
274 echo "Building binutils. Backing up ld as ld.orig."
275 install_gold || exit 99 322 install_gold || exit 99
276 fi 323 fi
277 else 324 else
278 echo "Not installing gold." 325 echo "Not installing gold."
279 fi 326 fi
280 esac 327 fi
281 328
282 # Install 32bit backwards compatibility support for 64bit systems 329 # Install 32bit backwards compatibility support for 64bit systems
283 if [ "$(uname -m)" = "x86_64" ]; then 330 if [ "$(uname -m)" = "x86_64" ]; then
284 if test "$do_inst_lib32" = "" 331 if test "$do_inst_lib32" = ""
285 then 332 then
286 echo "Installing 32bit libraries not already provided by the system" 333 echo "Installing 32bit libraries not already provided by the system"
287 echo 334 echo
288 echo "This is only needed to build a 32-bit Chrome on your 64-bit system." 335 echo "This is only needed to build a 32-bit Chrome on your 64-bit system."
289 echo 336 echo
290 echo "While we only need to install a relatively small number of library" 337 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
456 sed -e 's/[.]so[.][0-9].*/.so/' | 503 sed -e 's/[.]so[.][0-9].*/.so/' |
457 sort -u); do 504 sort -u); do
458 [ "x${i##*/}" = "xld-linux.so" ] && continue 505 [ "x${i##*/}" = "xld-linux.so" ] && continue
459 [ -r "$i" ] && continue 506 [ -r "$i" ] && continue
460 j="$(ls "$i."* | sed -e 's/.*[.]so[.]\([^.]*\)$/\1/;t;d' | 507 j="$(ls "$i."* | sed -e 's/.*[.]so[.]\([^.]*\)$/\1/;t;d' |
461 sort -n | tail -n 1)" 508 sort -n | tail -n 1)"
462 [ -r "$i.$j" ] || continue 509 [ -r "$i.$j" ] || continue
463 sudo ln -s "${i##*/}.$j" "$i" 510 sudo ln -s "${i##*/}.$j" "$i"
464 done 511 done
465 fi 512 fi
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698