Merge pull request #6380 from jernejsk/or1k-gcc

LE11: Switch or1k gcc from pre-built to self-build
This commit is contained in:
Matthias Reichl 2022-04-14 00:10:37 +02:00 committed by GitHub
commit 2f2b008bfc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 226 additions and 38 deletions

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-or1k"
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"
PKG_LONGDESC="A GNU collection of binary utilities for OpenRISC 1000."
PKG_CONFIGURE_OPTS_HOST="--target=or1k-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

@ -1,36 +0,0 @@
# SPDX-License-Identifier: GPL-2.0
# Copyright (C) 2020-present Team LibreELEC (https://libreelec.tv)
PKG_NAME="gcc-or1k-linux"
PKG_VERSION="2021.11-5"
PKG_SHA256="409e4a7473125e7de7c8b0e6bc1cb971d53e63ac057e9a19102e4ce1467f442a"
PKG_LICENSE="GPL"
PKG_SITE="https://toolchains.bootlin.com/releases_openrisc.html"
PKG_URL="https://toolchains.bootlin.com/downloads/releases/toolchains/openrisc/tarballs/openrisc--musl--stable-${PKG_VERSION}.tar.bz2"
PKG_DEPENDS_HOST="ccache:host"
PKG_LONGDESC="OpenRISC 1000 GNU Linux Binary Toolchain"
PKG_TOOLCHAIN="manual"
makeinstall_host() {
mkdir -p ${TOOLCHAIN}/lib/gcc-or1k-linux/
cp -a * ${TOOLCHAIN}/lib/gcc-or1k-linux
# wrap gcc and g++ with ccache like in gcc package.mk
PKG_GCC_PREFIX="${TOOLCHAIN}/lib/gcc-or1k-linux/bin/or1k-linux-"
rm -f "${PKG_GCC_PREFIX}gcc"
cat > "${PKG_GCC_PREFIX}gcc" << EOF
#!/bin/sh
${TOOLCHAIN}/bin/ccache ${TOOLCHAIN}/lib/gcc-or1k-linux/bin/or1k-buildroot-linux-musl-gcc "\$@"
EOF
chmod +x "${PKG_GCC_PREFIX}gcc"
rm -f "${PKG_GCC_PREFIX}g++"
cat > "${PKG_GCC_PREFIX}g++" << EOF
#!/bin/sh
${TOOLCHAIN}/bin/ccache ${TOOLCHAIN}/lib/gcc-or1k-linux/bin/or1k-buildroot-linux-musl-g++ "\$@"
EOF
chmod +x "${PKG_GCC_PREFIX}g++"
}

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-or1k"
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 ccache:host autoconf:host binutils-or1k:host gmp:host mpfr:host mpc:host zstd:host"
PKG_LONGDESC="This package contains the GNU Compiler Collection for OpenRISC 1000."
PKG_CONFIGURE_OPTS_HOST="--target=or1k-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/or1k-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

@ -8,13 +8,16 @@ PKG_ARCH="arm aarch64"
PKG_LICENSE="BSD-3c"
PKG_SITE="https://github.com/crust-firmware/crust"
PKG_URL="https://github.com/crust-firmware/crust/archive/${PKG_VERSION}.tar.gz"
PKG_DEPENDS_TARGET="gcc-or1k-linux:host"
PKG_LONGDESC="Crust: Libre SCP firmware for Allwinner sunxi SoCs"
PKG_TOOLCHAIN="manual"
PKG_STAMP="${UBOOT_SYSTEM}"
if [ ! -z "${UBOOT_SYSTEM}" ]; then
PKG_DEPENDS_TARGET="gcc-or1k:host"
fi
pre_configure_target() {
export CROSS_COMPILE="${TOOLCHAIN}/lib/gcc-or1k-linux/bin/or1k-linux-"
export CROSS_COMPILE="or1k-none-elf-"
}
make_target() {