diff --git a/scripts/build_toolchain.sh b/scripts/build_toolchain.sh index 6403a5d..0dc4f75 100755 --- a/scripts/build_toolchain.sh +++ b/scripts/build_toolchain.sh @@ -13,12 +13,21 @@ PREFIX="$TOOLCHAIN/local" BUILD="$DIR/../builddbg" SYSROOT="$DIR/../sysroot" - BINUTILS_VERSION="2.40" BINUTILS_NAME="binutils-$BINUTILS_VERSION" BINUTILS_PKG="${BINUTILS_NAME}.tar.xz" BINUTILS_BASE_URL="https://ftp.gnu.org/gnu/binutils" +NEWLIB_VERSION="4.1.0" +NEWLIB_NAME="newlib-$NEWLIB_VERSION" +NEWLIB_PKG="${NEWLIB_NAME}.tar.gz" +NEWLIB_BASE_URL="ftp://sourceware.org/pub/newlib" + +GCC_VERSION="13.1.0" +GCC_NAME="gcc-$GCC_VERSION" +GCC_PKG="${GCC_NAME}.tar.xz" +GCC_BASE_URL="https://ftp.gnu.org/gnu/gcc" + mkdir -p "$TOOLCHAIN/srcs" pushd "$TOOLCHAIN/srcs" # TODO: Check md5sum @@ -29,6 +38,22 @@ pushd "$TOOLCHAIN/srcs" if [ ! -d "$BINUTILS_NAME" ]; then tar -xJf ${BINUTILS_PKG} fi + + if [ ! -e $NEWLIB_PKG ]; then + curl -LO $NEWLIB_BASE_URL/$NEWLIB_PKG + fi + + if [ ! -d $NEWLIB_NAME ]; then + tar -xzf $NEWLIB_PKG + fi + + if [ ! -e "$GCC_PKG" ]; then + curl -LO "$GCC_BASE_URL/$GCC_NAME/$GCC_PKG" + fi + + if [ ! -d "$GCC_NAME" ]; then + tar -xJf $GCC_PKG + fi popd @@ -41,11 +66,49 @@ pushd "$TOOLCHAIN/build" pushd binutils # skip building documentation export ac_cv_prog_MAKEINFO=true - "$TOOLCHAIN"/srcs/$BINUTILS_NAME/configure --prefix="$PREFIX" --target="$TARGET" --with-sysroot="$SYSROOT" --enable-shared --disable-nls + "$TOOLCHAIN"/srcs/$BINUTILS_NAME/configure \ + --prefix=$SYSROOT/usr \ + --exec-prefix=$PREFIX \ + --target="$TARGET" \ + --with-sysroot="$SYSROOT" \ + --enable-shared \ + --disable-nls + make MAKEINFO=true -j 8 make install MAKEINFO=true -j 8 popd fi + # rm -rf newlib + if [ ! -d newlib ]; then + mkdir -p newlib + pushd newlib + $TOOLCHAIN/srcs/$NEWLIB_NAME/configure \ + --prefix=$SYSROOT/usr \ + --target=x86_64-elf \ + --with-sysroot=$SYSROOT + make -j 8 + make -j 8 install + popd + fi + + rm -rf gcc + mkdir -p gcc + pushd gcc + $TOOLCHAIN/srcs/$GCC_NAME/configure \ + --prefix=$PREFIX \ + --target=$TARGET \ + --with-sysroot=$SYSROOT \ + --disable-nls \ + --enable-languages=c,c++ + + + make -j 8 all-gcc + make -j 8 all-target-libgcc + + make -j 8 install-gcc install-target-libgcc + + popd + popd diff --git a/toolchain/patches/gcc/00-first.patch b/toolchain/patches/gcc/00-first.patch new file mode 100644 index 0000000..433ce7f --- /dev/null +++ b/toolchain/patches/gcc/00-first.patch @@ -0,0 +1,350 @@ +diff --git a/config.sub b/config.sub +index 38f3d037a..a6298ccb7 100755 +--- a/config.sub ++++ b/config.sub +@@ -203,6 +203,10 @@ case $1 in + # Convert single-component short-hands not valid as part of + # multi-component configurations. + case $field1 in ++ acadia) ++ basic_machine=x86_64-pc ++ os=acadia ++ ;; + 386bsd) + basic_machine=i386-pc + basic_os=bsd +@@ -1749,7 +1753,7 @@ case $os in + | onefs* | tirtos* | phoenix* | fuchsia* | redox* | bme* \ + | midnightbsd* | amdhsa* | unleashed* | emscripten* | wasi* \ + | nsk* | powerunix* | genode* | zvmoe* | qnx* | emx* | zephyr* \ +- | fiwix* ) ++ | fiwix* | acadia* ) + ;; + # This one is extra strict with allowed versions + sco3.2v2 | sco3.2v[4-9]* | sco5v6*) +diff --git a/fixincludes/mkfixinc.sh b/fixincludes/mkfixinc.sh +index df90720b7..ae12e48d1 100755 +--- a/fixincludes/mkfixinc.sh ++++ b/fixincludes/mkfixinc.sh +@@ -11,6 +11,7 @@ target=fixinc.sh + + # Check for special fix rules for particular targets + case $machine in ++ *-*-acadia* | \ + i?86-*-cygwin* | \ + i?86-*-mingw32* | \ + x86_64-*-mingw32* | \ +diff --git a/gcc/config.gcc b/gcc/config.gcc +index 6fd159448..34e17e1f5 100644 +--- a/gcc/config.gcc ++++ b/gcc/config.gcc +@@ -690,6 +690,13 @@ x86_cpus="generic intel" + + # Common parts for widely ported systems. + case ${target} in ++*-*-acadia*) ++ gas=yes ++ gnu_ld=yes ++ default_use_cxa_atexit=yes ++ target_has_targetm_common=no ++ use_gcc_stdint=provide ++ ;; + *-*-darwin*) + tmake_file="t-darwin " + tm_file="${tm_file} darwin.h" +@@ -1126,6 +1133,9 @@ case ${target} in + esac + + case ${target} in ++x86_64-*-acadia*) ++ tm_file="${tm_file} i386/unix.h i386/att.h elfos.h glibc-stdint.h i386/i386elf.h i386/x86-64.h acadia.h" ++ ;; + aarch64*-*-elf | aarch64*-*-fuchsia* | aarch64*-*-rtems*) + tm_file="${tm_file} elfos.h newlib-stdint.h" + tm_file="${tm_file} aarch64/aarch64-elf.h aarch64/aarch64-errata.h aarch64/aarch64-elf-raw.h" +diff --git a/gcc/config/acadia.h b/gcc/config/acadia.h +new file mode 100644 +index 000000000..a5f58313d +--- /dev/null ++++ b/gcc/config/acadia.h +@@ -0,0 +1,25 @@ ++#undef TARGET_ACADIA ++#define TARGET_ACADIA 1 ++ ++#undef LIB_SPEC ++#define LIB_SPEC "-lc" /* link against C standard library */ ++ ++/* Files that are linked before user code. ++ The %s tells GCC to look for these files in the library directory. */ ++#undef STARTFILE_SPEC ++#define STARTFILE_SPEC "crt0.o%s crti.o%s crtbegin.o%s" ++ ++/* Files that are linked after user code. */ ++#undef ENDFILE_SPEC ++#define ENDFILE_SPEC "crtend.o%s crtn.o%s" ++ ++/* Additional predefined macros. */ ++#undef TARGET_ACADIA_CPP_BUILTINS ++#define TARGET_ACADIA_CPP_BUILTINS() \ ++ do { \ ++ builtin_define("__acadia__"); \ ++ builtin_define("__unix__"); \ ++ builtin_assert("system=acadia"); \ ++ builtin_assert("system=unix"); \ ++ builtin_assert("system=posix"); \ ++ } while (0); +diff --git a/gcc/config/i386/t-i386 b/gcc/config/i386/t-i386 +index b417c7f17..a30a64488 100644 +--- a/gcc/config/i386/t-i386 ++++ b/gcc/config/i386/t-i386 +@@ -50,7 +50,11 @@ i386-options.o: $(srcdir)/config/i386/i386-options.cc + $(COMPILE) $< + $(POSTCOMPILE) + +-i386-builtins.o: $(srcdir)/config/i386/i386-builtins.cc ++i386-common.o: $(srcdir)/common/config/i386/i386-common.cc ++ $(COMPILE) $< ++ $(POSTCOMPILE) ++ ++i386-builtins.o: $(srcdir)/config/i386/i386-builtins.cc + $(COMPILE) $< + $(POSTCOMPILE) + +diff --git a/libgcc/config.host b/libgcc/config.host +index b9975de90..bd766dfa0 100644 +--- a/libgcc/config.host ++++ b/libgcc/config.host +@@ -368,6 +368,10 @@ i[34567]86-*-cygwin* | x86_64-*-cygwin*) + esac + + case ${host} in ++x86_64-*-acadia*) ++ extra_parts="$extra_parts crti.o crtbegin.o crtend.o crtn.o" ++ tmake_file="$tmake_file i386/t-i386 i386/t-crtstuff t-crtstuff-pic t-libgcc-pic" ++ ;; + aarch64*-*-elf | aarch64*-*-rtems*) + extra_parts="$extra_parts crtbegin.o crtend.o crti.o crtn.o" + extra_parts="$extra_parts crtfastmath.o" +diff --git a/libstdc++-v3/crossconfig.m4 b/libstdc++-v3/crossconfig.m4 +index b3269cb88..0d2c7b53c 100644 +--- a/libstdc++-v3/crossconfig.m4 ++++ b/libstdc++-v3/crossconfig.m4 +@@ -9,6 +9,12 @@ case "${host}" in + # This is a freestanding configuration; there is nothing to do here. + ;; + ++ *-acadia*) ++ GLIBCXX_CHECK_COMPILER_FEATURES ++ GLIBCXX_CHECK_LINKER_FEATURES ++ GLIBCXX_CHECK_MATH_SUPPORT ++ GLIBCXX_CHECK_STDLIB_SUPPORT ++ ;; + avr*-*-*) + AC_DEFINE(HAVE_ACOSF) + AC_DEFINE(HAVE_ASINF) +diff --git a/lto-plugin/Makefile.in b/lto-plugin/Makefile.in +index cb568e1e0..c91313526 100644 +--- a/lto-plugin/Makefile.in ++++ b/lto-plugin/Makefile.in +@@ -1,7 +1,7 @@ +-# Makefile.in generated by automake 1.15.1 from Makefile.am. ++# Makefile.in generated by automake 1.15 from Makefile.am. + # @configure_input@ + +-# Copyright (C) 1994-2017 Free Software Foundation, Inc. ++# Copyright (C) 1994-2014 Free Software Foundation, Inc. + + # This Makefile.in is free software; the Free Software Foundation + # gives unlimited permission to copy and/or distribute it, +diff --git a/lto-plugin/aclocal.m4 b/lto-plugin/aclocal.m4 +index f1fc28d4f..58ea724c4 100644 +--- a/lto-plugin/aclocal.m4 ++++ b/lto-plugin/aclocal.m4 +@@ -1,6 +1,6 @@ +-# generated automatically by aclocal 1.15.1 -*- Autoconf -*- ++# generated automatically by aclocal 1.15 -*- Autoconf -*- + +-# Copyright (C) 1996-2017 Free Software Foundation, Inc. ++# Copyright (C) 1996-2014 Free Software Foundation, Inc. + + # This file is free software; the Free Software Foundation + # gives unlimited permission to copy and/or distribute it, +@@ -20,7 +20,7 @@ You have another version of autoconf. It may work, but is not guaranteed to. + If you have problems, you may need to regenerate the build system entirely. + To do so, use the procedure documented by the package, typically 'autoreconf'.])]) + +-# Copyright (C) 2002-2017 Free Software Foundation, Inc. ++# Copyright (C) 2002-2014 Free Software Foundation, Inc. + # + # This file is free software; the Free Software Foundation + # gives unlimited permission to copy and/or distribute it, +@@ -35,7 +35,7 @@ AC_DEFUN([AM_AUTOMAKE_VERSION], + [am__api_version='1.15' + dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to + dnl require some minimum version. Point them to the right macro. +-m4_if([$1], [1.15.1], [], ++m4_if([$1], [1.15], [], + [AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl + ]) + +@@ -51,14 +51,14 @@ m4_define([_AM_AUTOCONF_VERSION], []) + # Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced. + # This function is AC_REQUIREd by AM_INIT_AUTOMAKE. + AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION], +-[AM_AUTOMAKE_VERSION([1.15.1])dnl ++[AM_AUTOMAKE_VERSION([1.15])dnl + m4_ifndef([AC_AUTOCONF_VERSION], + [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl + _AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))]) + + # AM_AUX_DIR_EXPAND -*- Autoconf -*- + +-# Copyright (C) 2001-2017 Free Software Foundation, Inc. ++# Copyright (C) 2001-2014 Free Software Foundation, Inc. + # + # This file is free software; the Free Software Foundation + # gives unlimited permission to copy and/or distribute it, +@@ -110,7 +110,7 @@ am_aux_dir=`cd "$ac_aux_dir" && pwd` + + # AM_CONDITIONAL -*- Autoconf -*- + +-# Copyright (C) 1997-2017 Free Software Foundation, Inc. ++# Copyright (C) 1997-2014 Free Software Foundation, Inc. + # + # This file is free software; the Free Software Foundation + # gives unlimited permission to copy and/or distribute it, +@@ -141,7 +141,7 @@ AC_CONFIG_COMMANDS_PRE( + Usually this means the macro was only invoked conditionally.]]) + fi])]) + +-# Copyright (C) 1999-2017 Free Software Foundation, Inc. ++# Copyright (C) 1999-2014 Free Software Foundation, Inc. + # + # This file is free software; the Free Software Foundation + # gives unlimited permission to copy and/or distribute it, +@@ -332,7 +332,7 @@ _AM_SUBST_NOTMAKE([am__nodep])dnl + + # Generate code to set up dependency tracking. -*- Autoconf -*- + +-# Copyright (C) 1999-2017 Free Software Foundation, Inc. ++# Copyright (C) 1999-2014 Free Software Foundation, Inc. + # + # This file is free software; the Free Software Foundation + # gives unlimited permission to copy and/or distribute it, +@@ -408,7 +408,7 @@ AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS], + + # Do all the work for Automake. -*- Autoconf -*- + +-# Copyright (C) 1996-2017 Free Software Foundation, Inc. ++# Copyright (C) 1996-2014 Free Software Foundation, Inc. + # + # This file is free software; the Free Software Foundation + # gives unlimited permission to copy and/or distribute it, +@@ -605,7 +605,7 @@ for _am_header in $config_headers :; do + done + echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_count]) + +-# Copyright (C) 2001-2017 Free Software Foundation, Inc. ++# Copyright (C) 2001-2014 Free Software Foundation, Inc. + # + # This file is free software; the Free Software Foundation + # gives unlimited permission to copy and/or distribute it, +@@ -629,7 +629,7 @@ AC_SUBST([install_sh])]) + # Add --enable-maintainer-mode option to configure. -*- Autoconf -*- + # From Jim Meyering + +-# Copyright (C) 1996-2017 Free Software Foundation, Inc. ++# Copyright (C) 1996-2014 Free Software Foundation, Inc. + # + # This file is free software; the Free Software Foundation + # gives unlimited permission to copy and/or distribute it, +@@ -664,7 +664,7 @@ AC_MSG_CHECKING([whether to enable maintainer-specific portions of Makefiles]) + + # Check to see how 'make' treats includes. -*- Autoconf -*- + +-# Copyright (C) 2001-2017 Free Software Foundation, Inc. ++# Copyright (C) 2001-2014 Free Software Foundation, Inc. + # + # This file is free software; the Free Software Foundation + # gives unlimited permission to copy and/or distribute it, +@@ -714,7 +714,7 @@ rm -f confinc confmf + + # Fake the existence of programs that GNU maintainers use. -*- Autoconf -*- + +-# Copyright (C) 1997-2017 Free Software Foundation, Inc. ++# Copyright (C) 1997-2014 Free Software Foundation, Inc. + # + # This file is free software; the Free Software Foundation + # gives unlimited permission to copy and/or distribute it, +@@ -753,7 +753,7 @@ fi + + # Helper functions for option handling. -*- Autoconf -*- + +-# Copyright (C) 2001-2017 Free Software Foundation, Inc. ++# Copyright (C) 2001-2014 Free Software Foundation, Inc. + # + # This file is free software; the Free Software Foundation + # gives unlimited permission to copy and/or distribute it, +@@ -782,7 +782,7 @@ AC_DEFUN([_AM_SET_OPTIONS], + AC_DEFUN([_AM_IF_OPTION], + [m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])]) + +-# Copyright (C) 1999-2017 Free Software Foundation, Inc. ++# Copyright (C) 1999-2014 Free Software Foundation, Inc. + # + # This file is free software; the Free Software Foundation + # gives unlimited permission to copy and/or distribute it, +@@ -829,7 +829,7 @@ AC_LANG_POP([C])]) + # For backward compatibility. + AC_DEFUN_ONCE([AM_PROG_CC_C_O], [AC_REQUIRE([AC_PROG_CC])]) + +-# Copyright (C) 2001-2017 Free Software Foundation, Inc. ++# Copyright (C) 2001-2014 Free Software Foundation, Inc. + # + # This file is free software; the Free Software Foundation + # gives unlimited permission to copy and/or distribute it, +@@ -848,7 +848,7 @@ AC_DEFUN([AM_RUN_LOG], + + # Check to make sure that the build environment is sane. -*- Autoconf -*- + +-# Copyright (C) 1996-2017 Free Software Foundation, Inc. ++# Copyright (C) 1996-2014 Free Software Foundation, Inc. + # + # This file is free software; the Free Software Foundation + # gives unlimited permission to copy and/or distribute it, +@@ -929,7 +929,7 @@ AC_CONFIG_COMMANDS_PRE( + rm -f conftest.file + ]) + +-# Copyright (C) 2009-2017 Free Software Foundation, Inc. ++# Copyright (C) 2009-2014 Free Software Foundation, Inc. + # + # This file is free software; the Free Software Foundation + # gives unlimited permission to copy and/or distribute it, +@@ -989,7 +989,7 @@ AC_SUBST([AM_BACKSLASH])dnl + _AM_SUBST_NOTMAKE([AM_BACKSLASH])dnl + ]) + +-# Copyright (C) 2001-2017 Free Software Foundation, Inc. ++# Copyright (C) 2001-2014 Free Software Foundation, Inc. + # + # This file is free software; the Free Software Foundation + # gives unlimited permission to copy and/or distribute it, +@@ -1017,7 +1017,7 @@ fi + INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s" + AC_SUBST([INSTALL_STRIP_PROGRAM])]) + +-# Copyright (C) 2006-2017 Free Software Foundation, Inc. ++# Copyright (C) 2006-2014 Free Software Foundation, Inc. + # + # This file is free software; the Free Software Foundation + # gives unlimited permission to copy and/or distribute it, +@@ -1036,7 +1036,7 @@ AC_DEFUN([AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE($@)]) + + # Check how to create a tarball. -*- Autoconf -*- + +-# Copyright (C) 2004-2017 Free Software Foundation, Inc. ++# Copyright (C) 2004-2014 Free Software Foundation, Inc. + # + # This file is free software; the Free Software Foundation + # gives unlimited permission to copy and/or distribute it,