flatcar-scripts/build_library/catalyst_toolchains.sh
Geoff Levand ea6cf50b8d toolchain_util.sh: Fix _configure_sysroot CBUILD
The portage CBUILD and HOSTCC variables need to be set to the SDK host to get
a proper cross build when building target binaries.

Change _configure_sysroot to use the CBUILD environment variable to set the
CBUILD and HOSTCC variables of ${ROOT}/etc/portage/make.conf.  Also, fix up all
calls to _configure_sysroot to set the CBUILD environment variable.

Fixes setup_board failure when the host and target architectures differ.

Signed-off-by: Geoff Levand <geoff@infradead.org>

[marineam: fixed a copy/paste error]
2015-04-01 15:54:43 -07:00

52 lines
1.7 KiB
Bash

#!/bin/bash
set -e
source /tmp/chroot-functions.sh
source /tmp/toolchain_util.sh
# A note on packages:
# The default PKGDIR is /usr/portage/packages
# To make sure things are uploaded to the correct places we split things up:
# crossdev build packages use ${PKGDIR}/crossdev (uploaded to SDK location)
# build deps in crossdev's sysroot use ${PKGDIR}/cross/${CHOST} (no upload)
# native toolchains use ${PKGDIR}/target/${BOARD} (uploaded to board location)
configure_target_root() {
local board="$1"
local cross_chost=$(get_board_chost "$1")
local profile=$(get_board_profile "${board}")
CBUILD="$(portageq envvar CBUILD)" \
CHOST="${cross_chost}" \
ROOT="/build/${board}" \
SYSROOT="/usr/${cross_chost}" \
_configure_sysroot "${profile}"
}
build_target_toolchain() {
local board="$1"
local ROOT="/build/${board}"
# --root is required because run_merge overrides ROOT=
PORTAGE_CONFIGROOT="$ROOT" \
run_merge -u --root="$ROOT" "${TOOLCHAIN_PKGS[@]}"
}
mkdir -p "/tmp/crossdev"
export PORTDIR_OVERLAY="/tmp/crossdev $(portageq envvar PORTDIR_OVERLAY)"
for cross_chost in $(get_chost_list); do
echo "Building cross toolchain for ${cross_chost}"
PKGDIR="$(portageq envvar PKGDIR)/crossdev" \
install_cross_toolchain "${cross_chost}" ${clst_myemergeopts}
PKGDIR="$(portageq envvar PKGDIR)/cross/${cross_chost}" \
install_cross_libs "${cross_chost}" ${clst_myemergeopts}
done
for board in $(get_board_list); do
echo "Building native toolchain for ${board}"
target_pkgdir="$(portageq envvar PKGDIR)/target/${board}"
PKGDIR="${target_pkgdir}" configure_target_root "${board}"
PKGDIR="${target_pkgdir}" build_target_toolchain "${board}"
done