Merge pull request #4271 from catalinii/master

Support cross-compile on aarch64 platform
This commit is contained in:
CvH 2020-05-31 11:09:54 +02:00 committed by GitHub
commit cb97caf937
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 64 additions and 11 deletions

View File

@ -42,16 +42,6 @@ SYSROOT_PREFIX=$TOOLCHAIN/$TARGET_NAME/sysroot
LIB_PREFIX=$SYSROOT_PREFIX/usr
TARGET_PREFIX=$TOOLCHAIN/bin/$TARGET_NAME-
# use ARM toolchain on 64/32 split builds
if [ -z "$KERNEL_TOOLCHAIN" -a "$TARGET_KERNEL_ARCH" = "arm64" -a "$TARGET_ARCH" = "arm" ]; then
KERNEL_TOOLCHAIN="aarch64-none-linux-gnu"
fi
if [ -n "$KERNEL_TOOLCHAIN" ]; then
TARGET_KERNEL_PREFIX=$TOOLCHAIN/lib/gcc-arm-$KERNEL_TOOLCHAIN/bin/$KERNEL_TOOLCHAIN-
else
TARGET_KERNEL_PREFIX=$TARGET_PREFIX
fi
FAKEROOT_SCRIPT=$BUILD/.fakeroot
if [ -z "$INSTALL" ]; then
@ -71,6 +61,22 @@ XORG_PATH_DRIVERS=/usr/lib/xorg/modules/drivers
. config/optimize
# use ARM toolchain on 64/32 split builds
if [ -z "$KERNEL_TOOLCHAIN" -a "$TARGET_KERNEL_ARCH" = "arm64" -a "$TARGET_ARCH" = "arm" ]; then
if [ "${MACHINE_HARDWARE_NAME}" = "x86_64" ]; then
KERNEL_TOOLCHAIN="aarch64-none-linux-gnu"
elif [ "${MACHINE_HARDWARE_NAME}" = "aarch64" ]; then
KERNEL_TOOLCHAIN="aarch64-none-elf"
else
die "No known toolchain available for ${MACHINE_HARDWARE_NAME}."
fi
fi
if [ -n "$KERNEL_TOOLCHAIN" ]; then
TARGET_KERNEL_PREFIX=$TOOLCHAIN/lib/gcc-arm-$KERNEL_TOOLCHAIN/bin/$KERNEL_TOOLCHAIN-
else
TARGET_KERNEL_PREFIX=$TARGET_PREFIX
fi
if [ -z "$CCACHE_DIR" ]; then
export CCACHE_DIR=$BUILD/.ccache
fi

View File

@ -0,0 +1,36 @@
# SPDX-License-Identifier: GPL-2.0
# Copyright (C) 2017-present Team LibreELEC (https://libreelec.tv)
PKG_NAME="gcc-arm-aarch64-none-elf"
PKG_VERSION="9.2-2019.12"
PKG_SHA256="041ca53bdd434b1a48f32161e957da1b84543c373d1881e2fd84a1579f87f243"
PKG_LICENSE="GPL"
PKG_SITE="https://developer.arm.com/tools-and-software/open-source-software/developer-tools/gnu-toolchain/gnu-a"
PKG_URL="https://developer.arm.com/-/media/Files/downloads/gnu-a/${PKG_VERSION}/binrel/gcc-arm-${PKG_VERSION}-aarch64-aarch64-none-elf.tar.xz"
PKG_DEPENDS_HOST="ccache:host"
PKG_LONGDESC="ARM Aarch64 GNU Linux Binary Toolchain"
PKG_TOOLCHAIN="manual"
makeinstall_host() {
mkdir -p $TOOLCHAIN/lib/gcc-arm-aarch64-none-elf/
cp -a * $TOOLCHAIN/lib/gcc-arm-aarch64-none-elf
# wrap gcc and g++ with ccache like in gcc package.mk
PKG_GCC_PREFIX="$TOOLCHAIN/lib/gcc-arm-aarch64-none-elf/bin/aarch64-none-elf-"
cp "${PKG_GCC_PREFIX}gcc" "${PKG_GCC_PREFIX}gcc.real"
cat > "${PKG_GCC_PREFIX}gcc" << EOF
#!/bin/sh
$TOOLCHAIN/bin/ccache ${PKG_GCC_PREFIX}gcc.real "\$@"
EOF
chmod +x "${PKG_GCC_PREFIX}gcc"
cp "${PKG_GCC_PREFIX}g++" "${PKG_GCC_PREFIX}g++.real"
cat > "${PKG_GCC_PREFIX}g++" << EOF
#!/bin/sh
$TOOLCHAIN/bin/ccache ${PKG_GCC_PREFIX}g++.real "\$@"
EOF
chmod +x "${PKG_GCC_PREFIX}g++"
}

View File

@ -46,7 +46,7 @@ pre_configure_host() {
configure_host() {
cd $PKG_BUILD/.$HOST_NAME
./Configure $PKG_CONFIGURE_OPTS_HOST $PKG_CONFIGURE_OPTS_SHARED linux-x86_64 $CFLAGS $LDFLAGS
./Configure $PKG_CONFIGURE_OPTS_HOST $PKG_CONFIGURE_OPTS_SHARED linux-${MACHINE_HARDWARE_NAME} $CFLAGS $LDFLAGS
}
makeinstall_host() {

View File

@ -122,6 +122,17 @@ if [ -n "${DISTRO_DEPS_PKG}" ] ; then
deps_pkg+=(${DISTRO_DEPS_PKG})
fi
# aarch64 dependencies
if [ "$(uname -m)" = "aarch64" ]; then
if [ ! -f /lib64/ld-linux-x86-64.so.2 -a ! -f /lib/x86_64-linux-gnu/libc.so.6 ]; then
printf "Copy from a working x86_64 system:\n\t/lib64/libc.so.6\n\t/lib/x86_64-linux-gnu/libc.so.6\n"
fi
files+=(/lib64/ld-linux-x86-64.so.2 /lib/x86_64-linux-gnu/libc.so.6)
files_pkg+=(libc6:amd64 libc6:amd64)
deps+=(qemu-x86_64)
deps_pkg+=(qemu-user-binfmt)
fi
get_deps
if [ "${#need[@]}" -gt 0 ]; then