Merge pull request #6386 from jernejsk/arm64-toolchain

[LE11] Switch from pre-built to self-build aarch64 gcc
This commit is contained in:
CvH 2022-04-15 10:46:25 +02:00 committed by GitHub
commit e313ad688f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 228 additions and 85 deletions

View File

@ -56,18 +56,12 @@ XORG_PATH_DRIVERS=/usr/lib/xorg/modules/drivers
. config/optimize
# use ARM toolchain on 64/32 split builds
# use different toolchain for 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
KERNEL_TOOLCHAIN="aarch64"
fi
if [ -n "$KERNEL_TOOLCHAIN" ]; then
TARGET_KERNEL_PREFIX=$TOOLCHAIN/lib/gcc-arm-$KERNEL_TOOLCHAIN/bin/$KERNEL_TOOLCHAIN-
TARGET_KERNEL_PREFIX=$KERNEL_TOOLCHAIN-none-elf-
else
TARGET_KERNEL_PREFIX=$TARGET_PREFIX
fi

View File

@ -0,0 +1,47 @@
# SPDX-License-Identifier: GPL-2.0-or-later
# Copyright (C) 2009-2016 Stephan Raue (stephan@openelec.tv)
# Copyright (C) 2018-present Team LibreELEC (https://libreelec.tv)
PKG_NAME="binutils-aarch64"
PKG_VERSION="2.37"
PKG_SHA256="820d9724f020a3e69cb337893a0b63c2db161dadcb0e06fc11dc29eb1e84a32c"
PKG_LICENSE="GPL"
PKG_SITE="https://www.gnu.org/software/binutils/"
PKG_URL="https://ftp.gnu.org/gnu/binutils/binutils-${PKG_VERSION}.tar.xz"
PKG_DEPENDS_HOST="toolchain:host"
PKG_LONGDESC="A GNU collection of binary utilities for 64-bit ARM."
PKG_CONFIGURE_OPTS_HOST="--target=aarch64-none-elf \
--with-sysroot=${SYSROOT_PREFIX} \
--with-lib-path=${SYSROOT_PREFIX}/lib:${SYSROOT_PREFIX}/usr/lib \
--without-ppl \
--enable-static \
--without-cloog \
--disable-werror \
--disable-multilib \
--disable-libada \
--disable-libssp \
--enable-version-specific-runtime-libs \
--enable-plugins \
--enable-gold \
--enable-ld=default \
--enable-lto \
--disable-nls"
pre_configure_host() {
unset CPPFLAGS
unset CFLAGS
unset CXXFLAGS
unset LDFLAGS
}
make_host() {
make configure-host
make
}
makeinstall_host() {
cp -v ../include/libiberty.h ${SYSROOT_PREFIX}/usr/include
make -C bfd install # fix parallel build with libctf requiring bfd
make install
}

View File

