From 4116fc3e6f72807a1f2cc07f9c2250cf0e3d2c98 Mon Sep 17 00:00:00 2001 From: Adam Joseph Date: Wed, 16 Aug 2023 23:46:09 -0700 Subject: gcc: if atLeast 9, use deduplicated version --- ...-mcf-thread-model-support-from-mcfgthread.patch | 306 --------------------- .../gcc/9/avoid-cycling-subreg-reloads.patch | 261 ------------------ pkgs/development/compilers/gcc/9/default.nix | 294 -------------------- .../9/fix-struct-redefinition-on-glibc-2.36.patch | 31 --- .../compilers/gcc/9/gcc9-asan-glibc-2.34.patch | 70 ----- pkgs/development/compilers/gcc/default.nix | 25 +- ...-mcf-thread-model-support-from-mcfgthread.patch | 306 +++++++++++++++++++++ .../patches/9/avoid-cycling-subreg-reloads.patch | 261 ++++++++++++++++++ .../9/fix-struct-redefinition-on-glibc-2.36.patch | 31 +++ .../gcc/patches/9/gcc9-asan-glibc-2.34.patch | 70 +++++ pkgs/top-level/all-packages.nix | 1 + 11 files changed, 685 insertions(+), 971 deletions(-) delete mode 100644 pkgs/development/compilers/gcc/9/Added-mcf-thread-model-support-from-mcfgthread.patch delete mode 100644 pkgs/development/compilers/gcc/9/avoid-cycling-subreg-reloads.patch delete mode 100644 pkgs/development/compilers/gcc/9/default.nix delete mode 100644 pkgs/development/compilers/gcc/9/fix-struct-redefinition-on-glibc-2.36.patch delete mode 100644 pkgs/development/compilers/gcc/9/gcc9-asan-glibc-2.34.patch create mode 100644 pkgs/development/compilers/gcc/patches/9/Added-mcf-thread-model-support-from-mcfgthread.patch create mode 100644 pkgs/development/compilers/gcc/patches/9/avoid-cycling-subreg-reloads.patch create mode 100644 pkgs/development/compilers/gcc/patches/9/fix-struct-redefinition-on-glibc-2.36.patch create mode 100644 pkgs/development/compilers/gcc/patches/9/gcc9-asan-glibc-2.34.patch diff --git a/pkgs/development/compilers/gcc/9/Added-mcf-thread-model-support-from-mcfgthread.patch b/pkgs/development/compilers/gcc/9/Added-mcf-thread-model-support-from-mcfgthread.patch deleted file mode 100644 index d9809e828f1..00000000000 --- a/pkgs/development/compilers/gcc/9/Added-mcf-thread-model-support-from-mcfgthread.patch +++ /dev/null @@ -1,306 +0,0 @@ -From 86f2f767ddffd9f7c6f1470b987ae7b0d251b988 Mon Sep 17 00:00:00 2001 -From: Liu Hao -Date: Wed, 25 Apr 2018 21:54:19 +0800 -Subject: [PATCH] Added 'mcf' thread model support from mcfgthread. - -Signed-off-by: Liu Hao ---- - config/gthr.m4 | 1 + - gcc/config.gcc | 3 +++ - gcc/config/i386/mingw-mcfgthread.h | 1 + - gcc/config/i386/mingw-w64.h | 2 +- - gcc/config/i386/mingw32.h | 11 ++++++++++- - gcc/configure | 2 +- - gcc/configure.ac | 2 +- - libatomic/configure.tgt | 2 +- - libgcc/config.host | 6 ++++++ - libgcc/config/i386/gthr-mcf.h | 1 + - libgcc/config/i386/t-mingw-mcfgthread | 2 ++ - libgcc/configure | 1 + - libstdc++-v3/configure | 1 + - libstdc++-v3/libsupc++/atexit_thread.cc | 18 ++++++++++++++++++ - libstdc++-v3/libsupc++/guard.cc | 23 +++++++++++++++++++++++ - libstdc++-v3/src/c++11/thread.cc | 9 +++++++++ - 16 files changed, 80 insertions(+), 5 deletions(-) - create mode 100644 gcc/config/i386/mingw-mcfgthread.h - create mode 100644 libgcc/config/i386/gthr-mcf.h - create mode 100644 libgcc/config/i386/t-mingw-mcfgthread - -diff --git a/config/gthr.m4 b/config/gthr.m4 -index 7b29f1f3327..82e21fe1709 100644 ---- a/config/gthr.m4 -+++ b/config/gthr.m4 -@@ -21,6 +21,7 @@ case $1 in - tpf) thread_header=config/s390/gthr-tpf.h ;; - vxworks) thread_header=config/gthr-vxworks.h ;; - win32) thread_header=config/i386/gthr-win32.h ;; -+ mcf) thread_header=config/i386/gthr-mcf.h ;; - esac - AC_SUBST(thread_header) - ]) -diff --git a/gcc/config.gcc b/gcc/config.gcc -index 46a9029acec..112c24e95a3 100644 ---- a/gcc/config.gcc -+++ b/gcc/config.gcc -@@ -1758,6 +1758,9 @@ i[34567]86-*-mingw* | x86_64-*-mingw*) - if test x$enable_threads = xposix ; then - tm_file="${tm_file} i386/mingw-pthread.h" - fi -+ if test x$enable_threads = xmcf ; then -+ tm_file="${tm_file} i386/mingw-mcfgthread.h" -+ fi - tm_file="${tm_file} i386/mingw32.h" - # This makes the logic if mingw's or the w64 feature set has to be used - case ${target} in -diff --git a/gcc/config/i386/mingw-mcfgthread.h b/gcc/config/i386/mingw-mcfgthread.h -new file mode 100644 -index 00000000000..ec381a7798f ---- /dev/null -+++ b/gcc/config/i386/mingw-mcfgthread.h -@@ -0,0 +1 @@ -+#define TARGET_USE_MCFGTHREAD 1 -diff --git a/gcc/config/i386/mingw-w64.h b/gcc/config/i386/mingw-w64.h -index 484dc7a9e9f..a15bbeea500 100644 ---- a/gcc/config/i386/mingw-w64.h -+++ b/gcc/config/i386/mingw-w64.h -@@ -48,7 +48,7 @@ along with GCC; see the file COPYING3. If not see - "%{mwindows:-lgdi32 -lcomdlg32} " \ - "%{fvtable-verify=preinit:-lvtv -lpsapi; \ - fvtable-verify=std:-lvtv -lpsapi} " \ -- "-ladvapi32 -lshell32 -luser32 -lkernel32" -+ LIB_MCFGTHREAD "-ladvapi32 -lshell32 -luser32 -lkernel32" - - #undef SPEC_32 - #undef SPEC_64 -diff --git a/gcc/config/i386/mingw32.h b/gcc/config/i386/mingw32.h -index 0612b87199a..76cea94f3b7 100644 ---- a/gcc/config/i386/mingw32.h -+++ b/gcc/config/i386/mingw32.h -@@ -32,6 +32,14 @@ along with GCC; see the file COPYING3. If not see - | MASK_STACK_PROBE | MASK_ALIGN_DOUBLE \ - | MASK_MS_BITFIELD_LAYOUT) - -+#ifndef TARGET_USE_MCFGTHREAD -+#define CPP_MCFGTHREAD() ((void)0) -+#define LIB_MCFGTHREAD "" -+#else -+#define CPP_MCFGTHREAD() (builtin_define("__USING_MCFGTHREAD__")) -+#define LIB_MCFGTHREAD " -lmcfgthread " -+#endif -+ - /* See i386/crtdll.h for an alternative definition. _INTEGRAL_MAX_BITS - is for compatibility with native compiler. */ - #define EXTRA_OS_CPP_BUILTINS() \ -@@ -50,6 +58,7 @@ along with GCC; see the file COPYING3. If not see - builtin_define_std ("WIN64"); \ - builtin_define ("_WIN64"); \ - } \ -+ CPP_MCFGTHREAD(); \ - } \ - while (0) - -@@ -93,7 +102,7 @@ along with GCC; see the file COPYING3. If not see - "%{mwindows:-lgdi32 -lcomdlg32} " \ - "%{fvtable-verify=preinit:-lvtv -lpsapi; \ - fvtable-verify=std:-lvtv -lpsapi} " \ -- "-ladvapi32 -lshell32 -luser32 -lkernel32" -+ LIB_MCFGTHREAD "-ladvapi32 -lshell32 -luser32 -lkernel32" - - /* Weak symbols do not get resolved if using a Windows dll import lib. - Make the unwind registration references strong undefs. */ -diff --git a/gcc/configure b/gcc/configure -index 6121e163259..52f0e00efe6 100755 ---- a/gcc/configure -+++ b/gcc/configure -@@ -11693,7 +11693,7 @@ case ${enable_threads} in - target_thread_file='single' - ;; - aix | dce | lynx | mipssde | posix | rtems | \ -- single | tpf | vxworks | win32) -+ single | tpf | vxworks | win32 | mcf) - target_thread_file=${enable_threads} - ;; - *) -diff --git a/gcc/configure.ac b/gcc/configure.ac -index b066cc609e1..4ecdba88de7 100644 ---- a/gcc/configure.ac -+++ b/gcc/configure.ac -@@ -1612,7 +1612,7 @@ case ${enable_threads} in - target_thread_file='single' - ;; - aix | dce | lynx | mipssde | posix | rtems | \ -- single | tpf | vxworks | win32) -+ single | tpf | vxworks | win32 | mcf) - target_thread_file=${enable_threads} - ;; - *) -diff --git a/libatomic/configure.tgt b/libatomic/configure.tgt -index ea8c34f8c71..23134ad7363 100644 ---- a/libatomic/configure.tgt -+++ b/libatomic/configure.tgt -@@ -145,7 +145,7 @@ case "${target}" in - *-*-mingw*) - # OS support for atomic primitives. - case ${target_thread_file} in -- win32) -+ win32 | mcf) - config_path="${config_path} mingw" - ;; - posix) -diff --git a/libgcc/config.host b/libgcc/config.host -index 11b4acaff55..9fbd38650bd 100644 ---- a/libgcc/config.host -+++ b/libgcc/config.host -@@ -737,6 +737,9 @@ i[34567]86-*-mingw*) - posix) - tmake_file="i386/t-mingw-pthread $tmake_file" - ;; -+ mcf) -+ tmake_file="i386/t-mingw-mcfgthread $tmake_file" -+ ;; - esac - # This has to match the logic for DWARF2_UNWIND_INFO in gcc/config/i386/cygming.h - if test x$ac_cv_sjlj_exceptions = xyes; then -@@ -761,6 +764,9 @@ x86_64-*-mingw*) - posix) - tmake_file="i386/t-mingw-pthread $tmake_file" - ;; -+ mcf) -+ tmake_file="i386/t-mingw-mcfgthread $tmake_file" -+ ;; - esac - # This has to match the logic for DWARF2_UNWIND_INFO in gcc/config/i386/cygming.h - if test x$ac_cv_sjlj_exceptions = xyes; then -diff --git a/libgcc/config/i386/gthr-mcf.h b/libgcc/config/i386/gthr-mcf.h -new file mode 100644 -index 00000000000..5ea2908361f ---- /dev/null -+++ b/libgcc/config/i386/gthr-mcf.h -@@ -0,0 +1 @@ -+#include -diff --git a/libgcc/config/i386/t-mingw-mcfgthread b/libgcc/config/i386/t-mingw-mcfgthread -new file mode 100644 -index 00000000000..4b9b10e32d6 ---- /dev/null -+++ b/libgcc/config/i386/t-mingw-mcfgthread -@@ -0,0 +1,2 @@ -+SHLIB_PTHREAD_CFLAG = -+SHLIB_PTHREAD_LDFLAG = -lmcfgthread -diff --git a/libgcc/configure b/libgcc/configure -index b2f3f870844..eff889dc3b3 100644 ---- a/libgcc/configure -+++ b/libgcc/configure -@@ -5451,6 +5451,7 @@ case $target_thread_file in - tpf) thread_header=config/s390/gthr-tpf.h ;; - vxworks) thread_header=config/gthr-vxworks.h ;; - win32) thread_header=config/i386/gthr-win32.h ;; -+ mcf) thread_header=config/i386/gthr-mcf.h ;; - esac - - -diff --git a/libstdc++-v3/configure b/libstdc++-v3/configure -index ba094be6f15..979a5ab9ace 100755 ---- a/libstdc++-v3/configure -+++ b/libstdc++-v3/configure -@@ -15187,6 +15187,7 @@ case $target_thread_file in - tpf) thread_header=config/s390/gthr-tpf.h ;; - vxworks) thread_header=config/gthr-vxworks.h ;; - win32) thread_header=config/i386/gthr-win32.h ;; -+ mcf) thread_header=config/i386/gthr-mcf.h ;; - esac - - -diff --git a/libstdc++-v3/libsupc++/atexit_thread.cc b/libstdc++-v3/libsupc++/atexit_thread.cc -index de920d714c6..665fb74bd6b 100644 ---- a/libstdc++-v3/libsupc++/atexit_thread.cc -+++ b/libstdc++-v3/libsupc++/atexit_thread.cc -@@ -25,6 +25,22 @@ - #include - #include - #include "bits/gthr.h" -+ -+#ifdef __USING_MCFGTHREAD__ -+ -+#include -+ -+extern "C" int -+__cxxabiv1::__cxa_thread_atexit (void (*dtor)(void *), -+ void *obj, void *dso_handle) -+ _GLIBCXX_NOTHROW -+{ -+ return ::_MCFCRT_AtThreadExit((void (*)(_MCFCRT_STD intptr_t))dtor, (_MCFCRT_STD intptr_t)obj) ? 0 : -1; -+ (void)dso_handle; -+} -+ -+#else // __USING_MCFGTHREAD__ -+ - #ifdef _GLIBCXX_THREAD_ATEXIT_WIN32 - #define WIN32_LEAN_AND_MEAN - #include -@@ -167,3 +183,5 @@ __cxxabiv1::__cxa_thread_atexit (void (*dtor)(void *), void *obj, void */*dso_ha - } - - #endif /* _GLIBCXX_HAVE___CXA_THREAD_ATEXIT_IMPL */ -+ -+#endif // __USING_MCFGTHREAD__ -diff --git a/libstdc++-v3/libsupc++/guard.cc b/libstdc++-v3/libsupc++/guard.cc -index 3a2ec3ad0d6..8b4cc96199b 100644 ---- a/libstdc++-v3/libsupc++/guard.cc -+++ b/libstdc++-v3/libsupc++/guard.cc -@@ -28,6 +28,27 @@ - #include - #include - #include -+ -+#ifdef __USING_MCFGTHREAD__ -+ -+#include -+ -+namespace __cxxabiv1 { -+ -+extern "C" int __cxa_guard_acquire(__guard *g){ -+ return ::_MCFCRT_WaitForOnceFlagForever((::_MCFCRT_OnceFlag *)g) == ::_MCFCRT_kOnceResultInitial; -+} -+extern "C" void __cxa_guard_abort(__guard *g) throw() { -+ ::_MCFCRT_SignalOnceFlagAsAborted((::_MCFCRT_OnceFlag *)g); -+} -+extern "C" void __cxa_guard_release(__guard *g) throw() { -+ ::_MCFCRT_SignalOnceFlagAsFinished((::_MCFCRT_OnceFlag *)g); -+} -+ -+} -+ -+#else // __USING_MCFGTHREAD__ -+ - #include - #include - #include -@@ -425,3 +446,5 @@ namespace __cxxabiv1 - #endif - } - } -+ -+#endif -diff --git a/libstdc++-v3/src/c++11/thread.cc b/libstdc++-v3/src/c++11/thread.cc -index 8238817c2e9..0c6a1f85f6f 100644 ---- a/libstdc++-v3/src/c++11/thread.cc -+++ b/libstdc++-v3/src/c++11/thread.cc -@@ -55,6 +55,15 @@ static inline int get_nprocs() - #elif defined(_GLIBCXX_USE_SC_NPROC_ONLN) - # include - # define _GLIBCXX_NPROCS sysconf(_SC_NPROC_ONLN) -+#elif defined(_WIN32) -+# include -+static inline int get_nprocs() -+{ -+ SYSTEM_INFO sysinfo; -+ GetSystemInfo(&sysinfo); -+ return (int)sysinfo.dwNumberOfProcessors; -+} -+# define _GLIBCXX_NPROCS get_nprocs() - #else - # define _GLIBCXX_NPROCS 0 - #endif --- -2.17.0 - diff --git a/pkgs/development/compilers/gcc/9/avoid-cycling-subreg-reloads.patch b/pkgs/development/compilers/gcc/9/avoid-cycling-subreg-reloads.patch deleted file mode 100644 index 17a4e0a2447..00000000000 --- a/pkgs/development/compilers/gcc/9/avoid-cycling-subreg-reloads.patch +++ /dev/null @@ -1,261 +0,0 @@ -From 6001db79c477b03eacc7e7049560921fb54b7845 Mon Sep 17 00:00:00 2001 -From: Richard Sandiford -Date: Mon, 7 Sep 2020 20:15:36 +0100 -Subject: [PATCH] lra: Avoid cycling on certain subreg reloads [PR96796] - -This PR is about LRA cycling for a reload of the form: - ----------------------------------------------------------------------------- -Changing pseudo 196 in operand 1 of insn 103 on equiv [r105:DI*0x8+r140:DI] - Creating newreg=287, assigning class ALL_REGS to slow/invalid mem r287 - Creating newreg=288, assigning class ALL_REGS to slow/invalid mem r288 - 103: r203:SI=r288:SI<<0x1+r196:DI#0 - REG_DEAD r196:DI - Inserting slow/invalid mem reload before: - 316: r287:DI=[r105:DI*0x8+r140:DI] - 317: r288:SI=r287:DI#0 ----------------------------------------------------------------------------- - -The problem is with r287. We rightly give it a broad starting class of -POINTER_AND_FP_REGS (reduced from ALL_REGS by preferred_reload_class). -However, we never make forward progress towards narrowing it down to -a specific choice of class (POINTER_REGS or FP_REGS). - -I think in practice we rely on two things to narrow a reload pseudo's -class down to a specific choice: - -(1) a restricted class is specified when the pseudo is created - - This happens for input address reloads, where the class is taken - from the target's chosen base register class. It also happens - for simple REG reloads, where the class is taken from the chosen - alternative's constraints. - -(2) uses of the reload pseudo as a direct input operand - - In this case get_reload_reg tries to reuse the existing register - and narrow its class, instead of creating a new reload pseudo. - -However, neither occurs here. As described above, r287 rightly -starts out with a wide choice of class, ultimately derived from -ALL_REGS, so we don't get (1). And as the comments in the PR -explain, r287 is never used as an input reload, only the subreg is, -so we don't get (2): - ----------------------------------------------------------------------------- - Choosing alt 13 in insn 317: (0) r (1) w {*movsi_aarch64} - Creating newreg=291, assigning class FP_REGS to r291 - 317: r288:SI=r291:SI - Inserting insn reload before: - 320: r291:SI=r287:DI#0 ----------------------------------------------------------------------------- - -IMO, in this case we should rely on the reload of r316 to narrow -down the class of r278. Currently we do: - ----------------------------------------------------------------------------- - Choosing alt 7 in insn 316: (0) r (1) m {*movdi_aarch64} - Creating newreg=289 from oldreg=287, assigning class GENERAL_REGS to r289 - 316: r289:DI=[r105:DI*0x8+r140:DI] - Inserting insn reload after: - 318: r287:DI=r289:DI ---------------------------------------------------- - -i.e. we create a new pseudo register r289 and give *that* pseudo -GENERAL_REGS instead. This is because get_reload_reg only narrows -down the existing class for OP_IN and OP_INOUT, not OP_OUT. - -But if we have a reload pseudo in a reload instruction and have chosen -a specific class for the reload pseudo, I think we should simply install -it for OP_OUT reloads too, if the class is a subset of the existing class. -We will need to pick such a register whatever happens (for r289 in the -example above). And as explained in the PR, doing this actually avoids -an unnecessary move via the FP registers too. - -The patch is quite aggressive in that it does this for all reload -pseudos in all reload instructions. I wondered about reusing the -condition for a reload move in in_class_p: - - INSN_UID (curr_insn) >= new_insn_uid_start - && curr_insn_set != NULL - && ((OBJECT_P (SET_SRC (curr_insn_set)) - && ! CONSTANT_P (SET_SRC (curr_insn_set))) - || (GET_CODE (SET_SRC (curr_insn_set)) == SUBREG - && OBJECT_P (SUBREG_REG (SET_SRC (curr_insn_set))) - && ! CONSTANT_P (SUBREG_REG (SET_SRC (curr_insn_set))))))) - -but I can't really justify that on first principles. I think we -should apply the rule consistently until we have a specific reason -for doing otherwise. - -gcc/ - PR rtl-optimization/96796 - * lra-constraints.c (in_class_p): Add a default-false - allow_all_reload_class_changes_p parameter. Do not treat - reload moves specially when the parameter is true. - (get_reload_reg): Try to narrow the class of an existing OP_OUT - reload if we're reloading a reload pseudo in a reload instruction. - -gcc/testsuite/ - PR rtl-optimization/96796 - * gcc.c-torture/compile/pr96796.c: New test. ---- - gcc/lra-constraints.c | 54 ++++++++++++++---- - gcc/testsuite/gcc.c-torture/compile/pr96796.c | 55 +++++++++++++++++++ - 2 files changed, 99 insertions(+), 10 deletions(-) - create mode 100644 gcc/testsuite/gcc.c-torture/compile/pr96796.c - -diff --git a/gcc/lra-constraints.c b/gcc/lra-constraints.c -index 580da9c3ed6..161b721efb1 100644 ---- a/gcc/lra-constraints.c -+++ b/gcc/lra-constraints.c -@@ -236,12 +236,17 @@ get_reg_class (int regno) - CL. Use elimination first if REG is a hard register. If REG is a - reload pseudo created by this constraints pass, assume that it will - be allocated a hard register from its allocno class, but allow that -- class to be narrowed to CL if it is currently a superset of CL. -+ class to be narrowed to CL if it is currently a superset of CL and -+ if either: -+ -+ - ALLOW_ALL_RELOAD_CLASS_CHANGES_P is true or -+ - the instruction we're processing is not a reload move. - - If NEW_CLASS is nonnull, set *NEW_CLASS to the new allocno class of - REGNO (reg), or NO_REGS if no change in its class was needed. */ - static bool --in_class_p (rtx reg, enum reg_class cl, enum reg_class *new_class) -+in_class_p (rtx reg, enum reg_class cl, enum reg_class *new_class, -+ bool allow_all_reload_class_changes_p = false) - { - enum reg_class rclass, common_class; - machine_mode reg_mode; -@@ -266,7 +271,8 @@ in_class_p (rtx reg, enum reg_class cl, enum reg_class *new_class) - typically moves that have many alternatives, and restricting - reload pseudos for one alternative may lead to situations - where other reload pseudos are no longer allocatable. */ -- || (INSN_UID (curr_insn) >= new_insn_uid_start -+ || (!allow_all_reload_class_changes_p -+ && INSN_UID (curr_insn) >= new_insn_uid_start - && curr_insn_set != NULL - && ((OBJECT_P (SET_SRC (curr_insn_set)) - && ! CONSTANT_P (SET_SRC (curr_insn_set))) -@@ -598,13 +604,12 @@ canonicalize_reload_addr (rtx addr) - return addr; - } - --/* Create a new pseudo using MODE, RCLASS, ORIGINAL or reuse already -- created input reload pseudo (only if TYPE is not OP_OUT). Don't -- reuse pseudo if IN_SUBREG_P is true and the reused pseudo should be -- wrapped up in SUBREG. The result pseudo is returned through -- RESULT_REG. Return TRUE if we created a new pseudo, FALSE if we -- reused the already created input reload pseudo. Use TITLE to -- describe new registers for debug purposes. */ -+/* Create a new pseudo using MODE, RCLASS, ORIGINAL or reuse an existing -+ reload pseudo. Don't reuse an existing reload pseudo if IN_SUBREG_P -+ is true and the reused pseudo should be wrapped up in a SUBREG. -+ The result pseudo is returned through RESULT_REG. Return TRUE if we -+ created a new pseudo, FALSE if we reused an existing reload pseudo. -+ Use TITLE to describe new registers for debug purposes. */ - static bool - get_reload_reg (enum op_type type, machine_mode mode, rtx original, - enum reg_class rclass, bool in_subreg_p, -@@ -616,6 +621,35 @@ get_reload_reg (enum op_type type, machine_mode mode, rtx original, - - if (type == OP_OUT) - { -+ /* Output reload registers tend to start out with a conservative -+ choice of register class. Usually this is ALL_REGS, although -+ a target might narrow it (for performance reasons) through -+ targetm.preferred_reload_class. It's therefore quite common -+ for a reload instruction to require a more restrictive class -+ than the class that was originally assigned to the reload register. -+ -+ In these situations, it's more efficient to refine the choice -+ of register class rather than create a second reload register. -+ This also helps to avoid cycling for registers that are only -+ used by reload instructions. */ -+ if (REG_P (original) -+ && (int) REGNO (original) >= new_regno_start -+ && INSN_UID (curr_insn) >= new_insn_uid_start -+ && in_class_p (original, rclass, &new_class, true)) -+ { -+ unsigned int regno = REGNO (original); -+ if (lra_dump_file != NULL) -+ { -+ fprintf (lra_dump_file, " Reuse r%d for output ", regno); -+ dump_value_slim (lra_dump_file, original, 1); -+ } -+ if (new_class != lra_get_allocno_class (regno)) -+ lra_change_class (regno, new_class, ", change to", false); -+ if (lra_dump_file != NULL) -+ fprintf (lra_dump_file, "\n"); -+ *result_reg = original; -+ return false; -+ } - *result_reg - = lra_create_new_reg_with_unique_value (mode, original, rclass, title); - return true; -diff --git a/gcc/testsuite/gcc.c-torture/compile/pr96796.c b/gcc/testsuite/gcc.c-torture/compile/pr96796.c -new file mode 100644 -index 00000000000..8808e62fe77 ---- /dev/null -+++ b/gcc/testsuite/gcc.c-torture/compile/pr96796.c -@@ -0,0 +1,55 @@ -+/* { dg-additional-options "-fcommon" } */ -+ -+struct S0 { -+ signed f0 : 8; -+ unsigned f1; -+ unsigned f4; -+}; -+struct S1 { -+ long f3; -+ char f4; -+} g_3_4; -+ -+int g_5, func_1_l_32, func_50___trans_tmp_31; -+static struct S0 g_144, g_834, g_1255, g_1261; -+ -+int g_273[120] = {}; -+int *g_555; -+char **g_979; -+static int g_1092_0; -+static int g_1193; -+int safe_mul_func_int16_t_s_s(int si1, int si2) { return si1 * si2; } -+static struct S0 *func_50(); -+int func_1() { func_50(g_3_4, g_5, func_1_l_32, 8, 3); } -+void safe_div_func_int64_t_s_s(int *); -+void safe_mod_func_uint32_t_u_u(struct S0); -+struct S0 *func_50(int p_51, struct S0 p_52, struct S1 p_53, int p_54, -+ int p_55) { -+ int __trans_tmp_30; -+ char __trans_tmp_22; -+ short __trans_tmp_19; -+ long l_985_1; -+ long l_1191[8]; -+ safe_div_func_int64_t_s_s(g_273); -+ __builtin_printf((char*)g_1261.f4); -+ safe_mod_func_uint32_t_u_u(g_834); -+ g_144.f0 += 1; -+ for (;;) { -+ struct S1 l_1350 = {&l_1350}; -+ for (; p_53.f3; p_53.f3 -= 1) -+ for (; g_1193 <= 2; g_1193 += 1) { -+ __trans_tmp_19 = safe_mul_func_int16_t_s_s(l_1191[l_985_1 + p_53.f3], -+ p_55 % (**g_979 = 10)); -+ __trans_tmp_22 = g_1255.f1 * p_53.f4; -+ __trans_tmp_30 = __trans_tmp_19 + __trans_tmp_22; -+ if (__trans_tmp_30) -+ g_1261.f0 = p_51; -+ else { -+ g_1255.f0 = p_53.f3; -+ int *l_1422 = g_834.f0 = g_144.f4 != (*l_1422)++ > 0 < 0 ^ 51; -+ g_555 = ~0; -+ g_1092_0 |= func_50___trans_tmp_31; -+ } -+ } -+ } -+} --- -2.18.4 - diff --git a/pkgs/development/compilers/gcc/9/default.nix b/pkgs/development/compilers/gcc/9/default.nix deleted file mode 100644 index d08de2a5b79..00000000000 --- a/pkgs/development/compilers/gcc/9/default.nix +++ /dev/null @@ -1,294 +0,0 @@ -{ lib, stdenv, targetPackages, fetchurl, fetchpatch, noSysDirs -, langC ? true, langCC ? true, langFortran ? false -, langAda ? false -, langObjC ? stdenv.targetPlatform.isDarwin -, langObjCpp ? stdenv.targetPlatform.isDarwin -, langD ? false -, langGo ? false -, reproducibleBuild ? true -, profiledCompiler ? false -, langJit ? false -, staticCompiler ? false -, enableShared ? stdenv.targetPlatform.hasSharedLibraries -, enableLTO ? stdenv.hostPlatform.hasSharedLibraries -, texinfo ? null -, perl ? null # optional, for texi2pod (then pod2man) -, gmp, mpfr, libmpc, gettext, which, patchelf, binutils -, isl ? null # optional, for the Graphite optimization framework. -, zlib ? null -, gnat-bootstrap ? null -, enableMultilib ? false -, enablePlugin ? stdenv.hostPlatform == stdenv.buildPlatform # Whether to support user-supplied plug-ins -, name ? "gcc" -, libcCross ? null -, threadsCross ? null # for MinGW -, withoutTargetLibc ? false -, gnused ? null -, cloog # unused; just for compat with gcc4, as we override the parameter on some places -, buildPackages -, callPackage -}: - -# Note: this package is used for bootstrapping fetchurl, and thus -# cannot use fetchpatch! All mutable patches (generated by GitHub or -# cgit) that are needed here should be included directly in Nixpkgs as -# files. - -# Make sure we get GNU sed. -assert stdenv.buildPlatform.isDarwin -> gnused != null; - -# The go frontend is written in c++ -assert langGo -> langCC; -assert langAda -> gnat-bootstrap != null; - -# threadsCross is just for MinGW -assert threadsCross != {} -> stdenv.targetPlatform.isWindows; - -# profiledCompiler builds inject non-determinism in one of the compilation stages. -# If turned on, we can't provide reproducible builds anymore -assert reproducibleBuild -> profiledCompiler == false; - -with lib; -with builtins; - -let majorVersion = "9"; - version = "${majorVersion}.5.0"; - - inherit (stdenv) buildPlatform hostPlatform targetPlatform; - - patches = [ - ./fix-struct-redefinition-on-glibc-2.36.patch - # Fix https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80431 - ../fix-bug-80431.patch - ] ++ optional (targetPlatform != hostPlatform) ../libstdc++-target.patch - ++ optional targetPlatform.isNetBSD ../libstdc++-netbsd-ctypes.patch - ++ optional noSysDirs ../no-sys-dirs.patch - ++ optional (noSysDirs && hostPlatform.isRiscV) ../no-sys-dirs-riscv-gcc9.patch - /* ++ optional (hostPlatform != buildPlatform) (fetchpatch { # XXX: Refine when this should be applied - url = "https://git.busybox.net/buildroot/plain/package/gcc/${version}/0900-remove-selftests.patch?id=11271540bfe6adafbc133caf6b5b902a816f5f02"; - sha256 = ""; # TODO: uncomment and check hash when available. - }) */ - ++ optional langAda ../gnat-cflags.patch - ++ optional langD ../libphobos.patch - ++ optional langFortran ../gfortran-driving.patch - ++ optional (targetPlatform.libc == "musl" && targetPlatform.isPower) ../ppc-musl.patch - - # Obtain latest patch with ../update-mcfgthread-patches.sh - ++ optional (!withoutTargetLibc && targetPlatform.isMinGW && threadsCross.model == "mcf") ./Added-mcf-thread-model-support-from-mcfgthread.patch - ; - - /* Cross-gcc settings (build == host != target) */ - crossMingw = targetPlatform != hostPlatform && targetPlatform.libc == "msvcrt"; - stageNameAddon = if withoutTargetLibc then "stage-static" else "stage-final"; - crossNameAddon = optionalString (targetPlatform != hostPlatform) "${targetPlatform.config}-${stageNameAddon}-"; - - callFile = lib.callPackageWith { - # lets - inherit - majorVersion - version - buildPlatform - hostPlatform - targetPlatform - patches - crossMingw - stageNameAddon - crossNameAddon - ; - # inherit generated with 'nix eval --json --impure --expr "with import ./. {}; lib.attrNames (lib.functionArgs gcc9.cc.override)" | jq '.[]' --raw-output' - inherit - binutils - buildPackages - cloog - withoutTargetLibc - enableLTO - enableMultilib - enablePlugin - enableShared - fetchpatch - fetchurl - gettext - gmp - gnat-bootstrap - gnused - isl - langAda - langC - langCC - langD - langFortran - langGo - langJit - langObjC - langObjCpp - lib - libcCross - libmpc - mpfr - name - noSysDirs - patchelf - perl - profiledCompiler - reproducibleBuild - staticCompiler - stdenv - targetPackages - texinfo - threadsCross - which - zip - zlib - ; - }; - -in - -lib.pipe ((callFile ../common/builder.nix {}) ({ - pname = "${crossNameAddon}${name}"; - inherit version; - - src = fetchurl { - url = "mirror://gcc/releases/gcc-${version}/gcc-${version}.tar.xz"; - sha256 = "13ygjmd938m0wmy946pxdhz9i1wq7z4w10l6pvidak0xxxj9yxi7"; - }; - - inherit patches; - - outputs = [ "out" "man" "info" ] ++ lib.optional (!langJit) "lib"; - setOutputFlags = false; - NIX_NO_SELF_RPATH = true; - - libc_dev = stdenv.cc.libc_dev; - - hardeningDisable = [ "format" "pie" ]; - - postPatch = '' - configureScripts=$(find . -name configure) - for configureScript in $configureScripts; do - patchShebangs $configureScript - done - '' - # This should kill all the stdinc frameworks that gcc and friends like to - # insert into default search paths. - + lib.optionalString hostPlatform.isDarwin '' - substituteInPlace gcc/config/darwin-c.c \ - --replace 'if (stdinc)' 'if (0)' - - substituteInPlace libgcc/config/t-slibgcc-darwin \ - --replace "-install_name @shlib_slibdir@/\$(SHLIB_INSTALL_NAME)" "-install_name ''${!outputLib}/lib/\$(SHLIB_INSTALL_NAME)" - - substituteInPlace libgfortran/configure \ - --replace "-install_name \\\$rpath/\\\$soname" "-install_name ''${!outputLib}/lib/\\\$soname" - '' - + ( - lib.optionalString (targetPlatform != hostPlatform || stdenv.cc.libc != null) - # On NixOS, use the right path to the dynamic linker instead of - # `/lib/ld*.so'. - (let - libc = if libcCross != null then libcCross else stdenv.cc.libc; - in - ( - '' echo "fixing the \`GLIBC_DYNAMIC_LINKER', \`UCLIBC_DYNAMIC_LINKER', and \`MUSL_DYNAMIC_LINKER' macros..." - for header in "gcc/config/"*-gnu.h "gcc/config/"*"/"*.h - do - grep -q _DYNAMIC_LINKER "$header" || continue - echo " fixing \`$header'..." - sed -i "$header" \ - -e 's|define[[:blank:]]*\([UCG]\+\)LIBC_DYNAMIC_LINKER\([0-9]*\)[[:blank:]]"\([^\"]\+\)"$|define \1LIBC_DYNAMIC_LINKER\2 "${libc.out}\3"|g' \ - -e 's|define[[:blank:]]*MUSL_DYNAMIC_LINKER\([0-9]*\)[[:blank:]]"\([^\"]\+\)"$|define MUSL_DYNAMIC_LINKER\1 "${libc.out}\2"|g' - done - '' - + lib.optionalString (targetPlatform.libc == "musl") - '' - sed -i gcc/config/linux.h -e '1i#undef LOCAL_INCLUDE_DIR' - '' - )) - ) - + lib.optionalString targetPlatform.isAvr '' - makeFlagsArray+=( - 'LIMITS_H_TEST=false' - ) - ''; - - inherit noSysDirs staticCompiler withoutTargetLibc - libcCross crossMingw; - - inherit (callFile ../common/dependencies.nix { }) - depsBuildBuild nativeBuildInputs depsBuildTarget buildInputs depsTargetTarget; - - NIX_LDFLAGS = lib.optionalString hostPlatform.isSunOS "-lm"; - - preConfigure = callFile ../common/pre-configure.nix { }; - - dontDisableStatic = true; - - configurePlatforms = [ "build" "host" "target" ]; - - configureFlags = callFile ../common/configure-flags.nix { }; - - targetConfig = if targetPlatform != hostPlatform then targetPlatform.config else null; - - buildFlags = optional - (targetPlatform == hostPlatform && hostPlatform == buildPlatform) - (if profiledCompiler then "profiledbootstrap" else "bootstrap"); - - # https://gcc.gnu.org/PR109898 - enableParallelInstalling = false; - - inherit (callFile ../common/strip-attributes.nix { }) - stripDebugList - stripDebugListTarget - preFixup; - - # https://gcc.gnu.org/install/specific.html#x86-64-x-solaris210 - ${if hostPlatform.system == "x86_64-solaris" then "CC" else null} = "gcc -m64"; - - # Setting $CPATH and $LIBRARY_PATH to make sure both `gcc' and `xgcc' find the - # library headers and binaries, regarless of the language being compiled. - # - # Likewise, the LTO code doesn't find zlib. - # - # Cross-compiling, we need gcc not to read ./specs in order to build the g++ - # compiler (after the specs for the cross-gcc are created). Having - # LIBRARY_PATH= makes gcc read the specs from ., and the build breaks. - - CPATH = optionals (targetPlatform == hostPlatform) (makeSearchPathOutput "dev" "include" ([] - ++ optional (zlib != null) zlib - )); - - LIBRARY_PATH = optionals (targetPlatform == hostPlatform) (makeLibraryPath (optional (zlib != null) zlib)); - - inherit (callFile ../common/extra-target-flags.nix { }) - EXTRA_FLAGS_FOR_TARGET - EXTRA_LDFLAGS_FOR_TARGET - ; - - passthru = { - inherit langC langCC langObjC langObjCpp langAda langFortran langGo langD version; - isGNU = true; - hardeningUnsupportedFlags = [ "fortify3" ]; - }; - - enableParallelBuilding = true; - inherit enableShared enableMultilib; - - meta = { - inherit (callFile ../common/meta.nix { }) - homepage - license - description - longDescription - platforms - maintainers - ; - badPlatforms = [ "aarch64-darwin" ]; - }; -} - - -// optionalAttrs (enableMultilib) { dontMoveLib64 = true; } -) -) [ - (callPackage ../common/libgcc.nix { inherit version langC langCC langJit targetPlatform hostPlatform withoutTargetLibc enableShared; }) -] diff --git a/pkgs/development/compilers/gcc/9/fix-struct-redefinition-on-glibc-2.36.patch b/pkgs/development/compilers/gcc/9/fix-struct-redefinition-on-glibc-2.36.patch deleted file mode 100644 index 5b4abfd02e0..00000000000 --- a/pkgs/development/compilers/gcc/9/fix-struct-redefinition-on-glibc-2.36.patch +++ /dev/null @@ -1,31 +0,0 @@ -Derived from ../11/fix-struct-redefinition-on-glibc-2.36.patch (upstream commit d2356ebb0084a0d80dbfe33040c9afe938c15d19) - -diff --git a/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cc b/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cc -index e8fce8a02..cb1ac806e 100644 ---- a/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cc -+++ b/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cc -@@ -65,7 +65,9 @@ - #include - #include - #include -+#if SANITIZER_ANDROID - #include -+#endif - #include - #include - #include -@@ -846,10 +848,10 @@ unsigned struct_ElfW_Phdr_sz = sizeof(Elf_Phdr); - unsigned IOCTL_EVIOCGPROP = IOCTL_NOT_PRESENT; - unsigned IOCTL_EVIOCSKEYCODE_V2 = IOCTL_NOT_PRESENT; - #endif -- unsigned IOCTL_FS_IOC_GETFLAGS = FS_IOC_GETFLAGS; -- unsigned IOCTL_FS_IOC_GETVERSION = FS_IOC_GETVERSION; -- unsigned IOCTL_FS_IOC_SETFLAGS = FS_IOC_SETFLAGS; -- unsigned IOCTL_FS_IOC_SETVERSION = FS_IOC_SETVERSION; -+ unsigned IOCTL_FS_IOC_GETFLAGS = _IOR('f', 1, long); -+ unsigned IOCTL_FS_IOC_GETVERSION = _IOR('v', 1, long); -+ unsigned IOCTL_FS_IOC_SETFLAGS = _IOW('f', 2, long); -+ unsigned IOCTL_FS_IOC_SETVERSION = _IOW('v', 2, long); - unsigned IOCTL_GIO_CMAP = GIO_CMAP; - unsigned IOCTL_GIO_FONT = GIO_FONT; - unsigned IOCTL_GIO_UNIMAP = GIO_UNIMAP; diff --git a/pkgs/development/compilers/gcc/9/gcc9-asan-glibc-2.34.patch b/pkgs/development/compilers/gcc/9/gcc9-asan-glibc-2.34.patch deleted file mode 100644 index 1aea1f9b18a..00000000000 --- a/pkgs/development/compilers/gcc/9/gcc9-asan-glibc-2.34.patch +++ /dev/null @@ -1,70 +0,0 @@ -From 3d0135bf3be416bbe2531dc763d19b749eb2b856 Mon Sep 17 00:00:00 2001 -From: Jakub Jelinek -Date: Sat, 17 Apr 2021 11:27:14 +0200 -Subject: [PATCH] sanitizer: Fix asan against glibc 2.34 [PR100114] - -As mentioned in the PR, SIGSTKSZ is no longer a compile time constant in -glibc 2.34 and later, so -static const uptr kAltStackSize = SIGSTKSZ * 4; -needs dynamic initialization, but is used by a function called indirectly -from .preinit_array and therefore before the variable is constructed. -This results in using 0 size instead and all asan instrumented programs -die with: -==91==ERROR: AddressSanitizer failed to allocate 0x0 (0) bytes of SetAlternateSignalStack (error code: 22) - -Here is a cherry-pick from upstream to fix this. - -2021-04-17 Jakub Jelinek - - PR sanitizer/100114 - * sanitizer_common/sanitizer_posix_libcdep.cc: Cherry-pick - llvm-project revisions 82150606fb11d28813ae6da1101f5bda638165fe - and b93629dd335ffee2fc4b9b619bf86c3f9e6b0023. - -(cherry picked from commit 950bac27d63c1c2ac3a6ed867692d6a13f21feb3) ---- - .../sanitizer_common/sanitizer_posix_libcdep.cc | 13 ++++++++----- - 1 file changed, 8 insertions(+), 5 deletions(-) - -diff --git a/libsanitizer/sanitizer_common/sanitizer_posix_libcdep.cc b/libsanitizer/sanitizer_common/sanitizer_posix_libcdep.cc -index d2fd76a6d36..1917e29ced2 100644 ---- a/libsanitizer/sanitizer_common/sanitizer_posix_libcdep.cc -+++ b/libsanitizer/sanitizer_common/sanitizer_posix_libcdep.cc -@@ -169,7 +169,11 @@ bool SupportsColoredOutput(fd_t fd) { - - #if !SANITIZER_GO - // TODO(glider): different tools may require different altstack size. --static const uptr kAltStackSize = SIGSTKSZ * 4; // SIGSTKSZ is not enough. -+static uptr GetAltStackSize() { -+ // SIGSTKSZ is not enough. -+ static const uptr kAltStackSize = SIGSTKSZ * 4; -+ return kAltStackSize; -+} - - void SetAlternateSignalStack() { - stack_t altstack, oldstack; -@@ -180,10 +184,9 @@ void SetAlternateSignalStack() { - // TODO(glider): the mapped stack should have the MAP_STACK flag in the - // future. It is not required by man 2 sigaltstack now (they're using - // malloc()). -- void* base = MmapOrDie(kAltStackSize, __func__); -- altstack.ss_sp = (char*) base; -+ altstack.ss_size = GetAltStackSize(); -+ altstack.ss_sp = (char *)MmapOrDie(altstack.ss_size, __func__); - altstack.ss_flags = 0; -- altstack.ss_size = kAltStackSize; - CHECK_EQ(0, sigaltstack(&altstack, nullptr)); - } - -@@ -191,7 +194,7 @@ void UnsetAlternateSignalStack() { - stack_t altstack, oldstack; - altstack.ss_sp = nullptr; - altstack.ss_flags = SS_DISABLE; -- altstack.ss_size = kAltStackSize; // Some sane value required on Darwin. -+ altstack.ss_size = GetAltStackSize(); // Some sane value required on Darwin. - CHECK_EQ(0, sigaltstack(&altstack, &oldstack)); - UnmapOrDie(oldstack.ss_sp, oldstack.ss_size); - } --- -2.27.0 - diff --git a/pkgs/development/compilers/gcc/default.nix b/pkgs/development/compilers/gcc/default.nix index 4b9282adc68..adfadd2e391 100644 --- a/pkgs/development/compilers/gcc/default.nix +++ b/pkgs/development/compilers/gcc/default.nix @@ -39,10 +39,11 @@ let atLeast12 = lib.versionAtLeast version "12"; atLeast11 = lib.versionAtLeast version "11"; atLeast10 = lib.versionAtLeast version "10"; + atLeast9 = lib.versionAtLeast version "9"; in -# only gcc>=10 is currently supported -assert atLeast10; +# only gcc>=9 is currently supported +assert atLeast9; # Make sure we get GNU sed. assert stdenv.buildPlatform.isDarwin -> gnused != null; @@ -72,12 +73,15 @@ let majorVersion = lib.versions.major version; inherit (stdenv) buildPlatform hostPlatform targetPlatform; patches = - optional (!atLeast12) ./fix-bug-80431.patch - ++ optional (!atLeast11) ./11/fix-struct-redefinition-on-glibc-2.36.patch + optional (!atLeast10) ./9/fix-struct-redefinition-on-glibc-2.36.patch + ++ optional (!atLeast12) ./fix-bug-80431.patch + ++ optional (atLeast10 && !atLeast11) ./11/fix-struct-redefinition-on-glibc-2.36.patch ++ optional (targetPlatform != hostPlatform) ./libstdc++-target.patch + ++ optional (!atLeast10 && targetPlatform.isNetBSD) ./libstdc++-netbsd-ctypes.patch ++ optional (noSysDirs && atLeast12) ./gcc-12-no-sys-dirs.patch ++ optional (noSysDirs && !atLeast12) ./no-sys-dirs.patch - ++ optional (noSysDirs && (is10 || (!atLeast12 -> hostPlatform.isRiscV))) ./no-sys-dirs-riscv.patch + ++ optional (noSysDirs && atLeast10 && (is10 || !atLeast12 -> hostPlatform.isRiscV)) ./no-sys-dirs-riscv.patch + ++ optional (noSysDirs && !atLeast10 && hostPlatform.isRiscV) ./no-sys-dirs-riscv-gcc9.patch ++ optionals (langAda || atLeast12) [ ./gnat-cflags-11.patch ] ++ optionals (langAda && !atLeast11) [ @@ -171,7 +175,7 @@ let majorVersion = lib.versions.major version; # openjdk build fails without this on -march=opteron; is upstream in gcc12 ++ optionals (majorVersion == "11") [ ./11/gcc-issue-103910.patch ] - ++ optional (!atLeast11 && buildPlatform.system == "aarch64-darwin" && targetPlatform != buildPlatform) (fetchpatch { + ++ optional (majorVersion == "10" && buildPlatform.system == "aarch64-darwin" && targetPlatform != buildPlatform) (fetchpatch { url = "https://raw.githubusercontent.com/richard-vd/musl-cross-make/5e9e87f06fc3220e102c29d3413fbbffa456fcd6/patches/gcc-${version}/0008-darwin-aarch64-self-host-driver.patch"; sha256 = "sha256-XtykrPd5h/tsnjY1wGjzSOJ+AyyNLsfnjuOZ5Ryq9vA="; }); @@ -259,6 +263,7 @@ lib.pipe ((callFile ./common/builder.nix {}) ({ "12.3.0" = "sha256-lJpdT5nnhkIak7Uysi/6tVeN5zITaZdbka7Jet/ajDs="; "11.4.0" = "sha256-Py2yIrAH6KSiPNW6VnJu8I6LHx6yBV7nLBQCzqc6jdk="; "10.5.0" = "sha256-JRCVQ/30bzl8NHtdi3osflaUpaUczkucbh6opxyjB8E="; + "9.5.0" = "13ygjmd938m0wmy946pxdhz9i1wq7z4w10l6pvidak0xxxj9yxi7"; }."${version}"; }; @@ -315,12 +320,14 @@ lib.pipe ((callFile ./common/builder.nix {}) ({ '' ) )) - + lib.optionalString targetPlatform.isAvr '' + + lib.optionalString targetPlatform.isAvr ('' makeFlagsArray+=( + '' + (lib.optionalString atLeast10 '' '-s' # workaround for hitting hydra log limit + '') + '' 'LIMITS_H_TEST=false' ) - ''; + ''); inherit noSysDirs staticCompiler withoutTargetLibc libcCross crossMingw; @@ -330,7 +337,7 @@ lib.pipe ((callFile ./common/builder.nix {}) ({ NIX_LDFLAGS = lib.optionalString hostPlatform.isSunOS "-lm"; - preConfigure = (callFile ./common/pre-configure.nix { }) + '' + preConfigure = (callFile ./common/pre-configure.nix { }) + lib.optionalString atLeast10 '' ln -sf ${libxcrypt}/include/crypt.h libsanitizer/sanitizer_common/crypt.h ''; diff --git a/pkgs/development/compilers/gcc/patches/9/Added-mcf-thread-model-support-from-mcfgthread.patch b/pkgs/development/compilers/gcc/patches/9/Added-mcf-thread-model-support-from-mcfgthread.patch new file mode 100644 index 00000000000..d9809e828f1 --- /dev/null +++ b/pkgs/development/compilers/gcc/patches/9/Added-mcf-thread-model-support-from-mcfgthread.patch @@ -0,0 +1,306 @@ +From 86f2f767ddffd9f7c6f1470b987ae7b0d251b988 Mon Sep 17 00:00:00 2001 +From: Liu Hao +Date: Wed, 25 Apr 2018 21:54:19 +0800 +Subject: [PATCH] Added 'mcf' thread model support from mcfgthread. + +Signed-off-by: Liu Hao +--- + config/gthr.m4 | 1 + + gcc/config.gcc | 3 +++ + gcc/config/i386/mingw-mcfgthread.h | 1 + + gcc/config/i386/mingw-w64.h | 2 +- + gcc/config/i386/mingw32.h | 11 ++++++++++- + gcc/configure | 2 +- + gcc/configure.ac | 2 +- + libatomic/configure.tgt | 2 +- + libgcc/config.host | 6 ++++++ + libgcc/config/i386/gthr-mcf.h | 1 + + libgcc/config/i386/t-mingw-mcfgthread | 2 ++ + libgcc/configure | 1 + + libstdc++-v3/configure | 1 + + libstdc++-v3/libsupc++/atexit_thread.cc | 18 ++++++++++++++++++ + libstdc++-v3/libsupc++/guard.cc | 23 +++++++++++++++++++++++ + libstdc++-v3/src/c++11/thread.cc | 9 +++++++++ + 16 files changed, 80 insertions(+), 5 deletions(-) + create mode 100644 gcc/config/i386/mingw-mcfgthread.h + create mode 100644 libgcc/config/i386/gthr-mcf.h + create mode 100644 libgcc/config/i386/t-mingw-mcfgthread + +diff --git a/config/gthr.m4 b/config/gthr.m4 +index 7b29f1f3327..82e21fe1709 100644 +--- a/config/gthr.m4 ++++ b/config/gthr.m4 +@@ -21,6 +21,7 @@ case $1 in + tpf) thread_header=config/s390/gthr-tpf.h ;; + vxworks) thread_header=config/gthr-vxworks.h ;; + win32) thread_header=config/i386/gthr-win32.h ;; ++ mcf) thread_header=config/i386/gthr-mcf.h ;; + esac + AC_SUBST(thread_header) + ]) +diff --git a/gcc/config.gcc b/gcc/config.gcc +index 46a9029acec..112c24e95a3 100644 +--- a/gcc/config.gcc ++++ b/gcc/config.gcc +@@ -1758,6 +1758,9 @@ i[34567]86-*-mingw* | x86_64-*-mingw*) + if test x$enable_threads = xposix ; then + tm_file="${tm_file} i386/mingw-pthread.h" + fi ++ if test x$enable_threads = xmcf ; then ++ tm_file="${tm_file} i386/mingw-mcfgthread.h" ++ fi + tm_file="${tm_file} i386/mingw32.h" + # This makes the logic if mingw's or the w64 feature set has to be used + case ${target} in +diff --git a/gcc/config/i386/mingw-mcfgthread.h b/gcc/config/i386/mingw-mcfgthread.h +new file mode 100644 +index 00000000000..ec381a7798f +--- /dev/null ++++ b/gcc/config/i386/mingw-mcfgthread.h +@@ -0,0 +1 @@ ++#define TARGET_USE_MCFGTHREAD 1 +diff --git a/gcc/config/i386/mingw-w64.h b/gcc/config/i386/mingw-w64.h +index 484dc7a9e9f..a15bbeea500 100644 +--- a/gcc/config/i386/mingw-w64.h ++++ b/gcc/config/i386/mingw-w64.h +@@ -48,7 +48,7 @@ along with GCC; see the file COPYING3. If not see + "%{mwindows:-lgdi32 -lcomdlg32} " \ + "%{fvtable-verify=preinit:-lvtv -lpsapi; \ + fvtable-verify=std:-lvtv -lpsapi} " \ +- "-ladvapi32 -lshell32 -luser32 -lkernel32" ++ LIB_MCFGTHREAD "-ladvapi32 -lshell32 -luser32 -lkernel32" + + #undef SPEC_32 + #undef SPEC_64 +diff --git a/gcc/config/i386/mingw32.h b/gcc/config/i386/mingw32.h +index 0612b87199a..76cea94f3b7 100644 +--- a/gcc/config/i386/mingw32.h ++++ b/gcc/config/i386/mingw32.h +@@ -32,6 +32,14 @@ along with GCC; see the file COPYING3. If not see + | MASK_STACK_PROBE | MASK_ALIGN_DOUBLE \ + | MASK_MS_BITFIELD_LAYOUT) + ++#ifndef TARGET_USE_MCFGTHREAD ++#define CPP_MCFGTHREAD() ((void)0) ++#define LIB_MCFGTHREAD "" ++#else ++#define CPP_MCFGTHREAD() (builtin_define("__USING_MCFGTHREAD__")) ++#define LIB_MCFGTHREAD " -lmcfgthread " ++#endif ++ + /* See i386/crtdll.h for an alternative definition. _INTEGRAL_MAX_BITS + is for compatibility with native compiler. */ + #define EXTRA_OS_CPP_BUILTINS() \ +@@ -50,6 +58,7 @@ along with GCC; see the file COPYING3. If not see + builtin_define_std ("WIN64"); \ + builtin_define ("_WIN64"); \ + } \ ++ CPP_MCFGTHREAD(); \ + } \ + while (0) + +@@ -93,7 +102,7 @@ along with GCC; see the file COPYING3. If not see + "%{mwindows:-lgdi32 -lcomdlg32} " \ + "%{fvtable-verify=preinit:-lvtv -lpsapi; \ + fvtable-verify=std:-lvtv -lpsapi} " \ +- "-ladvapi32 -lshell32 -luser32 -lkernel32" ++ LIB_MCFGTHREAD "-ladvapi32 -lshell32 -luser32 -lkernel32" + + /* Weak symbols do not get resolved if using a Windows dll import lib. + Make the unwind registration references strong undefs. */ +diff --git a/gcc/configure b/gcc/configure +index 6121e163259..52f0e00efe6 100755 +--- a/gcc/configure ++++ b/gcc/configure +@@ -11693,7 +11693,7 @@ case ${enable_threads} in + target_thread_file='single' + ;; + aix | dce | lynx | mipssde | posix | rtems | \ +- single | tpf | vxworks | win32) ++ single | tpf | vxworks | win32 | mcf) + target_thread_file=${enable_threads} + ;; + *) +diff --git a/gcc/configure.ac b/gcc/configure.ac +index b066cc609e1..4ecdba88de7 100644 +--- a/gcc/configure.ac ++++ b/gcc/configure.ac +@@ -1612,7 +1612,7 @@ case ${enable_threads} in + target_thread_file='single' + ;; + aix | dce | lynx | mipssde | posix | rtems | \ +- single | tpf | vxworks | win32) ++ single | tpf | vxworks | win32 | mcf) + target_thread_file=${enable_threads} + ;; + *) +diff --git a/libatomic/configure.tgt b/libatomic/configure.tgt +index ea8c34f8c71..23134ad7363 100644 +--- a/libatomic/configure.tgt ++++ b/libatomic/configure.tgt +@@ -145,7 +145,7 @@ case "${target}" in + *-*-mingw*) + # OS support for atomic primitives. + case ${target_thread_file} in +- win32) ++ win32 | mcf) + config_path="${config_path} mingw" + ;; + posix) +diff --git a/libgcc/config.host b/libgcc/config.host +index 11b4acaff55..9fbd38650bd 100644 +--- a/libgcc/config.host ++++ b/libgcc/config.host +@@ -737,6 +737,9 @@ i[34567]86-*-mingw*) + posix) + tmake_file="i386/t-mingw-pthread $tmake_file" + ;; ++ mcf) ++ tmake_file="i386/t-mingw-mcfgthread $tmake_file" ++ ;; + esac + # This has to match the logic for DWARF2_UNWIND_INFO in gcc/config/i386/cygming.h + if test x$ac_cv_sjlj_exceptions = xyes; then +@@ -761,6 +764,9 @@ x86_64-*-mingw*) + posix) + tmake_file="i386/t-mingw-pthread $tmake_file" + ;; ++ mcf) ++ tmake_file="i386/t-mingw-mcfgthread $tmake_file" ++ ;; + esac + # This has to match the logic for DWARF2_UNWIND_INFO in gcc/config/i386/cygming.h + if test x$ac_cv_sjlj_exceptions = xyes; then +diff --git a/libgcc/config/i386/gthr-mcf.h b/libgcc/config/i386/gthr-mcf.h +new file mode 100644 +index 00000000000..5ea2908361f +--- /dev/null ++++ b/libgcc/config/i386/gthr-mcf.h +@@ -0,0 +1 @@ ++#include +diff --git a/libgcc/config/i386/t-mingw-mcfgthread b/libgcc/config/i386/t-mingw-mcfgthread +new file mode 100644 +index 00000000000..4b9b10e32d6 +--- /dev/null ++++ b/libgcc/config/i386/t-mingw-mcfgthread +@@ -0,0 +1,2 @@ ++SHLIB_PTHREAD_CFLAG = ++SHLIB_PTHREAD_LDFLAG = -lmcfgthread +diff --git a/libgcc/configure b/libgcc/configure +index b2f3f870844..eff889dc3b3 100644 +--- a/libgcc/configure ++++ b/libgcc/configure +@@ -5451,6 +5451,7 @@ case $target_thread_file in + tpf) thread_header=config/s390/gthr-tpf.h ;; + vxworks) thread_header=config/gthr-vxworks.h ;; + win32) thread_header=config/i386/gthr-win32.h ;; ++ mcf) thread_header=config/i386/gthr-mcf.h ;; + esac + + +diff --git a/libstdc++-v3/configure b/libstdc++-v3/configure +index ba094be6f15..979a5ab9ace 100755 +--- a/libstdc++-v3/configure ++++ b/libstdc++-v3/configure +@@ -15187,6 +15187,7 @@ case $target_thread_file in + tpf) thread_header=config/s390/gthr-tpf.h ;; + vxworks) thread_header=config/gthr-vxworks.h ;; + win32) thread_header=config/i386/gthr-win32.h ;; ++ mcf) thread_header=config/i386/gthr-mcf.h ;; + esac + + +diff --git a/libstdc++-v3/libsupc++/atexit_thread.cc b/libstdc++-v3/libsupc++/atexit_thread.cc +index de920d714c6..665fb74bd6b 100644 +--- a/libstdc++-v3/libsupc++/atexit_thread.cc ++++ b/libstdc++-v3/libsupc++/atexit_thread.cc +@@ -25,6 +25,22 @@ + #include + #include + #include "bits/gthr.h" ++ ++#ifdef __USING_MCFGTHREAD__ ++ ++#include ++ ++extern "C" int ++__cxxabiv1::__cxa_thread_atexit (void (*dtor)(void *), ++ void *obj, void *dso_handle) ++ _GLIBCXX_NOTHROW ++{ ++ return ::_MCFCRT_AtThreadExit((void (*)(_MCFCRT_STD intptr_t))dtor, (_MCFCRT_STD intptr_t)obj) ? 0 : -1; ++ (void)dso_handle; ++} ++ ++#else // __USING_MCFGTHREAD__ ++ + #ifdef _GLIBCXX_THREAD_ATEXIT_WIN32 + #define WIN32_LEAN_AND_MEAN + #include +@@ -167,3 +183,5 @@ __cxxabiv1::__cxa_thread_atexit (void (*dtor)(void *), void *obj, void */*dso_ha + } + + #endif /* _GLIBCXX_HAVE___CXA_THREAD_ATEXIT_IMPL */ ++ ++#endif // __USING_MCFGTHREAD__ +diff --git a/libstdc++-v3/libsupc++/guard.cc b/libstdc++-v3/libsupc++/guard.cc +index 3a2ec3ad0d6..8b4cc96199b 100644 +--- a/libstdc++-v3/libsupc++/guard.cc ++++ b/libstdc++-v3/libsupc++/guard.cc +@@ -28,6 +28,27 @@ + #include + #include + #include ++ ++#ifdef __USING_MCFGTHREAD__ ++ ++#include ++ ++namespace __cxxabiv1 { ++ ++extern "C" int __cxa_guard_acquire(__guard *g){ ++ return ::_MCFCRT_WaitForOnceFlagForever((::_MCFCRT_OnceFlag *)g) == ::_MCFCRT_kOnceResultInitial; ++} ++extern "C" void __cxa_guard_abort(__guard *g) throw() { ++ ::_MCFCRT_SignalOnceFlagAsAborted((::_MCFCRT_OnceFlag *)g); ++} ++extern "C" void __cxa_guard_release(__guard *g) throw() { ++ ::_MCFCRT_SignalOnceFlagAsFinished((::_MCFCRT_OnceFlag *)g); ++} ++ ++} ++ ++#else // __USING_MCFGTHREAD__ ++ + #include + #include + #include +@@ -425,3 +446,5 @@ namespace __cxxabiv1 + #endif + } + } ++ ++#endif +diff --git a/libstdc++-v3/src/c++11/thread.cc b/libstdc++-v3/src/c++11/thread.cc +index 8238817c2e9..0c6a1f85f6f 100644 +--- a/libstdc++-v3/src/c++11/thread.cc ++++ b/libstdc++-v3/src/c++11/thread.cc +@@ -55,6 +55,15 @@ static inline int get_nprocs() + #elif defined(_GLIBCXX_USE_SC_NPROC_ONLN) + # include + # define _GLIBCXX_NPROCS sysconf(_SC_NPROC_ONLN) ++#elif defined(_WIN32) ++# include ++static inline int get_nprocs() ++{ ++ SYSTEM_INFO sysinfo; ++ GetSystemInfo(&sysinfo); ++ return (int)sysinfo.dwNumberOfProcessors; ++} ++# define _GLIBCXX_NPROCS get_nprocs() + #else + # define _GLIBCXX_NPROCS 0 + #endif +-- +2.17.0 + diff --git a/pkgs/development/compilers/gcc/patches/9/avoid-cycling-subreg-reloads.patch b/pkgs/development/compilers/gcc/patches/9/avoid-cycling-subreg-reloads.patch new file mode 100644 index 00000000000..17a4e0a2447 --- /dev/null +++ b/pkgs/development/compilers/gcc/patches/9/avoid-cycling-subreg-reloads.patch @@ -0,0 +1,261 @@ +From 6001db79c477b03eacc7e7049560921fb54b7845 Mon Sep 17 00:00:00 2001 +From: Richard Sandiford +Date: Mon, 7 Sep 2020 20:15:36 +0100 +Subject: [PATCH] lra: Avoid cycling on certain subreg reloads [PR96796] + +This PR is about LRA cycling for a reload of the form: + +---------------------------------------------------------------------------- +Changing pseudo 196 in operand 1 of insn 103 on equiv [r105:DI*0x8+r140:DI] + Creating newreg=287, assigning class ALL_REGS to slow/invalid mem r287 + Creating newreg=288, assigning class ALL_REGS to slow/invalid mem r288 + 103: r203:SI=r288:SI<<0x1+r196:DI#0 + REG_DEAD r196:DI + Inserting slow/invalid mem reload before: + 316: r287:DI=[r105:DI*0x8+r140:DI] + 317: r288:SI=r287:DI#0 +---------------------------------------------------------------------------- + +The problem is with r287. We rightly give it a broad starting class of +POINTER_AND_FP_REGS (reduced from ALL_REGS by preferred_reload_class). +However, we never make forward progress towards narrowing it down to +a specific choice of class (POINTER_REGS or FP_REGS). + +I think in practice we rely on two things to narrow a reload pseudo's +class down to a specific choice: + +(1) a restricted class is specified when the pseudo is created + + This happens for input address reloads, where the class is taken + from the target's chosen base register class. It also happens + for simple REG reloads, where the class is taken from the chosen + alternative's constraints. + +(2) uses of the reload pseudo as a direct input operand + + In this case get_reload_reg tries to reuse the existing register + and narrow its class, instead of creating a new reload pseudo. + +However, neither occurs here. As described above, r287 rightly +starts out with a wide choice of class, ultimately derived from +ALL_REGS, so we don't get (1). And as the comments in the PR +explain, r287 is never used as an input reload, only the subreg is, +so we don't get (2): + +---------------------------------------------------------------------------- + Choosing alt 13 in insn 317: (0) r (1) w {*movsi_aarch64} + Creating newreg=291, assigning class FP_REGS to r291 + 317: r288:SI=r291:SI + Inserting insn reload before: + 320: r291:SI=r287:DI#0 +---------------------------------------------------------------------------- + +IMO, in this case we should rely on the reload of r316 to narrow +down the class of r278. Currently we do: + +---------------------------------------------------------------------------- + Choosing alt 7 in insn 316: (0) r (1) m {*movdi_aarch64} + Creating newreg=289 from oldreg=287, assigning class GENERAL_REGS to r289 + 316: r289:DI=[r105:DI*0x8+r140:DI] + Inserting insn reload after: + 318: r287:DI=r289:DI +--------------------------------------------------- + +i.e. we create a new pseudo register r289 and give *that* pseudo +GENERAL_REGS instead. This is because get_reload_reg only narrows +down the existing class for OP_IN and OP_INOUT, not OP_OUT. + +But if we have a reload pseudo in a reload instruction and have chosen +a specific class for the reload pseudo, I think we should simply install +it for OP_OUT reloads too, if the class is a subset of the existing class. +We will need to pick such a register whatever happens (for r289 in the +example above). And as explained in the PR, doing this actually avoids +an unnecessary move via the FP registers too. + +The patch is quite aggressive in that it does this for all reload +pseudos in all reload instructions. I wondered about reusing the +condition for a reload move in in_class_p: + + INSN_UID (curr_insn) >= new_insn_uid_start + && curr_insn_set != NULL + && ((OBJECT_P (SET_SRC (curr_insn_set)) + && ! CONSTANT_P (SET_SRC (curr_insn_set))) + || (GET_CODE (SET_SRC (curr_insn_set)) == SUBREG + && OBJECT_P (SUBREG_REG (SET_SRC (curr_insn_set))) + && ! CONSTANT_P (SUBREG_REG (SET_SRC (curr_insn_set))))))) + +but I can't really justify that on first principles. I think we +should apply the rule consistently until we have a specific reason +for doing otherwise. + +gcc/ + PR rtl-optimization/96796 + * lra-constraints.c (in_class_p): Add a default-false + allow_all_reload_class_changes_p parameter. Do not treat + reload moves specially when the parameter is true. + (get_reload_reg): Try to narrow the class of an existing OP_OUT + reload if we're reloading a reload pseudo in a reload instruction. + +gcc/testsuite/ + PR rtl-optimization/96796 + * gcc.c-torture/compile/pr96796.c: New test. +--- + gcc/lra-constraints.c | 54 ++++++++++++++---- + gcc/testsuite/gcc.c-torture/compile/pr96796.c | 55 +++++++++++++++++++ + 2 files changed, 99 insertions(+), 10 deletions(-) + create mode 100644 gcc/testsuite/gcc.c-torture/compile/pr96796.c + +diff --git a/gcc/lra-constraints.c b/gcc/lra-constraints.c +index 580da9c3ed6..161b721efb1 100644 +--- a/gcc/lra-constraints.c ++++ b/gcc/lra-constraints.c +@@ -236,12 +236,17 @@ get_reg_class (int regno) + CL. Use elimination first if REG is a hard register. If REG is a + reload pseudo created by this constraints pass, assume that it will + be allocated a hard register from its allocno class, but allow that +- class to be narrowed to CL if it is currently a superset of CL. ++ class to be narrowed to CL if it is currently a superset of CL and ++ if either: ++ ++ - ALLOW_ALL_RELOAD_CLASS_CHANGES_P is true or ++ - the instruction we're processing is not a reload move. + + If NEW_CLASS is nonnull, set *NEW_CLASS to the new allocno class of + REGNO (reg), or NO_REGS if no change in its class was needed. */ + static bool +-in_class_p (rtx reg, enum reg_class cl, enum reg_class *new_class) ++in_class_p (rtx reg, enum reg_class cl, enum reg_class *new_class, ++ bool allow_all_reload_class_changes_p = false) + { + enum reg_class rclass, common_class; + machine_mode reg_mode; +@@ -266,7 +271,8 @@ in_class_p (rtx reg, enum reg_class cl, enum reg_class *new_class) + typically moves that have many alternatives, and restricting + reload pseudos for one alternative may lead to situations + where other reload pseudos are no longer allocatable. */ +- || (INSN_UID (curr_insn) >= new_insn_uid_start ++ || (!allow_all_reload_class_changes_p ++ && INSN_UID (curr_insn) >= new_insn_uid_start + && curr_insn_set != NULL + && ((OBJECT_P (SET_SRC (curr_insn_set)) + && ! CONSTANT_P (SET_SRC (curr_insn_set))) +@@ -598,13 +604,12 @@ canonicalize_reload_addr (rtx addr) + return addr; + } + +-/* Create a new pseudo using MODE, RCLASS, ORIGINAL or reuse already +- created input reload pseudo (only if TYPE is not OP_OUT). Don't +- reuse pseudo if IN_SUBREG_P is true and the reused pseudo should be +- wrapped up in SUBREG. The result pseudo is returned through +- RESULT_REG. Return TRUE if we created a new pseudo, FALSE if we +- reused the already created input reload pseudo. Use TITLE to +- describe new registers for debug purposes. */ ++/* Create a new pseudo using MODE, RCLASS, ORIGINAL or reuse an existing ++ reload pseudo. Don't reuse an existing reload pseudo if IN_SUBREG_P ++ is true and the reused pseudo should be wrapped up in a SUBREG. ++ The result pseudo is returned through RESULT_REG. Return TRUE if we ++ created a new pseudo, FALSE if we reused an existing reload pseudo. ++ Use TITLE to describe new registers for debug purposes. */ + static bool + get_reload_reg (enum op_type type, machine_mode mode, rtx original, + enum reg_class rclass, bool in_subreg_p, +@@ -616,6 +621,35 @@ get_reload_reg (enum op_type type, machine_mode mode, rtx original, + + if (type == OP_OUT) + { ++ /* Output reload registers tend to start out with a conservative ++ choice of register class. Usually this is ALL_REGS, although ++ a target might narrow it (for performance reasons) through ++ targetm.preferred_reload_class. It's therefore quite common ++ for a reload instruction to require a more restrictive class ++ than the class that was originally assigned to the reload register. ++ ++ In these situations, it's more efficient to refine the choice ++ of register class rather than create a second reload register. ++ This also helps to avoid cycling for registers that are only ++ used by reload instructions. */ ++ if (REG_P (original) ++ && (int) REGNO (original) >= new_regno_start ++ && INSN_UID (curr_insn) >= new_insn_uid_start ++ && in_class_p (original, rclass, &new_class, true)) ++ { ++ unsigned int regno = REGNO (original); ++ if (lra_dump_file != NULL) ++ { ++ fprintf (lra_dump_file, " Reuse r%d for output ", regno); ++ dump_value_slim (lra_dump_file, original, 1); ++ } ++ if (new_class != lra_get_allocno_class (regno)) ++ lra_change_class (regno, new_class, ", change to", false); ++ if (lra_dump_file != NULL) ++ fprintf (lra_dump_file, "\n"); ++ *result_reg = original; ++ return false; ++ } + *result_reg + = lra_create_new_reg_with_unique_value (mode, original, rclass, title); + return true; +diff --git a/gcc/testsuite/gcc.c-torture/compile/pr96796.c b/gcc/testsuite/gcc.c-torture/compile/pr96796.c +new file mode 100644 +index 00000000000..8808e62fe77 +--- /dev/null ++++ b/gcc/testsuite/gcc.c-torture/compile/pr96796.c +@@ -0,0 +1,55 @@ ++/* { dg-additional-options "-fcommon" } */ ++ ++struct S0 { ++ signed f0 : 8; ++ unsigned f1; ++ unsigned f4; ++}; ++struct S1 { ++ long f3; ++ char f4; ++} g_3_4; ++ ++int g_5, func_1_l_32, func_50___trans_tmp_31; ++static struct S0 g_144, g_834, g_1255, g_1261; ++ ++int g_273[120] = {}; ++int *g_555; ++char **g_979; ++static int g_1092_0; ++static int g_1193; ++int safe_mul_func_int16_t_s_s(int si1, int si2) { return si1 * si2; } ++static struct S0 *func_50(); ++int func_1() { func_50(g_3_4, g_5, func_1_l_32, 8, 3); } ++void safe_div_func_int64_t_s_s(int *); ++void safe_mod_func_uint32_t_u_u(struct S0); ++struct S0 *func_50(int p_51, struct S0 p_52, struct S1 p_53, int p_54, ++ int p_55) { ++ int __trans_tmp_30; ++ char __trans_tmp_22; ++ short __trans_tmp_19; ++ long l_985_1; ++ long l_1191[8]; ++ safe_div_func_int64_t_s_s(g_273); ++ __builtin_printf((char*)g_1261.f4); ++ safe_mod_func_uint32_t_u_u(g_834); ++ g_144.f0 += 1; ++ for (;;) { ++ struct S1 l_1350 = {&l_1350}; ++ for (; p_53.f3; p_53.f3 -= 1) ++ for (; g_1193 <= 2; g_1193 += 1) { ++ __trans_tmp_19 = safe_mul_func_int16_t_s_s(l_1191[l_985_1 + p_53.f3], ++ p_55 % (**g_979 = 10)); ++ __trans_tmp_22 = g_1255.f1 * p_53.f4; ++ __trans_tmp_30 = __trans_tmp_19 + __trans_tmp_22; ++ if (__trans_tmp_30) ++ g_1261.f0 = p_51; ++ else { ++ g_1255.f0 = p_53.f3; ++ int *l_1422 = g_834.f0 = g_144.f4 != (*l_1422)++ > 0 < 0 ^ 51; ++ g_555 = ~0; ++ g_1092_0 |= func_50___trans_tmp_31; ++ } ++ } ++ } ++} +-- +2.18.4 + diff --git a/pkgs/development/compilers/gcc/patches/9/fix-struct-redefinition-on-glibc-2.36.patch b/pkgs/development/compilers/gcc/patches/9/fix-struct-redefinition-on-glibc-2.36.patch new file mode 100644 index 00000000000..5b4abfd02e0 --- /dev/null +++ b/pkgs/development/compilers/gcc/patches/9/fix-struct-redefinition-on-glibc-2.36.patch @@ -0,0 +1,31 @@ +Derived from ../11/fix-struct-redefinition-on-glibc-2.36.patch (upstream commit d2356ebb0084a0d80dbfe33040c9afe938c15d19) + +diff --git a/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cc b/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cc +index e8fce8a02..cb1ac806e 100644 +--- a/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cc ++++ b/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cc +@@ -65,7 +65,9 @@ + #include + #include + #include ++#if SANITIZER_ANDROID + #include ++#endif + #include + #include + #include +@@ -846,10 +848,10 @@ unsigned struct_ElfW_Phdr_sz = sizeof(Elf_Phdr); + unsigned IOCTL_EVIOCGPROP = IOCTL_NOT_PRESENT; + unsigned IOCTL_EVIOCSKEYCODE_V2 = IOCTL_NOT_PRESENT; + #endif +- unsigned IOCTL_FS_IOC_GETFLAGS = FS_IOC_GETFLAGS; +- unsigned IOCTL_FS_IOC_GETVERSION = FS_IOC_GETVERSION; +- unsigned IOCTL_FS_IOC_SETFLAGS = FS_IOC_SETFLAGS; +- unsigned IOCTL_FS_IOC_SETVERSION = FS_IOC_SETVERSION; ++ unsigned IOCTL_FS_IOC_GETFLAGS = _IOR('f', 1, long); ++ unsigned IOCTL_FS_IOC_GETVERSION = _IOR('v', 1, long); ++ unsigned IOCTL_FS_IOC_SETFLAGS = _IOW('f', 2, long); ++ unsigned IOCTL_FS_IOC_SETVERSION = _IOW('v', 2, long); + unsigned IOCTL_GIO_CMAP = GIO_CMAP; + unsigned IOCTL_GIO_FONT = GIO_FONT; + unsigned IOCTL_GIO_UNIMAP = GIO_UNIMAP; diff --git a/pkgs/development/compilers/gcc/patches/9/gcc9-asan-glibc-2.34.patch b/pkgs/development/compilers/gcc/patches/9/gcc9-asan-glibc-2.34.patch new file mode 100644 index 00000000000..1aea1f9b18a --- /dev/null +++ b/pkgs/development/compilers/gcc/patches/9/gcc9-asan-glibc-2.34.patch @@ -0,0 +1,70 @@ +From 3d0135bf3be416bbe2531dc763d19b749eb2b856 Mon Sep 17 00:00:00 2001 +From: Jakub Jelinek +Date: Sat, 17 Apr 2021 11:27:14 +0200 +Subject: [PATCH] sanitizer: Fix asan against glibc 2.34 [PR100114] + +As mentioned in the PR, SIGSTKSZ is no longer a compile time constant in +glibc 2.34 and later, so +static const uptr kAltStackSize = SIGSTKSZ * 4; +needs dynamic initialization, but is used by a function called indirectly +from .preinit_array and therefore before the variable is constructed. +This results in using 0 size instead and all asan instrumented programs +die with: +==91==ERROR: AddressSanitizer failed to allocate 0x0 (0) bytes of SetAlternateSignalStack (error code: 22) + +Here is a cherry-pick from upstream to fix this. + +2021-04-17 Jakub Jelinek + + PR sanitizer/100114 + * sanitizer_common/sanitizer_posix_libcdep.cc: Cherry-pick + llvm-project revisions 82150606fb11d28813ae6da1101f5bda638165fe + and b93629dd335ffee2fc4b9b619bf86c3f9e6b0023. + +(cherry picked from commit 950bac27d63c1c2ac3a6ed867692d6a13f21feb3) +--- + .../sanitizer_common/sanitizer_posix_libcdep.cc | 13 ++++++++----- + 1 file changed, 8 insertions(+), 5 deletions(-) + +diff --git a/libsanitizer/sanitizer_common/sanitizer_posix_libcdep.cc b/libsanitizer/sanitizer_common/sanitizer_posix_libcdep.cc +index d2fd76a6d36..1917e29ced2 100644 +--- a/libsanitizer/sanitizer_common/sanitizer_posix_libcdep.cc ++++ b/libsanitizer/sanitizer_common/sanitizer_posix_libcdep.cc +@@ -169,7 +169,11 @@ bool SupportsColoredOutput(fd_t fd) { + + #if !SANITIZER_GO + // TODO(glider): different tools may require different altstack size. +-static const uptr kAltStackSize = SIGSTKSZ * 4; // SIGSTKSZ is not enough. ++static uptr GetAltStackSize() { ++ // SIGSTKSZ is not enough. ++ static const uptr kAltStackSize = SIGSTKSZ * 4; ++ return kAltStackSize; ++} + + void SetAlternateSignalStack() { + stack_t altstack, oldstack; +@@ -180,10 +184,9 @@ void SetAlternateSignalStack() { + // TODO(glider): the mapped stack should have the MAP_STACK flag in the + // future. It is not required by man 2 sigaltstack now (they're using + // malloc()). +- void* base = MmapOrDie(kAltStackSize, __func__); +- altstack.ss_sp = (char*) base; ++ altstack.ss_size = GetAltStackSize(); ++ altstack.ss_sp = (char *)MmapOrDie(altstack.ss_size, __func__); + altstack.ss_flags = 0; +- altstack.ss_size = kAltStackSize; + CHECK_EQ(0, sigaltstack(&altstack, nullptr)); + } + +@@ -191,7 +194,7 @@ void UnsetAlternateSignalStack() { + stack_t altstack, oldstack; + altstack.ss_sp = nullptr; + altstack.ss_flags = SS_DISABLE; +- altstack.ss_size = kAltStackSize; // Some sane value required on Darwin. ++ altstack.ss_size = GetAltStackSize(); // Some sane value required on Darwin. + CHECK_EQ(0, sigaltstack(&altstack, &oldstack)); + UnmapOrDie(oldstack.ss_sp, oldstack.ss_size); + } +-- +2.27.0 + diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 6fbd0bd7387..aef17d92771 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -15805,6 +15805,7 @@ with pkgs; "12" = "12.3.0"; "11" = "11.4.0"; "10" = "10.4.0"; + "9" = "9.5.0"; }; deduplicated = deduplicatedVersions ? "${version}"; path = if deduplicated -- cgit 1.4.1