* ERROR: dev-lang/gnat-gpl-2018-r2::gentoo failed (compile phase): * emake failed * * If you need support, post the output of `emerge --info '=dev-lang/gnat-gpl-2018-r2::gentoo'`, * the complete build log and the output of `emerge -pqv '=dev-lang/gnat-gpl-2018-r2::gentoo'`. * The complete build log is located at '/var/tmp/portage/dev-lang/gnat-gpl-2018-r2/temp/build.log'. * The ebuild environment file is located at '/var/tmp/portage/dev-lang/gnat-gpl-2018-r2/temp/environment'. * Working directory: '/var/tmp/portage/dev-lang/gnat-gpl-2018-r2/work/build' * S: '/var/tmp/portage/dev-lang/gnat-gpl-2018-r2/work/gcc-7-gpl-2018-src' * * Please include /var/tmp/portage/dev-lang/gnat-gpl-2018-r2/work/gcc-build-logs.tar.bz2 in your bug report. * Reproducible: Always
Created attachment 580608 [details] emerge --info '=dev-lang/gnat-gpl-2018-r2::gentoo'
Created attachment 580610 [details] emerge -pqv '=dev-lang/gnat-gpl-2018-r2::gentoo'
Created attachment 580612 [details] /var/tmp/portage/dev-lang/gnat-gpl-2018-r2/temp/build.log.lzma
Created attachment 580614 [details] /var/tmp/portage/dev-lang/gnat-gpl-2018-r2/work/gcc-build-logs.tar.bz2
Logging here tupone@'s findings (and a tiny bit of mine): Looks like the chief trigger here is -mstackrealign in CFLAGS. I manager to reproduce the crash with: CFLAGS="-O1 -g -mstackrealign" # crashes CXXFLAGS="${CFLAGS}" CFLAGS="-O1 -g" # works CXXFLAGS="${CFLAGS}" It SIGSEGVs in libgcc_s.so.1: Program received signal SIGSEGV, Segmentation fault. _Unwind_GetGR (index=<optimized out>, context=<optimized out>) at /dev/shm/portage/sys-devel/gcc-7.3.0-r6/work/gcc-7.3.0/libgcc/unwind-dw2.c:242 242 /dev/shm/portage/sys-devel/gcc-7.3.0-r6/work/gcc-7.3.0/libgcc/unwind-dw2.c: Нет такого файла или каталога. (gdb) bt #0 _Unwind_GetGR (index=<optimized out>, context=<optimized out>) at /dev/shm/portage/sys-devel/gcc-7.3.0-r6/work/gcc-7.3.0/libgcc/unwind-dw2.c:242 #1 execute_stack_op (op_ptr=0x7ffff7fad51a "\003\016\002\n\f\n", op_end=0x7ffff7fad51a "\003\016\002\n\f\n", context=context@entry=0x7fffffffd920, initial=initial@entry=140737488347120) at /dev/shm/portage/sys-devel/gcc-7.3.0-r6/work/gcc-7.3.0/libgcc/unwind-dw2.c:696 #2 0x00007ffff7fa689d in uw_update_context_1 (context=context@entry=0x7fffffffdc40, fs=fs@entry=0x7fffffffda70) at /dev/shm/portage/sys-devel/gcc-7.3.0-r6/work/gcc-7.3.0/libgcc/unwind-dw2.c:1469 #3 0x00007ffff7fa6b88 in uw_init_context_1 (context=context@entry=0x7fffffffdc40, outer_cfa=outer_cfa@entry=0x7fffffffdff0, outer_ra=0x4035cb <ada.exceptions.exception_propagation.propagate_gcc_exception+9>) at /dev/shm/portage/sys-devel/gcc-7.3.0-r6/work/gcc-7.3.0/libgcc/unwind-dw2.c:1599 #4 0x00007ffff7fa700d in _Unwind_RaiseException (exc=0x432260) at /dev/shm/portage/sys-devel/gcc-7.3.0-r6/work/gcc-7.3.0/libgcc/unwind.inc:88 #5 0x00000000004035cb in ada.exceptions.exception_propagation.propagate_gcc_exception () #6 0x0000000000403603 in ada.exceptions.exception_propagation.propagate_exception () #7 0x00000000004040fd in ada.exceptions.complete_and_propagate_occurrence () #8 0x0000000000404148 in __gnat_raise_exception () #9 0x0000000000402ab0 in main () at main.adb:2 Probably _Unwind_RaiseException was broken by -mstackrealign in a way that dwarf info does not match stack frame layout. I'll try to make sense out of it.
Meanwhile I suspect the simplest thing for you would be to drop -mstackrealign. It should not be needed for software that was built by modern gcc.
The bug has been referenced in the following commit(s): https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=5277d012d4d21640d82ba9c82748d8b63523804c commit 5277d012d4d21640d82ba9c82748d8b63523804c Author: Sergei Trofimovich <slyfox@gentoo.org> AuthorDate: 2019-10-26 16:33:17 +0000 Commit: Sergei Trofimovich <slyfox@gentoo.org> CommitDate: 2019-10-26 16:36:09 +0000 toolchain.eclass: filter out -mstackrealign, bug #688580 -mstackrealign breaks stack unwinding via _Unwind_RaiseException in libgcc_s.so.1. Not clear why exactly. Probably by breaking unwinding information during realignment. The change works it around by dropping -mstackrealign when building gcc. Reported-by: Erik Bug: https://bugs.gentoo.org/688580 Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org> eclass/toolchain.eclass | 7 +++++++ 1 file changed, 7 insertions(+)
I've bisected gcc behaviour change down to https://gcc.gnu.org/PR81313: commit 84066338f533756496dc8ce09726fe8dad8b0cf5 Author: hjl <hjl@138bc75d-0d04-0410-961f-82ee72b054a4> Date: Sun Jul 9 18:25:49 2017 +0000 x86: Use DRAP only if there are outgoing arguments on stack Since DRAP is needed only if there are outgoing arguments on stack, we should track outgoing arguments on stack and avoid setting need_drap to true when there are no outgoing arguments on stack. gcc/ PR target/81313 * config/i386/i386.c (ix86_function_arg_advance): Set outgoing_args_on_stack to true if there are outgoing arguments on stack. (ix86_function_arg): Likewise. (ix86_get_drap_rtx): Use DRAP only if there are outgoing arguments on stack and ACCUMULATE_OUTGOING_ARGS is false. * config/i386/i386.h (machine_function): Add outgoing_args_on_stack. gcc/testsuite/ PR target/81313 * gcc.target/i386/pr81313-1.c: New test. * gcc.target/i386/pr81313-2.c: Likewise. * gcc.target/i386/pr81313-3.c: Likewise. * gcc.target/i386/pr81313-4.c: Likewise. * gcc.target/i386/pr81313-5.c: Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@250084 138bc75d-0d04-0410-961f-82ee72b054a4 gcc/ChangeLog | 12 ++++++++++++ gcc/config/i386/i386.c | 18 ++++++++++++++++-- gcc/config/i386/i386.h | 3 +++ gcc/testsuite/ChangeLog | 9 +++++++++ gcc/testsuite/gcc.target/i386/pr81313-1.c | 12 ++++++++++++ gcc/testsuite/gcc.target/i386/pr81313-2.c | 12 ++++++++++++ gcc/testsuite/gcc.target/i386/pr81313-3.c | 12 ++++++++++++ gcc/testsuite/gcc.target/i386/pr81313-4.c | 12 ++++++++++++ gcc/testsuite/gcc.target/i386/pr81313-5.c | 12 ++++++++++++ 9 files changed, 100 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/gcc.target/i386/pr81313-1.c create mode 100644 gcc/testsuite/gcc.target/i386/pr81313-2.c create mode 100644 gcc/testsuite/gcc.target/i386/pr81313-3.c create mode 100644 gcc/testsuite/gcc.target/i386/pr81313-4.c create mode 100644 gcc/testsuite/gcc.target/i386/pr81313-5.c It does not look like a real fix as it avoids injecting stack realignment into simple functions.
Fun fact: -mforce-drap (stronger variant of -mstackrealign option) does not cause gcc-7.3.0 or master to crash.
Instead of -mstackrealign the following is enough to make sample crash on gcc-7.3.0: diff --git a/libgcc/unwind.inc b/libgcc/unwind.inc index 658bd94f8f3..616c6a8a293 100644 --- a/libgcc/unwind.inc +++ b/libgcc/unwind.inc @@ -78,7 +78,7 @@ _Unwind_RaiseException_Phase2(struct _Unwind_Exception *exc, /* Raise an exception, passing along the given exception object. */ -_Unwind_Reason_Code LIBGCC2_UNWIND_ATTRIBUTE +_Unwind_Reason_Code LIBGCC2_UNWIND_ATTRIBUTE __attribute__((force_align_arg_pointer)) _Unwind_RaiseException(struct _Unwind_Exception *exc) { struct _Unwind_Context this_context, cur_context;
(In reply to Sergei Trofimovich from comment #10) > Instead of -mstackrealign the following is enough to make sample crash on > gcc-7.3.0: > > diff --git a/libgcc/unwind.inc b/libgcc/unwind.inc > index 658bd94f8f3..616c6a8a293 100644 > --- a/libgcc/unwind.inc > +++ b/libgcc/unwind.inc > @@ -78,7 +78,7 @@ _Unwind_RaiseException_Phase2(struct _Unwind_Exception > *exc, > > /* Raise an exception, passing along the given exception object. */ > > -_Unwind_Reason_Code LIBGCC2_UNWIND_ATTRIBUTE > +_Unwind_Reason_Code LIBGCC2_UNWIND_ATTRIBUTE > __attribute__((force_align_arg_pointer)) > _Unwind_RaiseException(struct _Unwind_Exception *exc) > { > struct _Unwind_Context this_context, cur_context; Bisected the behaviour change down to https://gcc.gnu.org/PR81313 as well. OK, let's assume it was fixed.