@ -0,0 +1,32 @@
simplified patch based on
http://git.yoctoproject.org/cgit.cgi/poky/plain/meta/recipes-devtools/binutils/binutils/0009-warn-for-uses-of-system-directories-when-cross-linki.patch
just detect and skip system directories if used by mistake
linker output in case of using /usr/lib path:
/data/LibreELEC.tv/build.LibreELEC-Generic.x86_64-8.0-devel/toolchain/lib/gcc/x86_64-libreelec-linux-gnu/6.2.0/../../../../x86_64-libreelec-linux-gnu/bin/ld: warning: library search path "/usr/lib" is unsafe for cross-compilation, ignore it
From 7ab8e318659eb5d9adc758c78d084a95560b93fd Mon Sep 17 00:00:00 2001
From: Khem Raj <raj.khem@gmail.com>
Date: Fri, 15 Jan 2016 06:31:09 +0000
Subject: [PATCH 09/13] warn for uses of system directories when cross linking
--- a/ld/ldfile.c
+++ b/ld/ldfile.c
@@ -103,6 +103,17 @@ ldfile_add_library_path (const char *nam
if (!cmdline && config.only_cmd_line_lib_dirs)
return;
+ /* skip those directories when linking */
+ if ((!strncmp (name, "/lib", 4)) ||
+ (!strncmp (name, "/usr/lib", 8)) ||
+ (!strncmp (name, "/usr/local/lib", 14)) ||
+ (!strncmp (name, "/usr/X11R6/lib", 14)))
+ {
+ einfo (_("%P: warning: library search path \"%s\" is unsafe for "
+ "cross-compilation, ignore it\n"), name);
+ return;
+ }
+
new_dirs = (search_dirs_type *) xmalloc (sizeof (search_dirs_type));
new_dirs->next = NULL;
new_dirs->cmdline = cmdline;

View File

@ -0,0 +1,11 @@
--- a/binutils/Makefile.in
+++ b/binutils/Makefile.in
@@ -569,7 +569,7 @@ zlibdir = @zlibdir@
zlibinc = @zlibinc@
AUTOMAKE_OPTIONS = dejagnu no-dist foreign subdir-objects
ACLOCAL_AMFLAGS = -I .. -I ../config -I ../bfd
-SUBDIRS = doc po
+SUBDIRS =
tooldir = $(exec_prefix)/$(target_alias)
# Automake 1.10+ disables lex and yacc output file regeneration if

View File

@ -0,0 +1,68 @@
# SPDX-License-Identifier: GPL-2.0-or-later
# Copyright (C) 2009-2016 Stephan Raue (stephan@openelec.tv)
# Copyright (C) 2018-present Team LibreELEC (https://libreelec.tv)
PKG_NAME="gcc-aarch64"
PKG_VERSION="11.2.0"
PKG_SHA256="d08edc536b54c372a1010ff6619dd274c0f1603aa49212ba20f7aa2cda36fa8b"
PKG_LICENSE="GPL-2.0-or-later"
PKG_SITE="http://gcc.gnu.org/"
PKG_URL="http://ftpmirror.gnu.org/gcc/gcc-${PKG_VERSION}/gcc-${PKG_VERSION}.tar.xz"
PKG_DEPENDS_HOST="toolchain:host ccache:host autoconf:host binutils-aarch64:host gmp:host mpfr:host mpc:host zstd:host"
PKG_LONGDESC="This package contains the GNU Compiler Collection for 64-bit ARM."
PKG_CONFIGURE_OPTS_HOST="--target=aarch64-none-elf \
--with-sysroot=${SYSROOT_PREFIX} \
--with-gmp=${TOOLCHAIN} \
--with-mpfr=${TOOLCHAIN} \
--with-mpc=${TOOLCHAIN} \
--with-zstd=${TOOLCHAIN} \
--with-gnu-as \
--with-gnu-ld \
--with-newlib \
--without-ppl \
--without-headers \
--without-cloog \
--enable-__cxa_atexit \
--enable-checking=release \
--enable-gold \
--enable-languages=c \
--enable-ld=default \
--enable-lto \
--enable-plugin \
--enable-static \
--disable-decimal-float \
--disable-gcov \
--disable-libada \
--disable-libatomic \
--disable-libgomp \
--disable-libitm \
--disable-libmpx \
--disable-libmudflap \
--disable-libquadmath \
--disable-libquadmath-support \
--disable-libsanitizer \
--disable-libssp \
--disable-multilib \
--disable-nls \
--disable-shared \
--disable-threads"
post_makeinstall_host() {
PKG_GCC_PREFIX="${TOOLCHAIN}/bin/aarch64-none-elf-"
GCC_VERSION=$(${PKG_GCC_PREFIX}gcc -dumpversion)
DATE="0501$(echo ${GCC_VERSION} | sed 's/\./0/g')"
CROSS_CC=${PKG_GCC_PREFIX}gcc-${GCC_VERSION}
rm -f ${PKG_GCC_PREFIX}gcc
cat > ${PKG_GCC_PREFIX}gcc <<EOF
#!/bin/sh
${TOOLCHAIN}/bin/ccache ${CROSS_CC} "\$@"
EOF
chmod +x ${PKG_GCC_PREFIX}gcc
# To avoid cache trashing
touch -c -t ${DATE} ${CROSS_CC}
}

View File

@ -0,0 +1,32 @@
From c611cd5416ff1042a4adec0e1b12c71e307b508d Mon Sep 17 00:00:00 2001
From: Stefan Saraev <stefan@saraev.ca>
Date: Thu, 24 Apr 2014 22:33:27 +0300
Subject: [PATCH] allow newer autoconf
---
config/override.m4 | 9 ---------
1 files changed, 0 insertions(+), 9 deletions(-)
diff --git a/config/override.m4 b/config/override.m4
index 52bd1c3..6c39656 100644
--- a/config/override.m4
+++ b/config/override.m4
@@ -38,15 +38,6 @@ dnl m4_define([_GCC_AUTOCONF_VERSION], [X.Y])
dnl in configure.ac before AC_INIT,
dnl without rewriting this file.
dnl Or for updating the whole tree at once with the definition above.
-AC_DEFUN([_GCC_AUTOCONF_VERSION_CHECK],
-[m4_if(m4_defn([_GCC_AUTOCONF_VERSION]),
- m4_defn([m4_PACKAGE_VERSION]), [],
- [m4_fatal([Please use exactly Autoconf ]_GCC_AUTOCONF_VERSION[ instead of ]m4_defn([m4_PACKAGE_VERSION])[.])])
-])
-m4_define([AC_INIT], m4_defn([AC_INIT])[
-_GCC_AUTOCONF_VERSION_CHECK
-])
-
dnl Ensure we do not use a buggy M4.
m4_if(m4_index([..wi.d.], [.d.]), [-1],
--
1.7.2.5

View File

@ -0,0 +1,31 @@
Index: gcc-4.4+svnr145550/gcc/incpath.c
===================================================================
--- gcc-4.4+svnr145550.orig/gcc/incpath.c 2009-04-04 13:48:31.000000000 -0700
+++ gcc-4.4+svnr145550/gcc/incpath.c 2009-04-04 14:49:29.000000000 -0700
@@ -417,6 +417,26 @@
p->construct = 0;
p->user_supplied_p = user_supplied_p;
+ /* A common error when cross compiling is including
+ host headers. This code below will try to fail fast
+ for cross compiling. Currently we consider /usr/include,
+ /opt/include and /sw/include as harmful. */
+
+ {
+ /* printf("Adding Path: %s\n", p->name ); */
+ if( strstr(p->name, "/usr/include" ) == p->name ) {
+ fprintf(stderr, _("CROSS COMPILE Badness: /usr/include in INCLUDEPATH: %s\n"), p->name);
+ abort();
+ } else if( strstr(p->name, "/sw/include") == p->name ) {
+ fprintf(stderr, _("CROSS COMPILE Badness: /sw/include in INCLUDEPATH: %s\n"), p->name);
+ abort();
+ } else if( strstr(p->name, "/opt/include") == p->name ) {
+ fprintf(stderr, _("CROSS COMPILE Badness: /opt/include in INCLUDEPATH: %s\n"), p->name);
+ abort();
+ }
+ }
+
+
add_cpp_dir_path (p, chain);
}

View File

@ -1,36 +0,0 @@
# SPDX-License-Identifier: GPL-2.0
# Copyright (C) 2017-present Team LibreELEC (https://libreelec.tv)
PKG_NAME="gcc-arm-aarch64-none-elf"
PKG_VERSION="11.2-2022.02"
PKG_SHA256="3b15725545a0211a17b63e72d4f10241f7ffbe7ce94cb9612590ceacde16992c"
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/${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

@ -1,36 +0,0 @@
# SPDX-License-Identifier: GPL-2.0
# Copyright (C) 2017-present Team LibreELEC (https://libreelec.tv)
PKG_NAME="gcc-arm-aarch64-none-linux-gnu"
PKG_VERSION="10.3-2021.07"
PKG_SHA256="1e33d53dea59c8de823bbdfe0798280bdcd138636c7060da9d77a97ded095a84"
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}-x86_64-aarch64-none-linux-gnu.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-linux-gnu/
cp -a * ${TOOLCHAIN}/lib/gcc-arm-aarch64-none-linux-gnu
# wrap gcc and g++ with ccache like in gcc package.mk
PKG_GCC_PREFIX="${TOOLCHAIN}/lib/gcc-arm-aarch64-none-linux-gnu/bin/aarch64-none-linux-gnu-"
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

@ -38,8 +38,8 @@ esac
PKG_KERNEL_CFG_FILE=$(kernel_config_path) || die
if [ -n "${KERNEL_TOOLCHAIN}" ]; then
PKG_DEPENDS_HOST+=" gcc-arm-${KERNEL_TOOLCHAIN}:host"
PKG_DEPENDS_TARGET+=" gcc-arm-${KERNEL_TOOLCHAIN}:host"
PKG_DEPENDS_HOST+=" gcc-${KERNEL_TOOLCHAIN}:host"
PKG_DEPENDS_TARGET+=" gcc-${KERNEL_TOOLCHAIN}:host"
HEADERS_ARCH=${TARGET_ARCH}
fi

View File

@ -12,7 +12,7 @@ PKG_DEPENDS_TARGET="toolchain"
PKG_LONGDESC="ARM Trusted Firmware is a reference implementation of secure world software, including a Secure Monitor executing at Exception Level 3 and various Arm interface standards."
PKG_TOOLCHAIN="manual"
[ -n "${KERNEL_TOOLCHAIN}" ] && PKG_DEPENDS_TARGET+=" gcc-arm-${KERNEL_TOOLCHAIN}:host"
[ -n "${KERNEL_TOOLCHAIN}" ] && PKG_DEPENDS_TARGET+=" gcc-${KERNEL_TOOLCHAIN}:host"
make_target() {
CROSS_COMPILE="${TARGET_KERNEL_PREFIX}" LDFLAGS="" CFLAGS="" make PLAT=${ATF_PLATFORM} bl31

View File

@ -11,7 +11,7 @@ PKG_LONGDESC="Das U-Boot is a cross-platform bootloader for embedded systems."
PKG_STAMP="${UBOOT_SYSTEM} ${UBOOT_TARGET}"
[ -n "${KERNEL_TOOLCHAIN}" ] && PKG_DEPENDS_TARGET+=" gcc-arm-${KERNEL_TOOLCHAIN}:host"
[ -n "${KERNEL_TOOLCHAIN}" ] && PKG_DEPENDS_TARGET+=" gcc-${KERNEL_TOOLCHAIN}:host"
if [ -n "${UBOOT_FIRMWARE}" ]; then
PKG_DEPENDS_TARGET+=" ${UBOOT_FIRMWARE}"