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

Side by Side Diff: tools/trusted_cross_toolchains/trusted-toolchain-creator.mipsel.squeeze.sh

Issue 10703143: [MIPS] Toolchain scripts for MIPS architecture. (Closed) Base URL: http://src.chromium.org/native_client/trunk/src/native_client/
Patch Set: Changing dirs and renaming. 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
« no previous file with comments | « tools/trusted_cross_toolchains/qemu_tool_mips32.sh ('k') | 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
(Empty)
1 #!/bin/bash
2 # Copyright 2012 The Native Client Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can
4 # be found in the LICENSE file.
5 #
6 #@ This script creates the mips trusted SDK.
7 #@ It must be run from the native_client directory.
8
9 ######################################################################
10 # Config
11 ######################################################################
12
13 set -o nounset
14 set -o errexit
15
16 readonly CS_URL=https://sourcery.mentor.com/sgpp/lite/mips/portal/package9761/pu blic/mips-linux-gnu/mips-2011.09-75-mips-linux-gnu-i686-pc-linux-gnu.tar.bz2
17
18 export INSTALL_ROOT=$(pwd)/toolchain/linux_mips-trusted
19
20 export TMP=$(pwd)/toolchain/tmp/crosstool-trusted
robertm 2012/08/03 20:06:10 do these have to be "export" can they be "readonly
21
22 export CS_ROOT=${INSTALL_ROOT}/mips-release
23
24 readonly JAIL_MIPS32=${CS_ROOT}/mips-linux-gnu/libc/el
25
26 readonly MAKE_OPTS="-j8"
27 # These are simple compiler wrappers to force 32bit builds
28 readonly CC32=$(readlink -f pnacl/scripts/mygcc32)
29 readonly CXX32=$(readlink -f pnacl/scripts/myg++32)
30 ######################################################################
31 # Helper
32 ######################################################################
33
34 Banner() {
35 echo "######################################################################"
36 echo $*
37 echo "######################################################################"
38 }
39
40 SubBanner() {
41 echo "......................................................................"
42 echo $*
43 echo "...................................................................."
44 }
45
46 Usage() {
47 echo
48 echo "$0 trusted_sdk"
49 echo
50 echo "trusted_sdk - Build everything and package it"
51 echo
52 }
53
54 DownloadOrCopy() {
55 if [[ -f "$2" ]] ; then
56 echo "$2 already in place"
57 elif [[ $1 =~ 'http://' || $1 =~ 'https://' ]] ; then
58 SubBanner "downloading from $1 -> $2"
59 wget $1 -O $2
60 else
61 SubBanner "copying from $1"
62 cp $1 $2
63 fi
64 }
65
66 ######################################################################
67 #
68 ######################################################################
69
70 # some sanity checks to make sure this script is run from the right place
71 # with the right tools
72 SanityCheck() {
73 Banner "Sanity Checks"
74 if [[ $(basename $(pwd)) != "native_client" ]] ; then
75 echo "ERROR: run this script from the native_client/ dir"
76 exit -1
77 fi
78
79 if ! mkdir -p "${INSTALL_ROOT}" ; then
80 echo "ERROR: ${INSTALL_ROOT} can't be created."
81 exit -1
82 fi
83
84 for tool in cleanlinks wget ; do
85 if ! which ${tool} ; then
86 echo "Required binary $tool not found."
87 echo "Exiting."
88 exit 1
89 fi
90 done
91 }
92
93
94 ClearInstallDir() {
95 Banner "clearing dirs in ${INSTALL_ROOT}"
96 rm -rf ${INSTALL_ROOT}/*
97 }
98
99
100 CreateTarBall() {
101 local tarball=$1
102 Banner "creating tar ball ${tarball}"
103 tar cfz ${tarball}-mips.tgz -C ${INSTALL_ROOT} .
104 }
105
106
107 # try to keep the tarball small
108 PruneDirs() {
109 Banner "pruning code sourcery tree"
110 SubBanner "Size before: $(du -msc ${CS_ROOT})"
111 rm -rf ${CS_ROOT}/share
112 rm -rf ${CS_ROOT}/mips-linux-gnu/lib/uclibc
113 rm -rf ${CS_ROOT}/mips-linux-gnu/lib/soft-float
114 rm -rf ${CS_ROOT}/mips-linux-gnu/lib/micromips
115
116 rm -rf ${CS_ROOT}/mips-linux-gnu/libc/uclibc
117 rm -rf ${CS_ROOT}/mips-linux-gnu/libc/soft-float
118 rm -rf ${CS_ROOT}/mips-linux-gnu/libc/micromips
119
120 rm -rf ${CS_ROOT}/lib/gcc/mips-linux-gnu/4.4.1/uclibc
121 rm -rf ${CS_ROOT}/lib/gcc/mips-linux-gnu/4.4.1/soft-float
122 rm -rf ${CS_ROOT}/lib/gcc/mips-linux-gnu/4.4.1/micromips
123
124 rm -rf ${CS_ROOT}/mips-linux-gnu/include/c++/4.4.1/mips-linux-gnu/uclibc
125 rm -rf ${CS_ROOT}/mips-linux-gnu/include/c++/4.4.1/mips-linux-gnu/soft-float
126 rm -rf ${CS_ROOT}/mips-linux-gnu/include/c++/4.4.1/mips-linux-gnu/micromips
127
128 SubBanner "Size after: $(du -msc ${CS_ROOT})"
129 }
130
131
132 # Download the codesourcery tarball or use a local copy when available.
133 DownloadOrCopyAndInstallCodeSourceryTarball() {
134 Banner "Installing Codesourcery Toolchain"
135 local tarball="${TMP}/${CS_URL##*/}"
136 DownloadOrCopy ${CS_URL} ${tarball}
137
138 SubBanner "Untaring ${INSTALL_ROOT}/${tarball}"
139 tar jxf ${tarball} -C ${INSTALL_ROOT}
140
141 save=$(pwd)
robertm 2012/08/03 20:06:10 use pushd/ popd
142 cd ${INSTALL_ROOT}
143 mv mips-* mips-release
144 cd ${save}
145 }
146
147
148 InstallTrustedLinkerScript() {
149 local trusted_ld_script=${INSTALL_ROOT}/ld_script_mips_trusted
150 # We are using the output of "ld --verbose" which contains
151 # the linker script delimited by "=========".
152 # We are changing the image start address to 70000000
153 # to move the sel_ldr and other images "out of the way"
154 Banner "installing trusted linker script to ${trusted_ld_script}"
155
156 ${CS_ROOT}/bin/mips-linux-gnu-ld --verbose |\
157 grep -A 10000 "=======" |\
158 grep -v "=======" |\
159 sed -e 's/0400000/70000000/g' > ${trusted_ld_script}
160 }
161
162
163 InstallMissingHeaders() {
164 Banner "installing openssl headers from local system"
165 cp -r /usr/include/openssl ${JAIL_MIPS32}/usr/include/
166 }
167
168
169 MissingSharedLibCleanup() {
170 Banner "Cleanup dangling symlinks"
171 }
172
173 # ----------------------------------------------------------------------
174 # mips32 deb files to complete our code sourcery jail
175 # ----------------------------------------------------------------------
176
177 readonly REPO=http://ftp.debian.org/debian
robertm 2012/08/03 20:06:10 REPO is very generic - can this be made more speci
178 readonly MIPS32_PACKAGES=${REPO}/dists/squeeze/main/binary-mipsel/Packages.bz2
179
180 readonly TMP_PACKAGELIST_MIPS32=${TMP}/../packagelist_mipsel.tmp
181
182 # These are good enough for native client
183 readonly BASE_PACKAGES="\
184 libssl0.9.8 \
185 libssl-dev \
186 libx11-6 \
187 libx11-dev \
188 x11proto-core-dev \
189 libxt6 \
190 libxt-dev \
191 zlib1g \
192 zlib1g-dev \
193 libasound2 \
194 libasound2-dev \
195 libaa1 \
196 libaa1-dev \
197 libxau-dev \
198 libxau6 \
199 libxcb1 \
200 libxcb1-dev \
201 libxcb-render0 \
202 libxcb-render0-dev \
203 libxcb-render-util0 \
204 libxcb-render-util0-dev \
205 libxcb-shm0 \
206 libxcb-shm0-dev \
207 libxdmcp6 \
208 libxdmcp-dev \
209 libxss1 \
210 libxss-dev"
211
212 GeneratePackageLists() {
213 Banner "generating package lists for mips32"
214 echo -n > ${TMP_PACKAGELIST_MIPS32}
215 DownloadOrCopy ${MIPS32_PACKAGES} ${TMP}/../Packages_mipsel.bz2
216 bzcat ${TMP}/../Packages_mipsel.bz2 | egrep '^(Package:|Filename:)' > ${TMP}/. ./Packages_mipsel
217 for pkg in ${BASE_PACKAGES} ; do
218 grep -A 1 "${pkg}\$" ${TMP}/../Packages_mipsel | egrep -o "pool/.*" >> ${TM P_PACKAGELIST_MIPS32}
219 done
220 }
221
222 InstallMissingLibraries() {
223 readonly DEP_FILES_NEEDED_MIPS32=$(cat ${TMP_PACKAGELIST_MIPS32})
224 for file in ${DEP_FILES_NEEDED_MIPS32} ; do
225 local package="${TMP}/${file##*/}"
226 Banner "installing ${file}"
227 DownloadOrCopy ${REPO}/${file} ${package}
228 SubBanner "extracting to ${JAIL_MIPS32}"
229 dpkg --fsys-tarfile ${package}\
230 | tar -xvf - --exclude=./usr/share -C ${JAIL_MIPS32}
231 done
232
233 Banner "some cleanup"
234
235 save=$(pwd)
robertm 2012/08/03 20:06:10 use pushd / popd
236 cd ${JAIL_MIPS32}/usr/lib/
237 cleanlinks > /dev/null 2> /dev/null
238 FixLibs
239 cd ${save}
240 }
241
242 FixLibs() {
243 Banner "Fixing libraries"
244
245 rm -f libbz2.so
246 ln -s ../../lib/libbz2.so.1 libbz2.so
247
248 rm -f libm.so
249 ln -s ../../lib/libm.so.6 libm.so
250
251 rm -f libdl.so
252 ln -s ../../lib/libdl.so.2 libdl.so
253
254 rm -f librt.so
255 ln -s ../../lib/librt.so.1 librt.so
256
257 rm -f libpcre.so
258 ln -s ../../lib/libpcre.so.3 libpcre.so
259
260 rm -f libresolv.so
261 ln -s ../../lib/libresolv.so.2 libresolv.so
262
263 echo "OUTPUT_FORMAT(elf32-tradlittlemips)" > libc.so
264 echo "GROUP ( libc.so.6 libc_nonshared.a AS_NEEDED ( ld.so.1 ) )" >> libc.so
265
266 echo "OUTPUT_FORMAT(elf32-tradlittlemips)" > libpthread.so
267 echo "GROUP ( libpthread.so.0 libpthread_nonshared.a )" >> libpthread.so
268 }
269
270 BuildAndInstallQemu() {
271 local saved_dir=$(pwd)
272 local tmpdir="${TMP}/qemu-mips.nacl"
273 local patch_mips32=$(readlink -f ../third_party/qemu/qemu-0.12.5-mips.patch)
274 local tarball="qemu-0.12.5.tar.gz"
275 local download="http://download.savannah.gnu.org/releases/qemu/qemu-0.12.5.tar .gz"
robertm 2012/08/03 20:06:10 make download and patch_mips32 toplevel readonlys
276 Banner "Building qemu in ${tmpdir}"
277 rm -rf ${tmpdir}
278 mkdir ${tmpdir}
279 cd ${tmpdir}
280 SubBanner "Downloading"
281 wget -c ${download}
282 SubBanner "Untaring"
283 tar zxf ${tarball}
284 cd qemu-0.12.5
285 SubBanner "Patching"
286 patch -p1 < ${patch_mips32}
287
288 echo
289 echo "NOTE: on 64 bit systems you will need to the following 32bit libs:"
290 echo "lib32z1-dev"
291 echo
292
293 SubBanner "Configuring"
294 env -i PATH=/usr/bin/:/bin \
295 ./configure \
296 --cc=${CC32} \
297 --disable-system \
298 --enable-linux-user \
299 --disable-darwin-user \
300 --disable-bsd-user \
301 --target-list=mipsel-linux-user \
302 --disable-sdl \
303 --disable-linux-aio \
304 --static
305
306 SubBanner "Make"
307 env -i PATH=/usr/bin/:/bin \
308 make MAKE_OPTS=${MAKE_OPTS}
309
310 SubBanner "Install"
311 cp mipsel-linux-user/qemu-mipsel ${INSTALL_ROOT}/qemu-mips32
312 cd ${saved_dir}
313 cp tools/trusted_cross_toolchains/qemu_tool_mips32.sh ${INSTALL_ROOT}
314 ln -sf qemu_tool_mips32.sh ${INSTALL_ROOT}/run_under_qemu_mips32
315 }
316 ######################################################################
317 # Main
318 ######################################################################
319
320 if [[ $# -eq 0 ]] ; then
321 echo "you must specify a mode on the commandline:"
322 echo
323 Usage
324 exit -1
325
326 elif [[ $1 == "trusted_sdk" ]]; then
327 mkdir -p ${TMP}
328 SanityCheck
329 ClearInstallDir
330 DownloadOrCopyAndInstallCodeSourceryTarball
331 PruneDirs
332 GeneratePackageLists
333 InstallMissingHeaders
334 InstallMissingLibraries
335 MissingSharedLibCleanup
336 InstallTrustedLinkerScript
337 BuildAndInstallQemu
338 CreateTarBall $1
339
340 else
341 Usage
342 exit -1
343
344 fi
345
OLDNEW
« no previous file with comments | « tools/trusted_cross_toolchains/qemu_tool_mips32.sh ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698