blob: 878e8530bcd423edb19d10492b7e2d2057e5a545 [file] [log] [blame]
#!/bin/bash
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
set -o errtrace
trap 'echo Fatal error: script $0 aborting at line $LINENO, command \"$BASH_COMMAND\" returned $?; exit 1' ERR
snapshot="2022.03.12.131524"
snapshot_year=`echo $snapshot | cut -d . -f 1`
snapshot_month=`echo $snapshot | cut -d . -f 2`
snapshot_day=`echo $snapshot | cut -d . -f 3`
snapshot_time=`echo $snapshot | cut -d . -f 4`
glibc_version=2.33-r16
# Upgrade CrOS toolchain to GCC 10.2.0 ${snapshot}
function build_toolchain_arm_none_eabi {
pushd ${SCRIPT_DIR}
rm -rf arm
# 1. Obtain {toolchain,glibc} prebuilts from Chrome OS.
gsutil.py cp gs://chromiumos-sdk/${snapshot_year}/${snapshot_month}/arm-none-eabi-${snapshot}.tar.xz .
gsutil.py cp gs://chromeos-prebuilt/host/amd64/amd64-host/chroot-${snapshot}/packages/cross-arm-none-eabi/newlib-4.1.0.tbz2 .
# 2. Extract downloaded toolchain (overwrite armv7a contents)
rm -rf arm
mkdir arm
tar -C arm -xf arm-none-eabi-${snapshot}.tar.xz
tar -C arm -xf newlib-4.1.0.tbz2
rm arm-none-eabi-${snapshot}.tar.xz newlib-4.1.0.tbz2
# 3. Make copies of libgcc_s.so.1 to fit with chromecast build system.
cp arm/lib/libgcc_s.so.1 arm/usr/arm-none-eabi/lib/
# 4. Add NOTICE files.
curl -L https://www.gnu.org/licenses/lgpl-2.1.txt > arm/usr/arm-none-eabi/NOTICE-eglibc
curl -L https://gnu.org/licenses/gpl-3.0.txt > arm/usr/arm-none-eabi/NOTICE-gdb
# 6. Customize default linker to be bfd, not gold.
sed -i -e "s/-gold//g" arm/bin/arm-none-eabi-ld
popd # ${SCRIPT_DIR}
}
# Upgrade CrOS toolchain to GCC 10.2.0 ${snapshot}
function build_toolchain {
pushd ${SCRIPT_DIR}
local readonly arch=${1}
local readonly abi=${2}
rm -rf ${arch}
# 1. Obtain {toolchain,glibc} prebuilts from Chrome OS.
gsutil.py cp gs://chromiumos-sdk/${snapshot_year}/${snapshot_month}/${arch}-cros-linux-${abi}-${snapshot}.tar.xz .
gsutil.py cp gs://chromeos-prebuilt/host/amd64/amd64-host/chroot-${snapshot}/packages/cross-${arch}-cros-linux-${abi}/glibc-${glibc_version}.tbz2 .
# 2. Extract downloaded toolchain (overwrite armv7a contents)
rm -rf ${arch}
mkdir ${arch}
tar -C ${arch} -xf ${arch}-cros-linux-${abi}-${snapshot}.tar.xz
tar -C ${arch} -xf glibc-${glibc_version}.tbz2
rm ${arch}-cros-linux-${abi}-${snapshot}.tar.xz glibc-${glibc_version}.tbz2
# 3. Make copies of libgcc_s.so.1 to fit with chromecast build system.
cp ${arch}/usr/lib/gcc/${arch}-cros-linux-${abi}/10.2.0/libgcc_s.so.1 ${arch}/usr/${arch}-cros-linux-${abi}/lib/
# 4. Add NOTICE files.
curl -L https://www.gnu.org/licenses/lgpl-2.1.txt > ${arch}/usr/${arch}-cros-linux-${abi}/NOTICE-eglibc
curl -L https://gnu.org/licenses/gpl-3.0.txt > ${arch}/usr/${arch}-cros-linux-${abi}/NOTICE-gdb
# 8. Apply our patches
# Remove any empty folders created by unzipping the toolchains that are not
# checked into git. Those can be problematic when applying patches.
find . -type d -empty -delete
pushd ${arch}
patch -p1 < ${SCRIPT_DIR}/patches/eureka.patch
popd
if [ -f ${SCRIPT_DIR}/patches/${arch}.patch ]; then
patch -p1 < ${SCRIPT_DIR}/patches/${arch}.patch
fi
popd # ${SCRIPT_DIR}
}
build_toolchain armv7a gnueabihf
build_toolchain aarch64 gnu
build_toolchain x86_64 gnu
build_toolchain_arm_none_eabi