11#! /usr/bin/env sh
2- set -xe
2+ set -e
33
44# This script invokes all other build-*.sh scripts.
55# Inside the container, it is called by build-in-docker.sh.
66# FIXME: Add another entry point script to perform build directly on host.
77
8+ set -x
89cd " $( dirname " $0 " ) "
910. " $REPO_ROOT /config"
1011. ./global-vars
12+ set +x
1113
1214write_clang_config_files () {
1315 cat > " $INSTALL_DIR /bin/aarch64-unknown-linux-pauthtest.cfg" << EOF
@@ -20,19 +22,63 @@ $EXTRA_FLAGS_MUSL
2022EOF
2123}
2224
25+ # Usage: try_build <stamp-prefix> <command line...>
26+ # Note: CROSS_TARGET is added to the stamp file name.
27+ #
28+ # Try performing the build step:
29+ # * skip this step if the stamp file already exists
30+ # * create the stamp file if the build step succeeded
31+ # * print an error to the user if the build step failed
32+ #
33+ # The primary goal of this function is to improve usability of restarting
34+ # partially successful builds performed on the host. Note that no directories
35+ # are removed in case of an error to minimize the amount of "rm -rf" calls
36+ # performed on the host and to simplify the debugging of build errors.
37+ try_build () {
38+ local stamp_prefix=" $1 "
39+ shift 1
40+
41+ local build_dir=" ${BUILD_TMP} /${stamp_prefix} -${CROSS_TARGET} "
42+
43+ local stamp_file_name=" ${build_dir} .stamp"
44+ if [ -f " $stamp_file_name " ]; then
45+ echo " Stamp found, skipping '$* '."
46+ return
47+ fi
48+
49+ if [ -d " $build_dir " ]; then
50+ echo " Incomplete build directory is found at $build_dir ." 1>&2
51+ exit 1
52+ fi
53+
54+ # Try performing the build step.
55+ # On error, print a message to the user instead on exiting due to 'set -e'.
56+
57+ export BUILD_DIR=" $build_dir " # Used by called subprocess.
58+ echo " Executing: $* "
59+ if " $@ " ; then
60+ touch " $stamp_file_name "
61+ else
62+ echo " Execution of '$stamp_prefix ' step for '$CROSS_TARGET ' failed." 1>&2
63+ echo " Please remove incomplete build at '$BUILD_DIR ' before restarting the build." 1>&2
64+ exit 1
65+ fi
66+ }
67+
2368build_target_libs () {
2469 export CROSS_TARGET
2570 export TARGET_PREFIX=" $INSTALL_DIR /$CROSS_TARGET /usr"
26- ./create-symlinks.sh
27- ./build-linux-header.sh
28- LIBC_STARTFILE_STAGE=1 ./build-musl.sh
29- COMPILER_RT_BUILD=builtins ./build-compiler-rt.sh
30- ./build-musl.sh
31- ./build-runtimes.sh
32- COMPILER_RT_BUILD=full ./build-compiler-rt.sh
71+ echo " Building runtime libs in $TARGET_PREFIX ..."
72+ try_build symlinks ./create-symlinks.sh
73+ try_build linux-headers ./build-linux-header.sh
74+ LIBC_STARTFILE_STAGE=1 try_build musl-startfiles ./build-musl.sh
75+ COMPILER_RT_BUILD=builtins try_build compiler-rt-builtins ./build-compiler-rt.sh
76+ try_build musl-full ./build-musl.sh
77+ try_build runtimes ./build-runtimes.sh
78+ COMPILER_RT_BUILD=full try_build compiler-rt-full ./build-compiler-rt.sh
3379}
3480
35- ./build-llvm.sh
81+ CROSS_TARGET= " all " try_build llvm ./build-llvm.sh
3682
3783write_clang_config_files
3884CROSS_TARGET=" aarch64-linux-pauthtest" build_target_libs
0 commit comments