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.
6 # Script assumed to be run in native_client/
7 if [[ ${PWD} != */native_client ]]; then
8 echo "ERROR: must be run in native_client!"
16 # Transitionally, even though our new toolchain location is under
17 # toolchain/linux_x86_nacl_x86/nacl_x86_glibc we have to keep the old format
18 # inside of the tar (toolchain/linux_x86) so that the untar toolchain script
19 # is backwards compatible and can untar old tars. Eventually this will be
20 # unnecessary with the new package_version scheme since how to untar the
21 # tar file will be embedded inside of the package file so they can differ
23 export TOOLCHAINLOC=toolchain
24 export TOOLCHAINNAME=linux_x86
26 # This is where we want the toolchain when moving to native_client/toolchain.
27 OUT_TOOLCHAINLOC=toolchain/linux_x86
28 OUT_TOOLCHAINNAME=nacl_x86_glibc
30 TOOL_TOOLCHAIN="${TOOLCHAINLOC}/${TOOLCHAINNAME}"
31 OUT_TOOLCHAIN="${OUT_TOOLCHAINLOC}/${OUT_TOOLCHAINNAME}"
33 echo @@@BUILD_STEP gclient_runhooks@@@
34 gclient runhooks --force
36 echo @@@BUILD_STEP clobber_toolchain@@@
37 rm -rf scons-out tools/SRC/*.patch* tools/BUILD/* tools/out tools/toolchain \
38 tools/glibc tools/glibc.tar tools/toolchain.t* "${OUT_TOOLCHAIN}" .tmp ||
41 echo @@@BUILD_STEP clean_sources@@@
42 tools/update_all_repos_to_latest.sh
44 if [[ "${BUILDBOT_SLAVE_TYPE:-Trybot}" == "Trybot" ]]; then
45 echo @@@BUILD_STEP setup source@@@
46 (cd tools; ./buildbot_patch-toolchain-tries.sh)
49 echo @@@BUILD_STEP compile_toolchain@@@
52 make -j8 buildbot-build-with-glibc
53 if [[ "${BUILDBOT_SLAVE_TYPE:-Trybot}" != "Trybot" ]]; then
54 make install-glibc INST_GLIBC_PREFIX="$PWD"
56 mkdir -p SRC/newlib/newlib/libc/sys/nacl/include
57 cp -aiv ../src/untrusted/pthread/{pthread.h,semaphore.h} \
58 SRC/newlib/newlib/libc/sys/nacl/include
59 find SRC/newlib/newlib/libc/sys/nacl -name .svn -print0 | xargs -0 rm -rf --
60 ( cd SRC/newlib/newlib/libc/sys ; git add nacl )
61 for file in SRC/gcc/gcc/configure.ac SRC/gcc/gcc/configure ; do
62 cp -aiv $file $file.orig
63 sed -e s"|\(CROSS_SYSTEM_HEADER_DIR='\)\(\\\$(gcc_tooldir)/sys-include'\)|\1\$(DESTDIR)\2|" \
65 touch -r $file.orig $file
67 ( cd SRC/gcc/gcc ; git add $(basename $file) )
70 for patchname in SRC/*.patch ; do
72 bzip2 -k -9 "$patchname"
74 zcat "$patchname".gz > "$patchname"
77 cp -aiv {SRC/linux-headers-for-nacl/include/,}linux/getcpu.h
78 cp -aiv {../src/untrusted/include/machine/,}_default_types.h
79 cp -aiv ../LICENSE LICENSE
80 mv Makefile Makefile.orig
82 sed -e s"|^\\(CANNED_REVISION = \\)no$|\\1$BUILDBOT_GOT_REVISION|" \
83 -e s'|^\(SRCDIR =\).*$|\1|' \
84 -e s'|\(GCC_CC = \)gcc -m$(HOST_TOOLCHAIN_BITS)|\1gcc|' \
85 -e s'|\(GLIBC_CC =.*\)|\1 -I$(abspath $(dir $(THISMAKEFILE)))|' \
86 -e s'|\(LINUX_HEADERS = \).*|\1/usr/include|' \
87 -e s"|\\(export NACL_FAKE_SONAME\\).*|\\1 = ${NACL_GLIBC_COMMIT:0:8}|" \
88 < Makefile.orig > Makefile
89 tar czSvpf nacltoolchain-buildscripts-r${BUILDBOT_GOT_REVISION}.tar.gz \
90 LICENSE Makefile download_SRC.sh \
91 _default_types.h linux newlib-libc-script \
92 create_redirector{,s,s_cygwin}.sh redirector.exe redirect_table.txt \
93 redirector/redirector{.c,.h} redirector/redirector_table.txt
95 mv Makefile.orig Makefile
96 rm linux/getcpu.h _default_types.h LICENSE
100 if [[ "${BUILDBOT_SLAVE_TYPE:-Trybot}" != "Trybot" ]]; then
101 echo @@@BUILD_STEP tar_glibc@@@
104 cp --archive --sparse=always glibc glibc_sparse
106 mv glibc_sparse glibc
108 tar zScf ../glibc.tgz ./*
109 chmod a+r ../glibc.tgz
112 echo @@@BUILD_STEP archive_glibc@@@
113 rev="$(tools/glibc_revision.sh)"
114 wget https://gsdview.appspot.com/nativeclient-archive2/between_builders/x86_glibc/r"$rev"/glibc_x86.tar.gz -O /dev/null ||
115 $GSUTIL cp -a public-read \
117 gs://nativeclient-archive2/between_builders/x86_glibc/r"$rev"/glibc_x86.tar.gz
118 echo @@@STEP_LINK@download@http://gsdview.appspot.com/nativeclient-archive2/between_builders/x86_glibc/r"$rev"/@@@
121 if [[ "${BUILDBOT_SLAVE_TYPE:-Trybot}" != "Trybot" ]]; then
122 GSD_BUCKET=nativeclient-archive2
123 UPLOAD_REV=${BUILDBOT_GOT_REVISION}
124 UPLOAD_LOC=x86_toolchain/r${UPLOAD_REV}
126 GSD_BUCKET=nativeclient-trybot/packages
127 UPLOAD_REV=${BUILDBOT_BUILDERNAME}/${BUILDBOT_BUILDNUMBER}
128 UPLOAD_LOC=x86_toolchain/${UPLOAD_REV}
133 echo @@@BUILD_STEP sparsify_toolchain@@@
134 cp --archive --sparse=always "${TOOL_TOOLCHAIN}" "${TOOL_TOOLCHAIN}_sparse"
135 rm -rf "${TOOL_TOOLCHAIN}"
136 mv "${TOOL_TOOLCHAIN}_sparse" "${TOOL_TOOLCHAIN}"
137 echo @@@BUILD_STEP canonicalize timestamps@@@
138 ./canonicalize_timestamps.sh "${TOOL_TOOLCHAIN}"
139 echo @@@BUILD_STEP tar_toolchain@@@
140 tar Scf toolchain.tar "${TOOL_TOOLCHAIN}"
141 xz -k -9 toolchain.tar
142 bzip2 -k -9 toolchain.tar
143 gzip -n -9 toolchain.tar
144 for i in gz bz2 xz ; do
145 chmod a+r toolchain.tar.$i
146 echo "$(SHA1=$(sha1sum -b toolchain.tar.$i) ; echo ${SHA1:0:40})" \
147 > toolchain.tar.$i.sha1hash
151 echo @@@BUILD_STEP archive_build@@@
152 for suffix in gz gz.sha1hash bz2 bz2.sha1hash xz xz.sha1hash ; do
153 $GSUTIL cp -a public-read \
154 tools/toolchain.tar.$suffix \
155 gs://${GSD_BUCKET}/${UPLOAD_LOC}/toolchain_linux_x86.tar.$suffix
158 tools/nacltoolchain-buildscripts-r${BUILDBOT_GOT_REVISION}.tar.gz \
159 tools/SRC/*.patch* ; do
160 filename="${patch#tools/}"
161 filename="${filename#SRC/}"
162 $GSUTIL cp -a public-read \
164 gs://${GSD_BUCKET}/${UPLOAD_LOC}/$filename
166 echo @@@STEP_LINK@download@http://gsdview.appspot.com/${GSD_BUCKET}/${UPLOAD_LOC}/@@@
168 echo @@@BUILD_STEP archive_extract_package@@@
169 python build/package_version/package_version.py \
170 archive --archive-package=nacl_x86_glibc --extract \
171 --extra-archive gdb_i686_linux.tgz \
172 tools/toolchain.tar.bz2,toolchain/linux_x86@https://storage.googleapis.com/${GSD_BUCKET}/${UPLOAD_LOC}/toolchain_linux_x86.tar.bz2 \
174 echo @@@BUILD_STEP upload_package_info@@@
175 python build/package_version/package_version.py \
176 --cloud-bucket=${GSD_BUCKET} --annotate \
177 upload --skip-missing \
178 --upload-package=nacl_x86_glibc --revision=${UPLOAD_REV}
180 echo @@@BUILD_STEP glibc_tests64@@@
186 # The script should exit nonzero if any test run fails.
187 # But that should not short-circuit the script due to the 'set -e' behavior.
194 # Before we start testing, put in dummy mock archives so gyp can still untar
195 # the entire package.
196 python build/package_version/package_version.py fillemptytars \
197 --fill-package nacl_x86_glibc
199 # First run 32bit tests, then 64bit tests. Both should succeed.
200 export INSIDE_TOOLCHAIN=1
201 python buildbot/buildbot_standard.py --scons-args='no_gdb_tests=1' \
202 --step-suffix=' (32)' opt 32 glibc || fail
204 python buildbot/buildbot_standard.py --scons-args='no_gdb_tests=1' \
205 --step-suffix=' (64)' opt 64 glibc || fail
207 # sync_backports is obsolete and should probably be removed.
208 # if [[ "${BUILD_COMPATIBLE_TOOLCHAINS:-yes}" != "no" ]]; then
209 # echo @@@BUILD_STEP sync backports@@@
210 # rm -rf tools/BACKPORTS/ppapi*
211 # tools/BACKPORTS/build_backports.sh VERSIONS linux glibc