1#!/bin/bash 2# 3# Copyright 2020 The Chromium OS Authors. All rights reserved. 4# Use of this source code is governed by a BSD-style license that can be 5# found in the LICENSE file. 6 7# This script rebuilds and installs compiler wrappers 8 9if [[ ! -e /etc/cros_chroot_version ]]; then 10 echo "Please run this script inside chroot" 11 exit 1 12fi 13set -e 14cd "$(dirname "$(readlink -m "$0")")" 15echo "Updated files:" 16# Update the host wrapper 17./build.py --config=cros.host --use_ccache=false --use_llvm_next=false --output_file=./clang_host_wrapper 18sudo mv ./clang_host_wrapper /usr/bin/clang_host_wrapper 19echo "/usr/bin/clang_host_wrapper" 20sudo cp ../binary_search_tool/bisect_driver.py /usr/bin 21echo "/usr/bin/clang_host_wrapper/bisect_driver.py" 22 23# Update the target wrappers 24./build.py --config=cros.hardened --use_ccache=false --use_llvm_next=false --output_file=./sysroot_wrapper.hardened.noccache 25./build.py --config=cros.hardened --use_ccache=true --use_llvm_next=false --output_file=./sysroot_wrapper.hardened.ccache 26# Update clang target wrappers. 27sudo cp ./sysroot_wrapper.hardened.noccache ./sysroot_wrapper.hardened.ccache /usr/bin 28echo "Updated clang wrapper /usr/bin/sysroot_wrapper.hardened.noccache" 29echo "Updated clang wrapper /usr/bin/sysroot_wrapper.hardened.ccache" 30 31# Update GCC target wrappers. 32for GCC in cross-x86_64-cros-linux-gnu/gcc cross-armv7a-cros-linux-gnueabihf/gcc cross-aarch64-cros-linux-gnu/gcc; do 33 if ! FILES="$(equery f ${GCC})"; then 34 if [[ $(equery l "${GCC}" 2>&1 | wc -c) -eq 0 ]]; then 35 echo "no ${GCC} package found; skipping" >&2 36 continue 37 fi 38 # Something went wrong, and the equery above probably complained about it. 39 exit 1 40 fi 41 echo "Updating ${GCC} wrapper." 42 sudo cp ./sysroot_wrapper.hardened.noccache "$(grep sysroot_wrapper.hardened.noccache <<< "${FILES}")" 43 grep sysroot_wrapper.hardened.noccache <<< "${FILES}" 44 sudo cp ./sysroot_wrapper.hardened.ccache "$(grep sysroot_wrapper.hardened.ccache <<< "${FILES}")" 45 grep sysroot_wrapper.hardened.ccache <<< "${FILES}" 46 sudo cp ../binary_search_tool/bisect_driver.py "$(grep bisect_driver.py <<< "${FILES}")" 47 grep bisect_driver.py <<< "${FILES}" 48done 49rm -f ./sysroot_wrapper.hardened.noccache ./sysroot_wrapper.hardened.ccache 50