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{.c,.exe} redirect_table.txt
94 mv Makefile.orig Makefile
95 rm linux/getcpu.h _default_types.h LICENSE
99 if [[ "${BUILDBOT_SLAVE_TYPE:-Trybot}" != "Trybot" ]]; then
100 echo @@@BUILD_STEP tar_glibc@@@
103 cp --archive --sparse=always glibc glibc_sparse
105 mv glibc_sparse glibc
107 tar zScf ../glibc.tgz ./*
108 chmod a+r ../glibc.tgz
111 echo @@@BUILD_STEP archive_glibc@@@
112 rev="$(tools/glibc_revision.sh)"
113 wget https://gsdview.appspot.com/nativeclient-archive2/between_builders/x86_glibc/r"$rev"/glibc_x86.tar.gz -O /dev/null ||
114 $GSUTIL cp -a public-read \
116 gs://nativeclient-archive2/between_builders/x86_glibc/r"$rev"/glibc_x86.tar.gz
117 echo @@@STEP_LINK@download@http://gsdview.appspot.com/nativeclient-archive2/between_builders/x86_glibc/r"$rev"/@@@
120 if [[ "${BUILDBOT_SLAVE_TYPE:-Trybot}" != "Trybot" ]]; then
121 GSD_BUCKET=nativeclient-archive2
122 UPLOAD_REV=${BUILDBOT_GOT_REVISION}
123 UPLOAD_LOC=x86_toolchain/r${UPLOAD_REV}
125 GSD_BUCKET=nativeclient-trybot/packages
126 UPLOAD_REV=${BUILDBOT_BUILDERNAME}/${BUILDBOT_BUILDNUMBER}
127 UPLOAD_LOC=x86_toolchain/${UPLOAD_REV}
132 echo @@@BUILD_STEP sparsify_toolchain@@@
133 cp --archive --sparse=always "${TOOL_TOOLCHAIN}" "${TOOL_TOOLCHAIN}_sparse"
134 rm -rf "${TOOL_TOOLCHAIN}"
135 mv "${TOOL_TOOLCHAIN}_sparse" "${TOOL_TOOLCHAIN}"
136 echo @@@BUILD_STEP canonicalize timestamps@@@
137 ./canonicalize_timestamps.sh "${TOOL_TOOLCHAIN}"
138 echo @@@BUILD_STEP tar_toolchain@@@
139 tar Scf toolchain.tar "${TOOL_TOOLCHAIN}"
140 xz -k -9 toolchain.tar
141 bzip2 -k -9 toolchain.tar
142 gzip -n -9 toolchain.tar
143 for i in gz bz2 xz ; do
144 chmod a+r toolchain.tar.$i
145 echo "$(SHA1=$(sha1sum -b toolchain.tar.$i) ; echo ${SHA1:0:40})" \
146 > toolchain.tar.$i.sha1hash
150 echo @@@BUILD_STEP archive_build@@@
151 for suffix in gz gz.sha1hash bz2 bz2.sha1hash xz xz.sha1hash ; do
152 $GSUTIL cp -a public-read \
153 tools/toolchain.tar.$suffix \
154 gs://${GSD_BUCKET}/${UPLOAD_LOC}/toolchain_linux_x86.tar.$suffix
157 tools/nacltoolchain-buildscripts-r${BUILDBOT_GOT_REVISION}.tar.gz \
158 tools/SRC/*.patch* ; do
159 filename="${patch#tools/}"
160 filename="${filename#SRC/}"
161 $GSUTIL cp -a public-read \
163 gs://${GSD_BUCKET}/${UPLOAD_LOC}/$filename
165 echo @@@STEP_LINK@download@http://gsdview.appspot.com/${GSD_BUCKET}/${UPLOAD_LOC}/@@@
167 echo @@@BUILD_STEP archive_extract_package@@@
168 python build/package_version/package_version.py \
169 archive --archive-package=nacl_x86_glibc --extract \
170 --extra-archive gdb_i686_linux.tgz \
171 tools/toolchain.tar.bz2,toolchain/linux_x86@https://storage.googleapis.com/${GSD_BUCKET}/${UPLOAD_LOC}/toolchain_linux_x86.tar.bz2 \
173 echo @@@BUILD_STEP upload_package_info@@@
174 python build/package_version/package_version.py \
175 --cloud-bucket=${GSD_BUCKET} --annotate \
176 upload --skip-missing \
177 --upload-package=nacl_x86_glibc --revision=${UPLOAD_REV}
179 echo @@@BUILD_STEP glibc_tests64@@@
185 # The script should exit nonzero if any test run fails.
186 # But that should not short-circuit the script due to the 'set -e' behavior.
193 # Before we start testing, put in dummy mock archives so gyp can still untar
194 # the entire package.
195 python build/package_version/package_version.py fillemptytars \
196 --fill-package nacl_x86_glibc
198 # First run 32bit tests, then 64bit tests. Both should succeed.
199 export INSIDE_TOOLCHAIN=1
200 python buildbot/buildbot_standard.py --scons-args='no_gdb_tests=1' \
201 --step-suffix=' (32)' opt 32 glibc || fail
203 python buildbot/buildbot_standard.py --scons-args='no_gdb_tests=1' \
204 --step-suffix=' (64)' opt 64 glibc || fail
206 # sync_backports is obsolete and should probably be removed.
207 # if [[ "${BUILD_COMPATIBLE_TOOLCHAINS:-yes}" != "no" ]]; then
208 # echo @@@BUILD_STEP sync backports@@@
209 # rm -rf tools/BACKPORTS/ppapi*
210 # tools/BACKPORTS/build_backports.sh VERSIONS linux glibc