diff --git a/miosix/_tools/compiler/gcc-9.2.0-mp3.3/autotools/Autohell.txt b/miosix/_tools/compiler/gcc-9.2.0-mp3.3/autotools/Autohell.txt index b09f4115c28c6af4723c7cc199fbd3b73c64c0e9..ac041508b10e8cc2c269d53dbd7faba637c248fc 100644 --- a/miosix/_tools/compiler/gcc-9.2.0-mp3.3/autotools/Autohell.txt +++ b/miosix/_tools/compiler/gcc-9.2.0-mp3.3/autotools/Autohell.txt @@ -37,25 +37,29 @@ So, you've got to download the exact version of autoconf and automake, make an autotools directory, copy the autoconf and automake of the exact version taken from the GNU website, and then -$ wget https://ftpmirror.gnu.org/autoconf/autoconf-2.68.tar.bz2 -$ wget https://ftpmirror.gnu.org/automake/automake-1.11.6.tar.gz -$ mkdir autobins && cd autobins -$ PFX=`pwd` -$ cd .. -$ tar xjvf autoconf-2.68.tar.bz2 -$ cd autoconf-2.68 -$ ./configure --prefix=$PFX -$ make -$ make install -$ cd .. -$ tar xzvf automake-1.11.6.tar.gz -$ cd automake-1.11.6 -$ ./configure --prefix=$PFX -$ make -$ make install -$ cd ../autobins/share -$ ln -s `pwd`/aclocal-1.11 aclocal - +wget https://ftpmirror.gnu.org/autoconf/autoconf-2.69.tar.gz +wget https://ftpmirror.gnu.org/automake/automake-1.15.1.tar.gz +mkdir autobins +PFX=`pwd`/autobins +tar xvf autoconf-2.69.tar.gz +cd autoconf-2.69 +./configure --prefix=$PFX +make +make install +cd .. +tar xvf automake-1.15.1.tar.gz +cd automake-1.15.1 +./configure --prefix=$PFX +make +make install +cd .. +export PATH=`pwd`/autobins/bin:$PATH + + +cd ../autobins/share +rm -rf aclocal +ln -s `pwd`/aclocal-1.15 aclocal +cd - Note that the last command is necessary because during installation an aclocal-1.11 directory is created, but the scripts expect an aclocal directory. Essentially, the make install of automake is broken, go figure... diff --git a/miosix/_tools/compiler/gcc-9.2.0-mp3.3/install-script.sh b/miosix/_tools/compiler/gcc-9.2.0-mp3.3/install-script.sh index 57ada554ca29eae0a6b472178600c5215ecb5366..e747c35686eec670be19040efe0a8979f763a5d9 100755 --- a/miosix/_tools/compiler/gcc-9.2.0-mp3.3/install-script.sh +++ b/miosix/_tools/compiler/gcc-9.2.0-mp3.3/install-script.sh @@ -201,7 +201,7 @@ extract() extract 'binutils' $BINUTILS.tar.xz patches/binutils.patch if [[ ( $(uname -s) == 'Darwin' ) && ( $(uname -m) == 'arm64' ) ]]; then - extract 'gcc' $GCC.tar.xz patches/gcc.patch patches/gcc_mac_arm64.patch + extract 'gcc' $GCC.tar.xz patches/gcc.patch patches/gcc_mac_arm64.patch patches/libgomp-fix-crash.patch else extract 'gcc' $GCC.tar.xz patches/gcc.patch fi diff --git a/miosix/_tools/compiler/gcc-9.2.0-mp3.3/patches/libgomp-fix-crash.patch b/miosix/_tools/compiler/gcc-9.2.0-mp3.3/patches/libgomp-fix-crash.patch new file mode 100644 index 0000000000000000000000000000000000000000..9082b4077aeb525f768204d46cee6ab4b8a88ec0 --- /dev/null +++ b/miosix/_tools/compiler/gcc-9.2.0-mp3.3/patches/libgomp-fix-crash.patch @@ -0,0 +1,56 @@ +diff -ruN gcc-9.2.0-old/libgomp/libgomp.h gcc-9.2.0/libgomp/libgomp.h +--- gcc-9.2.0-old/libgomp/libgomp.h 2019-01-01 13:31:55.000000000 +0100 ++++ gcc-9.2.0/libgomp/libgomp.h 2025-02-07 17:58:36.283882851 +0100 +@@ -699,9 +699,27 @@ + return &gomp_tls_data; + } + #else ++extern void initialize_team (void); + extern pthread_key_t gomp_tls_key; + static inline struct gomp_thread *gomp_thread (void) + { ++ /* NOTE: initialize_team() is declared __attribute__((constructor)) and sets ++ * gomp_tls_key at program start, but for main() only! However, if the ++ * application spawns a thread using pthread, C11 or C++11 threads and *that* ++ * thread tries to call some OpenMP-parallelized code, no one initialized ++ * gomp_tls_key for that thread, causing a NULL pointer dereference. ++ * Fix: call initialize_team() if we reach here and gomp_tls_key is NULL ++ */ ++ void *gomp_tls_ptr = pthread_getspecific (gomp_tls_key); ++ if (!gomp_tls_ptr) ++ { ++ initialize_team (); ++ gomp_tls_ptr = pthread_getspecific (gomp_tls_key); ++ } ++ return gomp_tls_ptr; ++} ++static inline struct gomp_thread *gomp_thread_no_init (void) ++{ + return pthread_getspecific (gomp_tls_key); + } + #endif +diff -ruN gcc-9.2.0-old/libgomp/team.c gcc-9.2.0/libgomp/team.c +--- gcc-9.2.0-old/libgomp/team.c 2019-03-27 19:30:44.000000000 +0100 ++++ gcc-9.2.0/libgomp/team.c 2025-02-07 17:44:32.932930558 +0100 +@@ -249,7 +249,12 @@ + void + gomp_free_thread (void *arg __attribute__((unused))) + { ++#ifdef LIBGOMP_USE_PTHREADS ++ struct gomp_thread *thr = gomp_thread_no_init (); ++ if (!thr) return; ++#else + struct gomp_thread *thr = gomp_thread (); ++#endif + struct gomp_thread_pool *pool = thr->thread_pool; + if (pool) + { +@@ -995,7 +1000,7 @@ + + /* Constructors for this file. */ + +-static void __attribute__((constructor)) ++void __attribute__((constructor)) + initialize_team (void) + { + #if !defined HAVE_TLS && !defined USE_EMUTLS diff --git a/miosix/_tools/compiler/gcc-9.2.0-mp3.3/patches/newlib.patch b/miosix/_tools/compiler/gcc-9.2.0-mp3.3/patches/newlib.patch index 2d60dbf64e0d314582e1660babd19f9c07afbd83..7da1843680e6632d317d83987ab8dbb7d0bc0f6e 100644 --- a/miosix/_tools/compiler/gcc-9.2.0-mp3.3/patches/newlib.patch +++ b/miosix/_tools/compiler/gcc-9.2.0-mp3.3/patches/newlib.patch @@ -1,6 +1,6 @@ diff -ruN newlib-3.1.0-old/newlib/configure.host newlib-3.1.0/newlib/configure.host --- newlib-3.1.0-old/newlib/configure.host 2019-01-01 05:40:11.000000000 +0100 -+++ newlib-3.1.0/newlib/configure.host 2025-01-25 11:33:31.138351952 +0100 ++++ newlib-3.1.0/newlib/configure.host 2025-01-29 08:51:09.185355614 +0100 @@ -417,6 +417,10 @@ stdio64_dir=stdio64 xdr_dir=xdr @@ -30,8 +30,8 @@ diff -ruN newlib-3.1.0-old/newlib/configure.host newlib-3.1.0/newlib/configure.h +# _NO_POSIX_SPAWN: Miosix provides ths function as a syscall +# _SMALL_HEXDIG: save 256 byte of RAM in stdlib/gdtoa-gethex.c +# SIGNAL_PROVIDED: disable the implementation of signals in newlib -+# ARG_NUM_MAX=16: save 960 byte of RAM in exec*.c -+ newlib_cflags="${newlib_cflags} -DREENTRANT_SYSCALLS_PROVIDED -DGETREENT_PROVIDED -DHAVE_BLKSIZE -DHAVE_FCNTL -DHAVE_NANOSLEEP -D_NO_POPEN -D_NO_WORDEXP -D_NO_POSIX_SPAWN -D_SMALL_HEXDIG -DSIGNAL_PROVIDED -DARG_NUM_MAX=16" ++# _EXECL_USE_MALLOC avoid unbounded stack allocation in exec*.c ++ newlib_cflags="${newlib_cflags} -DREENTRANT_SYSCALLS_PROVIDED -DGETREENT_PROVIDED -DHAVE_BLKSIZE -DHAVE_FCNTL -DHAVE_NANOSLEEP -D_NO_POPEN -D_NO_WORDEXP -D_NO_POSIX_SPAWN -D_SMALL_HEXDIG -DSIGNAL_PROVIDED -D_EXECL_USE_MALLOC" + newlib_cflags="${newlib_cflags} -Wall" + ;; # RTEMS supplies its own versions of some routines: @@ -406,138 +406,159 @@ diff -ruN newlib-3.1.0-old/newlib/libc/posix/closedir.c newlib-3.1.0/newlib/libc __lock_release_recursive(dirp->dd_lock); diff -ruN newlib-3.1.0-old/newlib/libc/posix/execl.c newlib-3.1.0/newlib/libc/posix/execl.c --- newlib-3.1.0-old/newlib/libc/posix/execl.c 2019-01-01 05:40:11.000000000 +0100 -+++ newlib-3.1.0/newlib/libc/posix/execl.c 2025-01-25 11:39:25.870896727 +0100 -@@ -7,6 +7,7 @@ ++++ newlib-3.1.0/newlib/libc/posix/execl.c 2025-01-28 23:42:31.061928012 +0100 +@@ -7,6 +7,9 @@ #include <_ansi.h> #include <unistd.h> +#include <errno.h> ++#include <stdlib.h> ++#include <alloca.h> /* Only deal with a pointer to environ, to work around subtle bugs with shared libraries and/or small data systems where the user declares his own -@@ -16,6 +17,10 @@ - - #include <stdarg.h> - -+#ifndef ARG_NUM_MAX -+#define ARG_NUM_MAX 256 -+#endif -+ - int - execl (const char *path, - const char *arg0, ...) -@@ -24,14 +29,20 @@ +@@ -24,7 +27,24 @@ { int i; va_list args; - const char *argv[256]; -+ const char *argv[ARG_NUM_MAX]; ++ const char **argv; ++ ++ i = 1; ++ va_start (args, arg0); ++ do ++ i++; ++ while (va_arg (args, const char *) != NULL); ++ va_end (args); ++#ifndef _EXECL_USE_MALLOC ++ argv = alloca (i * sizeof(const char *)); ++#else ++ argv = malloc (i * sizeof(const char *)); ++ if (argv == NULL) ++ { ++ errno = ENOMEM; ++ return -1; ++ } ++#endif va_start (args, arg0); argv[0] = arg0; - i = 1; -- do -- argv[i] = va_arg (args, const char *); -- while (argv[i++] != NULL); -+ do { -+ if(i>=ARG_NUM_MAX) -+ { -+ va_end (args); -+ errno=E2BIG; -+ return -1; -+ } -+ argv[i] = va_arg (args, const char *); -+ } while (argv[i++] != NULL); +@@ -34,6 +54,10 @@ + while (argv[i++] != NULL); va_end (args); - return _execve (path, (char * const *) argv, *p_environ); +- return _execve (path, (char * const *) argv, *p_environ); ++ i = _execve (path, (char * const *) argv, *p_environ); ++#ifdef _EXECL_USE_MALLOC ++ free (argv); ++#endif ++ return i; + } + #endif /* !_NO_EXECVE */ diff -ruN newlib-3.1.0-old/newlib/libc/posix/execle.c newlib-3.1.0/newlib/libc/posix/execle.c --- newlib-3.1.0-old/newlib/libc/posix/execle.c 2019-01-01 05:40:11.000000000 +0100 -+++ newlib-3.1.0/newlib/libc/posix/execle.c 2025-01-25 11:39:32.402973850 +0100 -@@ -7,10 +7,15 @@ ++++ newlib-3.1.0/newlib/libc/posix/execle.c 2025-01-28 23:42:33.421948503 +0100 +@@ -7,6 +7,9 @@ #include <_ansi.h> #include <unistd.h> +#include <errno.h> ++#include <stdlib.h> ++#include <alloca.h> #include <stdarg.h> - -+#ifndef ARG_NUM_MAX -+#define ARG_NUM_MAX 256 -+#endif -+ - int - execle (const char *path, - const char *arg0, ...) -@@ -20,14 +25,20 @@ +@@ -20,7 +23,24 @@ int i; va_list args; const char * const *envp; - const char *argv[256]; -+ const char *argv[ARG_NUM_MAX]; ++ const char **argv; ++ ++ i = 1; ++ va_start (args, arg0); ++ do ++ i++; ++ while (va_arg (args, const char *) != NULL); ++ va_end (args); ++#ifndef _EXECL_USE_MALLOC ++ argv = alloca (i * sizeof(const char *)); ++#else ++ argv = malloc (i * sizeof(const char *)); ++ if (argv == NULL) ++ { ++ errno = ENOMEM; ++ return -1; ++ } ++#endif va_start (args, arg0); argv[0] = arg0; - i = 1; -- do -+ do { -+ if(i>=ARG_NUM_MAX) -+ { -+ va_end (args); -+ errno=E2BIG; -+ return -1; -+ } - argv[i] = va_arg (args, const char *); -- while (argv[i++] != NULL); -+ } while (argv[i++] != NULL); +@@ -31,7 +51,11 @@ envp = va_arg (args, const char * const *); va_end (args); +- return _execve (path, (char * const *) argv, (char * const *) envp); ++ i = _execve (path, (char * const *) argv, (char * const *) envp); ++#ifdef _EXECL_USE_MALLOC ++ free (argv); ++#endif ++ return i; + } + + #endif /* !_NO_EXECVE */ diff -ruN newlib-3.1.0-old/newlib/libc/posix/execlp.c newlib-3.1.0/newlib/libc/posix/execlp.c --- newlib-3.1.0-old/newlib/libc/posix/execlp.c 2019-01-01 05:40:11.000000000 +0100 -+++ newlib-3.1.0/newlib/libc/posix/execlp.c 2025-01-25 11:39:38.487045516 +0100 -@@ -7,10 +7,15 @@ ++++ newlib-3.1.0/newlib/libc/posix/execlp.c 2025-01-28 23:42:35.065962787 +0100 +@@ -7,6 +7,9 @@ #include <_ansi.h> #include <unistd.h> +#include <errno.h> ++#include <stdlib.h> ++#include <alloca.h> #include <stdarg.h> - -+#ifndef ARG_NUM_MAX -+#define ARG_NUM_MAX 256 -+#endif -+ - int - execlp (const char *path, - const char *arg0, ...) -@@ -19,14 +24,20 @@ +@@ -19,7 +22,24 @@ { int i; va_list args; - const char *argv[256]; -+ const char *argv[ARG_NUM_MAX]; ++ const char **argv; ++ ++ i = 1; ++ va_start (args, arg0); ++ do ++ i++; ++ while (va_arg (args, const char *) != NULL); ++ va_end (args); ++#ifndef _EXECL_USE_MALLOC ++ argv = alloca (i * sizeof(const char *)); ++#else ++ argv = malloc (i * sizeof(const char *)); ++ if (argv == NULL) ++ { ++ errno = ENOMEM; ++ return -1; ++ } ++#endif va_start (args, arg0); argv[0] = arg0; - i = 1; -- do -- argv[i] = va_arg (args, const char *); -- while (argv[i++] != NULL); -+ do { -+ if(i>=ARG_NUM_MAX) -+ { -+ va_end (args); -+ errno=E2BIG; -+ return -1; -+ } -+ argv[i] = va_arg (args, const char *); -+ } while (argv[i++] != NULL); +@@ -29,7 +49,11 @@ + while (argv[i++] != NULL); va_end (args); - return execvp (path, (char * const *) argv); +- return execvp (path, (char * const *) argv); ++ i = execvp (path, (char * const *) argv); ++#ifdef _EXECL_USE_MALLOC ++ free (argv); ++#endif ++ return i; + } + + #endif /* !_NO_EXECVE */ diff -ruN newlib-3.1.0-old/newlib/libc/posix/_isatty.c newlib-3.1.0/newlib/libc/posix/_isatty.c --- newlib-3.1.0-old/newlib/libc/posix/_isatty.c 2019-01-01 05:40:11.000000000 +0100 +++ newlib-3.1.0/newlib/libc/posix/_isatty.c 2024-07-26 22:02:58.645581943 +0200