diff --git a/avr-gcc-patches/0001-gcc-lto-wrapper.patch b/avr-gcc-patches/0001-gcc-lto-wrapper.patch index 8fc612e..c0c7ae0 100644 --- a/avr-gcc-patches/0001-gcc-lto-wrapper.patch +++ b/avr-gcc-patches/0001-gcc-lto-wrapper.patch @@ -1,5 +1,5 @@ ---- gcc/lto-wrapper.c.orig 2016-06-14 21:13:06.985134945 +0200 -+++ gcc/lto-wrapper.c 2016-06-14 21:15:37.825167119 +0200 +--- gcc/gcc/lto-wrapper.c.orig 2016-06-14 21:13:06.985134945 +0200 ++++ gcc/gcc/lto-wrapper.c 2016-06-14 21:15:37.825167119 +0200 @@ -594,7 +594,7 @@ filename[p - argv[i]] = '\0'; file_offset = (off_t) loffset; diff --git a/avr-gcc-patches/0002-Avoid-CFLAGS-in-CFLAGS_FOR_TARGETS-if-cross-compiling.patch b/avr-gcc-patches/0002-Avoid-CFLAGS-in-CFLAGS_FOR_TARGETS-if-cross-compiling.patch new file mode 100644 index 0000000..51dfb2b --- /dev/null +++ b/avr-gcc-patches/0002-Avoid-CFLAGS-in-CFLAGS_FOR_TARGETS-if-cross-compiling.patch @@ -0,0 +1,59 @@ +diff --git a/configure.ac b/configure.ac +index 00f7452..2a14c35 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -2319,28 +2319,36 @@ AC_SUBST(DEBUG_PREFIX_CFLAGS_FOR_TARGET) + # gcc) are built with "-O2 -g", so include those options when setting + # CFLAGS_FOR_TARGET and CXXFLAGS_FOR_TARGET. + if test "x$CFLAGS_FOR_TARGET" = x; then +- CFLAGS_FOR_TARGET=$CFLAGS +- case " $CFLAGS " in +- *" -O2 "*) ;; +- *) CFLAGS_FOR_TARGET="-O2 $CFLAGS_FOR_TARGET" ;; +- esac +- case " $CFLAGS " in +- *" -g "* | *" -g3 "*) ;; +- *) CFLAGS_FOR_TARGET="-g $CFLAGS_FOR_TARGET" ;; +- esac ++ if test "x${is_cross_compiler}" = xyes; then ++ CFLAGS_FOR_TARGET="-g -O2" ++ else ++ CFLAGS_FOR_TARGET=$CFLAGS ++ case " $CFLAGS " in ++ *" -O2 "*) ;; ++ *) CFLAGS_FOR_TARGET="-O2 $CFLAGS_FOR_TARGET" ;; ++ esac ++ case " $CFLAGS " in ++ *" -g "* | *" -g3 "*) ;; ++ *) CFLAGS_FOR_TARGET="-g $CFLAGS_FOR_TARGET" ;; ++ esac ++ fi + fi + AC_SUBST(CFLAGS_FOR_TARGET) + + if test "x$CXXFLAGS_FOR_TARGET" = x; then +- CXXFLAGS_FOR_TARGET=$CXXFLAGS +- case " $CXXFLAGS " in +- *" -O2 "*) ;; +- *) CXXFLAGS_FOR_TARGET="-O2 $CXXFLAGS_FOR_TARGET" ;; +- esac +- case " $CXXFLAGS " in +- *" -g "* | *" -g3 "*) ;; +- *) CXXFLAGS_FOR_TARGET="-g $CXXFLAGS_FOR_TARGET" ;; +- esac ++ if test "x${is_cross_compiler}" = xyes; then ++ CXXFLAGS_FOR_TARGET="-g -O2" ++ else ++ CXXFLAGS_FOR_TARGET=$CXXFLAGS ++ case " $CXXFLAGS " in ++ *" -O2 "*) ;; ++ *) CXXFLAGS_FOR_TARGET="-O2 $CXXFLAGS_FOR_TARGET" ;; ++ esac ++ case " $CXXFLAGS " in ++ *" -g "* | *" -g3 "*) ;; ++ *) CXXFLAGS_FOR_TARGET="-g $CXXFLAGS_FOR_TARGET" ;; ++ esac ++ fi + fi + AC_SUBST(CXXFLAGS_FOR_TARGET) + diff --git a/avr-gcc-patches/0002-i686-no-vectorized-lex.patch b/avr-gcc-patches/0002-i686-no-vectorized-lex.patch new file mode 100644 index 0000000..97f724c --- /dev/null +++ b/avr-gcc-patches/0002-i686-no-vectorized-lex.patch @@ -0,0 +1,11 @@ +--- ./libcpp/lex.c.orig 2016-09-07 16:10:17.563531580 +0200 ++++ ./libcpp/lex.c 2016-09-07 16:16:32.653889905 +0200 +@@ -272,7 +272,7 @@ + extensions used, so SSE4.2 executables cannot run on machines that + don't support that extension. */ + +-#if (GCC_VERSION >= 4005) && (defined(__i386__) || defined(__x86_64__)) && !(defined(__sun__) && defined(__svr4__)) ++#if (!defined(__i386__)) || defined(__x86_64__) && !(defined(__sun__) && defined(__svr4__)) + + /* Replicated character data to be shared between implementations. + Recall that outside of a context with vector support we can't diff --git a/avr-gcc-patches/0003-regenerate-configure.patch b/avr-gcc-patches/0003-regenerate-configure.patch new file mode 100644 index 0000000..59394bf --- /dev/null +++ b/avr-gcc-patches/0003-regenerate-configure.patch @@ -0,0 +1,57 @@ +--- a/configure 2016-09-07 00:26:53.479778030 +0200 ++++ b/configure 2016-09-07 00:31:39.237494045 +0200 +@@ -6831,28 +6831,36 @@ + # gcc) are built with "-O2 -g", so include those options when setting + # CFLAGS_FOR_TARGET and CXXFLAGS_FOR_TARGET. + if test "x$CFLAGS_FOR_TARGET" = x; then +- CFLAGS_FOR_TARGET=$CFLAGS +- case " $CFLAGS " in +- *" -O2 "*) ;; +- *) CFLAGS_FOR_TARGET="-O2 $CFLAGS_FOR_TARGET" ;; +- esac +- case " $CFLAGS " in +- *" -g "* | *" -g3 "*) ;; +- *) CFLAGS_FOR_TARGET="-g $CFLAGS_FOR_TARGET" ;; +- esac ++ if test "x${is_cross_compiler}" = xyes; then ++ CFLAGS_FOR_TARGET="-g -O2" ++ else ++ CFLAGS_FOR_TARGET=$CFLAGS ++ case " $CFLAGS " in ++ *" -O2 "*) ;; ++ *) CFLAGS_FOR_TARGET="-O2 $CFLAGS_FOR_TARGET" ;; ++ esac ++ case " $CFLAGS " in ++ *" -g "* | *" -g3 "*) ;; ++ *) CFLAGS_FOR_TARGET="-g $CFLAGS_FOR_TARGET" ;; ++ esac ++ fi + fi + + + if test "x$CXXFLAGS_FOR_TARGET" = x; then +- CXXFLAGS_FOR_TARGET=$CXXFLAGS +- case " $CXXFLAGS " in +- *" -O2 "*) ;; +- *) CXXFLAGS_FOR_TARGET="-O2 $CXXFLAGS_FOR_TARGET" ;; +- esac +- case " $CXXFLAGS " in +- *" -g "* | *" -g3 "*) ;; +- *) CXXFLAGS_FOR_TARGET="-g $CXXFLAGS_FOR_TARGET" ;; +- esac ++ if test "x${is_cross_compiler}" = xyes; then ++ CXXFLAGS_FOR_TARGET="-g -O2" ++ else ++ CXXFLAGS_FOR_TARGET=$CXXFLAGS ++ case " $CXXFLAGS " in ++ *" -O2 "*) ;; ++ *) CXXFLAGS_FOR_TARGET="-O2 $CXXFLAGS_FOR_TARGET" ;; ++ esac ++ case " $CXXFLAGS " in ++ *" -g "* | *" -g3 "*) ;; ++ *) CXXFLAGS_FOR_TARGET="-g $CXXFLAGS_FOR_TARGET" ;; ++ esac ++ fi + fi + + diff --git a/avr-libc.build.bash b/avr-libc.build.bash index 22ebab7..c4dd2e2 100755 --- a/avr-libc.build.bash +++ b/avr-libc.build.bash @@ -82,7 +82,7 @@ CONFARGS=" \ --libdir=$PREFIX/lib \ --disable-doc" -PATH=$PREFIX/bin:$PATH CC="avr-gcc" CXX="avr-g++" CFLAGS="-w -Os $CFLAGS" CXXFLAGS="-w -Os $CXXFLAGS" LDFLAGS="-s $LDFLAGS" ../avr-libc/configure $CONFARGS +PATH=$PREFIX/bin:$PATH CC="avr-gcc" CXX="avr-g++" CFLAGS="-w -Os" CXXFLAGS="-w -Os" LDFLAGS="-s $LDFLAGS" ../avr-libc/configure $CONFARGS if [ -z "$MAKE_JOBS" ]; then MAKE_JOBS="2" diff --git a/binutils.build.bash b/binutils.build.bash index 5ecce7d..b491ec8 100755 --- a/binutils.build.bash +++ b/binutils.build.bash @@ -61,7 +61,7 @@ CONFARGS=" \ --with-pic \ --target=avr" -CFLAGS="-w -O2 -g0 $CFLAGS" CXXFLAGS="-w -O2 -g0 $CXXFLAGS" LDFLAGS="-s $LDFLAGS" ../binutils/configure $CONFARGS +CFLAGS="-w -O2 -g3 $CFLAGS" CXXFLAGS="-w -O2 -g3 $CXXFLAGS" LDFLAGS="-s $LDFLAGS" ../binutils/configure $CONFARGS if [ -z "$MAKE_JOBS" ]; then MAKE_JOBS="2" diff --git a/gcc.build.bash b/gcc.build.bash index 9d77763..92ce5c2 100755 --- a/gcc.build.bash +++ b/gcc.build.bash @@ -60,12 +60,13 @@ pushd gcc #sh genopt.sh avr-mcus.def > avr-tables.opt #cat avr-mcus.def | awk -f genmultilib.awk FORMAT="Makefile" > t-multilib #popd -pushd gcc -for p in ../../avr-gcc-patches/*.patch +#pushd gcc +for p in ../avr-gcc-patches/*.patch do echo Applying $p patch -p1 < $p done +pushd gcc autoconf popd popd diff --git a/package-avr-gcc.bash b/package-avr-gcc.bash index 044e2ac..42a96d6 100755 --- a/package-avr-gcc.bash +++ b/package-avr-gcc.bash @@ -15,7 +15,7 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -OUTPUT_VERSION=4.9.2-atmel3.5.3-arduino2 +OUTPUT_VERSION=4.9.2-atmel3.5.3-arduino3 export OS=`uname -o || uname` export TARGET_OS=$OS @@ -35,6 +35,8 @@ elif [[ $OS == "GNU/Linux" ]] ; then OUTPUT_TAG=x86_64-pc-linux-gnu elif [[ $MACHINE == "i686" ]] ; then OUTPUT_TAG=i686-pc-linux-gnu + export CXXFLAGS="-mfpmath=387" + export CFLAGS="-mfpmath=387" elif [[ $MACHINE == "armv7l" ]] ; then OUTPUT_TAG=armhf-pc-linux-gnu else @@ -47,9 +49,8 @@ elif [[ $OS == "Msys" || $OS == "Cygwin" ]] ; then export PATH=$PATH:/c/MinGW/bin/:/c/cygwin/bin/ export CC="mingw32-gcc -m32" export CXX="mingw32-g++ -m32" - export CFLAGS="-DWIN32" - export CXXFLAGS="-DWIN32" - export LDFLAGS="-DWIN32" + export CFLAGS="-DWIN32 -mfpmath=387" + export CXXFLAGS="-DWIN32 -mfpmath=387" export MAKE_JOBS=1 OUTPUT_TAG=i686-mingw32