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

Side by Side Diff: tools/llvm/trusted-toolchain-creator.armel.lucid.sh

Issue 10736073: Rename tools/llvm to tools/trusted_cross_toolchains (Closed) Base URL: svn://svn.chromium.org/native_client/trunk/src/native_client/
Patch Set: Created 8 years, 5 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 | « tools/llvm/qemu_tool.sh ('k') | tools/llvm/trusted-toolchain-creator.armel.precise.sh » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 #!/bin/bash
2 # Copyright (c) 2012 The Native Client Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file.
5 #
6 #@ This script builds the (trusted) cross toolchain for arm.
7 #@ It must be run from the native_client/ directory.
8 #@
9 #@ The toolchain consists primarily of a jail with arm header and libraries.
10 #@ It also provides additional tools such as QEMU.
11 #@ It does NOT provide the actual cross compiler anymore.
12 #@ The cross compiler is now comming straight from a debian package.
13 #@ So there is a one-time step required for all machines using this TC.
14 #@ Which is especially true for build-bots:
15 #@
16 #@ tools/llvm/trusted-toolchain-creator.armel.lucid.sh InstallCrossArmBasePack agesManual
17 #@
18 #@
19 #@ Generally this script is invoked as:
20 #@ tools/llvm/trusted-toolchain-creator.armel.lucid.sh <mode> <args>*
21 #@ Available modes are shown below.
22 #@
23 #@
24 #@ This Toolchain was tested with Ubuntu Lucid
25 #@
26 #@ Usage of this TC:
27 #@ compile: arm-linux-gnueabi-gcc -march=armv7-a -isystem ${JAIL}/usr/include
28 #@ link: arm-linux-gnueabi-gcc -L${JAIL}/usr/lib -L${JAIL}/usr/lib/arm-linux -gnueabi
29 #@ -L${JAIL}/lib -L${JAIL}/lib/arm-linux-gnueabi
30 #@
31 #@ Usage of QEMU
32 #@ TBD
33 #@
34 #@ List of modes:
35
36 ######################################################################
37 # Config
38 ######################################################################
39
40 set -o nounset
41 set -o errexit
42
43 readonly SCRIPT_DIR=$(dirname $0)
44
45 # this where we create the ARMEL "jail"
46 readonly INSTALL_ROOT=$(pwd)/toolchain/linux_arm-trusted
47
48 readonly TMP=/tmp/arm-crosstool-natty
49
50 readonly REQUIRED_TOOLS="wget"
51
52 readonly MAKE_OPTS="-j8"
53
54 ######################################################################
55 # Package Config
56 ######################################################################
57
58 # this where we get the cross toolchain from for the manual install:
59 readonly CROSS_ARM_TC_REPO=http://archive.ubuntu.com/ubuntu
60 # this is where we get all the armel packages from
61 readonly ARMEL_REPO=http://ports.ubuntu.com/ubuntu-ports
62 #
63 readonly PACKAGE_LIST="${ARMEL_REPO}/dists/natty/main/binary-armel/Packages.bz2"
64
65 # Optional:
66 # gdb-arm-linux-gnueabi
67 # automake1.9
68 # libtool
69 readonly CROSS_ARM_TC_PACKAGES="\
70 gcc-4.5-arm-linux-gnueabi-base \
71 libc6-armel-cross \
72 libc6-dev-armel-cross \
73 libgcc1-armel-cross \
74 libgomp1-armel-cross \
75 linux-libc-dev-armel-cross \
76 libgcc1-dbg-armel-cross \
77 libgomp1-dbg-armel-cross \
78 libstdc++6-4.4-dev-armel-cross \
79 binutils-arm-linux-gnueabi \
80 gcc-4.5-locales \
81 cpp-4.5-arm-linux-gnueabi \
82 cpp-arm-linux-gnueabi \
83 gcc-4.5-arm-linux-gnueabi \
84 libmudflap0-4.5-dev-armel-cross \
85 libmudflap0-dbg-armel-cross
86 "
87
88 # NOTE: the package listing here should be updated using the
89 # GeneratePackageListXXX() functions below
90 readonly CROSS_ARM_TC_DEP_FILES_64="$(cat ${SCRIPT_DIR}/packagelist.amd64.crosst ool)"
91
92 readonly CROSS_ARM_TC_DEP_FILES_32="\
93 ${CROSS_ARM_TC_DEP_FILES_64//_amd64.deb/_i386.deb}"
94
95 readonly BUILD_ARCH=$(uname -m)
96 if [ "${BUILD_ARCH}" == "i386" ] ||
97 [ "${BUILD_ARCH}" == "i686" ] ; then
98 readonly CROSS_ARM_TC_DEP_FILES="${CROSS_ARM_TC_DEP_FILES_32}"
99 readonly EXTRA_PACKAGES="make"
100 elif [ "${BUILD_ARCH}" == "x86_64" ] ; then
101 readonly CROSS_ARM_TC_DEP_FILES="${CROSS_ARM_TC_DEP_FILES_64}"
102 # 32bit compatibility TCs
103 readonly EXTRA_PACKAGES="make ia32-libs libc6-i386"
104 else
105 echo "Unknown build arch '${BUILD_ARCH}'"
106 exit -1
107 fi
108
109
110 # Jail packages: these are good enough for native client
111 readonly ARMEL_BASE_PACKAGES="\
112 libssl-dev \
113 libssl0.9.8 \
114 libgcc1 \
115 libc6 \
116 libc6-dev \
117 libstdc++6 \
118 libx11-dev \
119 libx11-6 \
120 x11proto-core-dev \
121 libxt-dev \
122 libxt6 \
123 zlib1g \
124 zlib1g-dev"
125
126 # Additional jail packages needed to build chrome
127 # NOTE: the package listing here should be updated using the
128 # GeneratePackageListXXX() functions below
129 readonly ARMEL_BASE_DEP_FILES="$(cat ${SCRIPT_DIR}/packagelist.natty.armel.base) "
130
131 readonly ARMEL_EXTRA_PACKAGES="\
132 krb5-multidev \
133 libasound2 \
134 libasound2-dev \
135 libatk1.0-0 \
136 libatk1.0-dev \
137 libbz2-1.0 \
138 libbz2-dev \
139 libcairo2 \
140 libcairo2-dev \
141 libcups2 \
142 libcups2-dev \
143 libdbus-1-3 \
144 libdbus-1-dev \
145 libexpat1 \
146 libexpat1-dev \
147 libfontconfig1 \
148 libfontconfig1-dev \
149 libfreetype6 \
150 libfreetype6-dev \
151 libgconf2-4 \
152 libgconf2-dev \
153 libgdk-pixbuf2.0-0 \
154 libgdk-pixbuf2.0-dev \
155 libgtk2.0-0 \
156 libgtk2.0-dev \
157 libglib2.0-0 \
158 libglib2.0-dev \
159 libgnome-keyring-dev \
160 libkrb5-dev \
161 libnspr4 \
162 libnspr4-dev \
163 libnss3 \
164 libnss3-dev \
165 liborbit2 \
166 libpam0g \
167 libpam0g-dev \
168 libpango1.0-0 \
169 libpango1.0-dev \
170 libpcre3 \
171 libpcre3-dev \
172 libpixman-1-0 \
173 libpixman-1-dev \
174 libpng12-0 \
175 libpng12-dev \
176 libselinux1 \
177 libudev0 \
178 libudev-dev \
179 libxext-dev \
180 libxext6 \
181 libxau-dev \
182 libxau6 \
183 libxcb1 \
184 libxcb1-dev \
185 libxcb-render0 \
186 libxcb-render0-dev \
187 libxcb-shm0 \
188 libxcb-shm0-dev \
189 libxcomposite1 \
190 libxcomposite-dev \
191 libxcursor1 \
192 libxcursor-dev \
193 libxdamage1 \
194 libxdamage-dev \
195 libxdmcp6 \
196 libxfixes3 \
197 libxfixes-dev \
198 libxi6 \
199 libxi-dev \
200 libxinerama1 \
201 libxinerama-dev \
202 libxrandr2 \
203 libxrandr-dev \
204 libxrender1 \
205 libxrender-dev \
206 libxss1 \
207 libxss-dev \
208 libxtst6 \
209 libxtst-dev \
210 x11proto-composite-dev \
211 x11proto-damage-dev \
212 x11proto-fixes-dev \
213 x11proto-input-dev \
214 x11proto-record-dev \
215 x11proto-render-dev \
216 x11proto-scrnsaver-dev \
217 x11proto-xext-dev"
218
219 # NOTE: the package listing here should be updated using the
220 # GeneratePackageListXXX() functions below
221 readonly ARMEL_EXTRA_DEP_FILES="$(cat ${SCRIPT_DIR}/packagelist.natty.armel.extr a)"
222
223 ######################################################################
224 # Helper
225 ######################################################################
226
227 Banner() {
228 echo "######################################################################"
229 echo $*
230 echo "######################################################################"
231 }
232
233
234 SubBanner() {
235 echo "......................................................................"
236 echo $*
237 echo "......................................................................"
238 }
239
240
241 Usage() {
242 egrep "^#@" $0 | cut --bytes=3-
243 }
244
245
246 DownloadOrCopy() {
247 if [[ -f "$2" ]] ; then
248 echo "$2 already in place"
249 elif [[ $1 =~ 'http://' ]] ; then
250 SubBanner "downloading from $1 -> $2"
251 wget $1 -O $2
252 else
253 SubBanner "copying from $1"
254 cp $1 $2
255 fi
256 }
257
258 # some sanity checks to make sure this script is run from the right place
259 # with the right tools
260 SanityCheck() {
261 Banner "Sanity Checks"
262 if [[ $(basename $(pwd)) != "native_client" ]] ; then
263 echo "ERROR: run this script from the native_client/ dir"
264 exit -1
265 fi
266
267 if ! mkdir -p "${INSTALL_ROOT}" ; then
268 echo "ERROR: ${INSTALL_ROOT} can't be created."
269 exit -1
270 fi
271
272 if ! mkdir -p "${TMP}" ; then
273 echo "ERROR: ${TMP} can't be created."
274 exit -1
275 fi
276
277 for tool in ${REQUIRED_TOOLS} ; do
278 if ! which ${tool} ; then
279 echo "Required binary $tool not found."
280 echo "Exiting."
281 exit 1
282 fi
283 done
284 }
285
286
287 # TODO(robertm): consider wiping all of ${BASE_DIR}
288 ClearInstallDir() {
289 Banner "clearing dirs in ${INSTALL_ROOT}"
290 rm -rf ${INSTALL_ROOT}/*
291 }
292
293
294 CreateTarBall() {
295 local tarball=$1
296 Banner "creating tar ball ${tarball}"
297 tar cfz ${tarball} -C ${INSTALL_ROOT} .
298 }
299
300 ######################################################################
301 # One of these has to be run ONCE per machine
302 ######################################################################
303
304 #@
305 #@ InstallCrossArmBasePackages
306 #@
307 #@ This has been tested on 64bit ubuntu natty.
308 #@ For oneiric additional adjustments are necessary.
309 InstallCrossArmBasePackages() {
310 sudo apt-get install ${CROSS_ARM_TC_PACKAGES}
311 }
312
313 #@
314 #@ InstallCrossArmBasePackagesManual
315 #@
316 #@ This should work even for 64bit ubuntu lucid machine.
317 #@ The download part is more or less idem-potent, run it until
318 #@ all files have been downloaded.
319 InstallCrossArmBasePackagesManual() {
320 Banner "Install arm cross TC semi-automatically"
321
322 local dest=${TMP}/manual-tc-packages
323 mkdir -p ${dest}
324
325 SubBanner "Download packages"
326 for i in ${CROSS_ARM_TC_DEP_FILES} ; do
327 echo $i
328 url=${CROSS_ARM_TC_REPO}/pool/$i
329 file=${dest}/$(basename $i)
330 DownloadOrCopy ${url} ${file}
331 done
332
333 SubBanner "Package Sanity Check"
334
335 for i in ${dest}/*.deb ; do
336 ls -l $i
337 if [[ ! -s $i ]] ; then
338 echo
339 echo "ERROR: bad package $i"
340 exit -1
341 fi
342 done
343
344 SubBanner "Possibly install additional standard packages"
345 # these are needed for the TC packages we are about to install
346 sudo apt-get install libelfg0 libgmpxx4ldbl libmpc2 libppl7 libppl-c2
347 sudo apt-get install ${EXTRA_PACKAGES}
348
349 SubBanner "Install cross arm TC packages"
350 sudo dpkg -i ${dest}/*.deb
351 }
352
353 ######################################################################
354 #
355 ######################################################################
356
357 #@
358 #@ InstallTrustedLinkerScript
359 #@
360 #@ This forces the loading address of sel_ldr like programs
361 #@ to higher memory areas where they do not conflict with
362 #@ untrusted binaries.
363 #@ This likely no longer used because of "nacl_helper_bootstrap".
364 InstallTrustedLinkerScript() {
365 local trusted_ld_script=${INSTALL_ROOT}/ld_script_arm_trusted
366 # We are using the output of "ld --verbose" which contains
367 # the linker script delimited by "=========".
368 # We are changing the image start address to 70000000
369 # to move the sel_ldr and other images "out of the way"
370 Banner "installing trusted linker script to ${trusted_ld_script}"
371
372 arm-linux-gnueabi-ld --verbose |\
373 grep -A 10000 "=======" |\
374 grep -v "=======" |\
375 sed -e 's/00008000/70000000/g' > ${trusted_ld_script}
376 }
377
378 HacksAndPatches() {
379 rel_path=toolchain/linux_arm-trusted
380 Banner "Misc Hacks & Patches"
381 # these are linker scripts with absolute pathnames in them
382 # which we rewrite here
383 lscripts="${rel_path}/usr/lib/arm-linux-gnueabi/libpthread.so \
384 ${rel_path}/usr/lib/arm-linux-gnueabi/libc.so"
385
386 SubBanner "Rewriting Linker Scripts"
387 sed -i -e 's|/usr/lib/arm-linux-gnueabi/||g' ${lscripts}
388 sed -i -e 's|/lib/arm-linux-gnueabi/||g' ${lscripts}
389
390 # This is for chrome's ./build/linux/pkg-config-wrapper
391 # which overwrites PKG_CONFIG_PATH internally
392 SubBanner "Package Configs Symlink"
393 mkdir -p ${rel_path}/usr/share
394 ln -s ../lib/arm-linux-gnueabi/pkgconfig ${rel_path}/usr/share/pkgconfig
395 }
396
397
398 InstallMissingArmLibrariesAndHeadersIntoJail() {
399 Banner "Install Libs And Headers Into Jail"
400
401 mkdir -p ${TMP}/armel-packages
402 mkdir -p ${INSTALL_ROOT}
403 for file in $@ ; do
404 local package="${TMP}/armel-packages/${file##*/}"
405 Banner "installing ${file}"
406 DownloadOrCopy ${ARMEL_REPO}/pool/${file} ${package}
407 SubBanner "extracting to ${INSTALL_ROOT}"
408 if [[ ! -s ${package} ]] ; then
409 echo
410 echo "ERROR: bad package ${package}"
411 exit -1
412 fi
413 dpkg --fsys-tarfile ${package}\
414 | tar -xvf - --exclude=./usr/share -C ${INSTALL_ROOT}
415 done
416 }
417
418
419 CleanupJailSymlinks() {
420 Banner "jail symlink cleanup"
421
422 pushd ${INSTALL_ROOT}
423 find usr/lib -type l -printf '%p %l\n' | while read link target; do
424 # skip links with non-absolute paths
425 if [[ ${target} != /* ]] ; then
426 continue
427 fi
428 echo "${link}: ${target}"
429 case "${link}" in
430 usr/lib/arm-linux-gnueabi/*)
431 # Relativize the symlink.
432 ln -snfv "../../..${target}" "${link}"
433 ;;
434 usr/lib/*)
435 # Relativize the symlink.
436 ln -snfv "../..${target}" "${link}"
437 ;;
438 esac
439 # make sure we catch new bad links
440 if [ ! -r "${link}" ]; then
441 echo "ERROR: FOUND BAD LINK ${link}"
442 exit -1
443 fi
444 done
445 popd
446 }
447
448 #@
449 #@ BuildAndInstallQemu
450 #@
451 #@ Build ARM emulator including some patches for better tracing
452 #
453 # Historic Notes:
454 # Traditionally we were builidng static 32 bit images of qemu on a
455 # 64bit system which would run then on both x86-32 and x86-64 systems.
456 # The latest version of qemu contains new dependencies which
457 # currently make it impossible to build such images on 64bit systems
458 # We can build a static 64bit qemu but it does not work with
459 # the sandboxed translators for unknown reason.
460 # So instead we chose to build 32bit shared images.
461 #
462
463 #readonly QEMU_TARBALL=$(readlink -f ../third_party/qemu/qemu-1.0.1.tar.gz)
464 #readonly QEMU_DIR=qemu-1.0.1
465 readonly QEMU_TARBALL=$(readlink -f ../third_party/qemu/qemu-1.0.1.tar.gz)
466 readonly QEMU_PATCH=$(readlink -f ../third_party/qemu/qemu-1.0.1.patch_arm)
467 readonly QEMU_DIR=qemu-1.0.1
468
469 BuildAndInstallQemu() {
470 local saved_dir=$(pwd)
471 local tmpdir="${TMP}/qemu.nacl"
472
473 Banner "Building qemu in ${tmpdir}"
474 rm -rf ${tmpdir}
475 mkdir ${tmpdir}
476 cd ${tmpdir}
477 SubBanner "Untaring ${QEMU_TARBALL}"
478 tar zxf ${QEMU_TARBALL}
479 cd ${QEMU_DIR}
480
481 SubBanner "Patching ${QEMU_PATCH}"
482 patch -p1 < ${QEMU_PATCH}
483
484 SubBanner "Configuring"
485 env -i PATH=/usr/bin/:/bin \
486 ./configure \
487 --extra-cflags="-m32" \
488 --extra-ldflags="-Wl,-rpath=/lib32" \
489 --disable-system \
490 --enable-linux-user \
491 --disable-darwin-user \
492 --disable-bsd-user \
493 --target-list=arm-linux-user \
494 --disable-smartcard-nss \
495 --disable-sdl
496
497 # see above for why we can no longer use -static
498 # --static
499
500 SubBanner "Make"
501 env -i PATH=/usr/bin/:/bin \
502 V=99 make MAKE_OPTS=${MAKE_OPTS}
503
504 SubBanner "Install ${INSTALL_ROOT}"
505 cp arm-linux-user/qemu-arm ${INSTALL_ROOT}
506 cd ${saved_dir}
507 cp tools/llvm/qemu_tool.sh ${INSTALL_ROOT}
508 ln -sf qemu_tool.sh ${INSTALL_ROOT}/run_under_qemu_arm
509 }
510
511 #@
512 #@ BuildJail <tarball-name>
513 #@
514 #@ Build everything and package it
515 BuildJail() {
516 ClearInstallDir
517 InstallMissingArmLibrariesAndHeadersIntoJail \
518 ${ARMEL_BASE_DEP_FILES} \
519 ${ARMEL_EXTRA_DEP_FILES}
520 CleanupJailSymlinks
521 InstallTrustedLinkerScript
522 HacksAndPatches
523 AddChromeWrapperScripts
524 BuildAndInstallQemu
525 CreateTarBall $1
526 }
527
528 #@
529 #@ AddChromeWrapperScripts
530 #@
531 #@ Add some script which simplify cross compiling chrome.
532 AddChromeWrapperScripts() {
533 SubBanner "Installing Chrome Wrapper"
534
535 cp -a tools/llvm/chrome.cc.arm.sh ${INSTALL_ROOT}/chrome.cc.arm.sh
536 cp -a tools/llvm/chrome.cc.arm.sh ${INSTALL_ROOT}/chrome.c++.arm.sh
537
538 cp -a tools/llvm/chrome.cc.host.sh ${INSTALL_ROOT}/chrome.cc.host.sh
539 cp -a tools/llvm/chrome.cc.host.sh ${INSTALL_ROOT}/chrome.c++.host.sh
540
541 chmod a+rx ${INSTALL_ROOT}/chrome.c*.sh
542 }
543
544 #@
545 #@ Regenerate Package List
546 #@
547 #@ This will need some manual intervention, e.g. "pool/"
548 #@ needs to be stripped and special characters like may "+" cause problems
549 GeneratePackageList() {
550 DownloadOrCopy ${PACKAGE_LIST} ${TMP}/Packages.bz2
551 bzcat ${TMP}/Packages.bz2 | egrep '^(Package:|Filename:)' > ${TMP}/Packages
552 echo ${ARMEL_EXTRA_PACKAGES}
553 echo "# BEGIN:"
554 for pkg in $@ ; do
555 grep -A 1 "${pkg}\$" ${TMP}/Packages | egrep -o "pool/.*"
556 done
557 echo "# END:"
558 }
559
560 GeneratePackageListBase() {
561 GeneratePackageList "${ARMEL_BASE_PACKAGES}"
562 }
563
564 GeneratePackageListExtra() {
565 GeneratePackageList "${ARMEL_EXTRA_PACKAGES}"
566 }
567
568
569 if [[ $# -eq 0 ]] ; then
570 echo "ERROR: you must specify a mode on the commandline"
571 echo
572 Usage
573 exit -1
574 elif [[ "$(type -t $1)" != "function" ]]; then
575 echo "ERROR: unknown function '$1'." >&2
576 echo "For help, try:"
577 echo " $0 help"
578 exit 1
579 else
580 SanityCheck
581 "$@"
582 fi
OLDNEW
« no previous file with comments | « tools/llvm/qemu_tool.sh ('k') | tools/llvm/trusted-toolchain-creator.armel.precise.sh » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698