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

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