[Bug ada/105507] Ada build fails for 32bit Windows

2022-05-22 Thread reiter.christoph at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105507

Christoph Reiter  changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution|--- |INVALID

--- Comment #11 from Christoph Reiter  ---
I went with --with-boot-ldflags="-static-libstdc++" and
--with-stage1-ldflags="-static-libstdc++" now, and everything works nicely.

Thanks for your help and insight.

I'll document the dwarf-2 limitation downstream, so this hopefully wont happen
again.

[Bug ada/105507] Ada build fails for 32bit Windows

2022-05-19 Thread ebotcazou at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105507

--- Comment #10 from Eric Botcazou  ---
> I'm wondering if there are any downsides to just removing "-static-libgcc"
> from both "--with-stage1-ldflags" and "--with-boot-ldflags".

None presumably, since you already have dependencies on DLLs.

> Or is only ada using exceptions in GCC?

Yes, they are prohibited in the C++ codebase for the time being.

> Or should we try linking everything statically to avoid this alltogether?

It's your call, either should work equally well.

[Bug ada/105507] Ada build fails for 32bit Windows

2022-05-19 Thread reiter.christoph at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105507

--- Comment #9 from Christoph Reiter  ---
(In reply to Eric Botcazou from comment #8)
> > We currently link:
> > 
> > shared: gmp, winpthread, zlib, zstd
> > static: mpc, mpfr, isl
> > 
> > Not for any particular gcc related reason I think, some dependent packages
> > have static/shared builds, some don't.
> 
> Why didn't I think of that for PR ada/100486?

Sorry, I didn't know this was a problem :) I'm not quite sure how I ended up
maintaining this downstream... but here we are.

> So the fix should have been
> to add -shared-libgcc to GCC_LINKERFLAGS in
> gcc/ada/gcc-interface/Make-lang.in:
> 
> # Strip -Werror during linking for the LTO bootstrap
> GCC_LINKERFLAGS = $(filter-out -Werror, $(ALL_LINKERFLAGS)) -shared-libgcc
> 
> in your setup since you link gnat1 with shared libraries. This should
> override the -static-libgcc in ALL_LINKERFLAGS inherited from toplevel.
> 
> So you need to to it 1) for GCC 11: rebuild it and reinstall it 2) for GCC
> 12: build it with the patched GCC 11.  Note that this means that GCC 11 is
> currently not fully functional anyway.

Thanks for the detailed instructions. I'll give that a try.

I'm wondering if there are any downsides to just removing "-static-libgcc" from
both "--with-stage1-ldflags" and "--with-boot-ldflags". Or is only ada using
exceptions in GCC?

Or should we try linking everything statically to avoid this alltogether?

[Bug ada/105507] Ada build fails for 32bit Windows

2022-05-19 Thread ebotcazou at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105507

--- Comment #8 from Eric Botcazou  ---
> We currently link:
> 
> shared: gmp, winpthread, zlib, zstd
> static: mpc, mpfr, isl
> 
> Not for any particular gcc related reason I think, some dependent packages
> have static/shared builds, some don't.

Why didn't I think of that for PR ada/100486?  So the fix should have been to
add -shared-libgcc to GCC_LINKERFLAGS in gcc/ada/gcc-interface/Make-lang.in:

# Strip -Werror during linking for the LTO bootstrap
GCC_LINKERFLAGS = $(filter-out -Werror, $(ALL_LINKERFLAGS)) -shared-libgcc

in your setup since you link gnat1 with shared libraries. This should override
the -static-libgcc in ALL_LINKERFLAGS inherited from toplevel.

So you need to to it 1) for GCC 11: rebuild it and reinstall it 2) for GCC 12:
build it with the patched GCC 11.  Note that this means that GCC 11 is
currently not fully functional anyway.

[Bug ada/105507] Ada build fails for 32bit Windows

2022-05-19 Thread reiter.christoph at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105507

--- Comment #7 from Christoph Reiter  ---
We currently link:

shared: gmp, winpthread, zlib, zstd
static: mpc, mpfr, isl

Not for any particular gcc related reason I think, some dependent packages have
static/shared builds, some don't.

[Bug ada/105507] Ada build fails for 32bit Windows

2022-05-18 Thread ebotcazou at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105507

--- Comment #6 from Eric Botcazou  ---
> So the rule of thumb is to never use -static-libgcc if you have a
> GCC-compiled DLL in the link, that's guaranteed to break otherwise.

So this could happen to the compiler if it is linked with the shared version of
GMP, MPFR or MPC.  Is that the case in your setup?

[Bug ada/105507] Ada build fails for 32bit Windows

2022-05-18 Thread ebotcazou at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105507

--- Comment #5 from Eric Botcazou  ---
> We do have some open bugs re broken exception handling with mingw32, like
> https://github.com/msys2/MINGW-packages/issues/9289#issuecomment-945306860
> 
> Sadly no one stepped up to look into that. Do you think this could be
> related?

Possible, but the above report clearly points to pitfall #1 with DWARF
unwinding: you may *not* have more than a single libgcc in a link.  This means
that, if you link with a DLL that was linked with the (shared, that's
requuired) libgcc, you *cannot* also link with the static libgcc, because this
brings 2 libgccs in the link, you *must* link with the shared libgcc.

So the rule of thumb is to never use -static-libgcc if you have a GCC-compiled
DLL in the link, that's guaranteed to break otherwise.

[Bug ada/105507] Ada build fails for 32bit Windows

2022-05-18 Thread reiter.christoph at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105507

--- Comment #4 from Christoph Reiter  ---
I see, thanks for having a look :)

We do have some open bugs re broken exception handling with mingw32, like
https://github.com/msys2/MINGW-packages/issues/9289#issuecomment-945306860

Sadly no one stepped up to look into that. Do you think this could be related?

[Bug ada/105507] Ada build fails for 32bit Windows

2022-05-18 Thread ebotcazou at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105507

Eric Botcazou  changed:

   What|Removed |Added

 Depends on||100486
   Last reconfirmed||2022-05-18
 Ever confirmed|0   |1
 Status|UNCONFIRMED |NEW

--- Comment #3 from Eric Botcazou  ---
It's an issue in the base compiler though, not in GCC 12.x, probably the same
as the one reported under PR ada/100486: exception propagation in the compiler
does not work in your setup for some reason.


Referenced Bugs:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100486
[Bug 100486] Ada build fails for 32bit Windows

[Bug ada/105507] Ada build fails for 32bit Windows

2022-05-18 Thread reiter.christoph at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105507

--- Comment #2 from Christoph Reiter  ---
Stack trace (I rebuilt the host gcc 11.3.0 with debug symbols and re-ran the
failing command with "-wrapper gdb,--args"):

Thread 1 received signal SIGSEGV, Segmentation fault.
0x7563bd90 in strlen () from C:\WINDOWS\SysWOW64\msvcrt.dll
(gdb) bt
#0  0x7563bd90 in strlen () from C:\WINDOWS\SysWOW64\msvcrt.dll
#1  0x01731831 in libiberty_vprintf_buffer_size (
format=format@entry=0x1a3f865  "%s:%d",
args=, args@entry=0x1367df64 "")
at ../../gcc-11.3.0/libiberty/vprintf-support.c:105
#2  0x0173160a in xvasprintf (
format=format@entry=0x1a3f865  "%s:%d",
args=args@entry=0x1367df64 "")
at ../../gcc-11.3.0/libiberty/xvasprintf.c:57
#3  0x017312f7 in xasprintf (
fmt=0x1a3f865  "%s:%d")
at ../../gcc-11.3.0/libiberty/xasprintf.c:47
#4  0x0041f315 in internal_error_function (
context=0x29d40c0 ,
msgid=0x1b2aebd  "%s", ap=0x1367e0a0)
at ../../gcc-11.3.0/gcc/ada/gcc-interface/misc.c:343
#5  0x016ab28d in diagnostic_report_diagnostic (
context=0x29d40c0 ,
diagnostic=, diagnostic@entry=0x1367e048)
at ../../gcc-11.3.0/gcc/diagnostic.c:1225
#6  0x016ab7b7 in diagnostic_impl (richloc=0x1367e0a4, metadata=0x0, opt=-1,
gmsgid=0x1b2aebd  "%s", ap=0x1367e0a0,
kind=DK_ICE) at ../../gcc-11.3.0/gcc/diagnostic.c:1406
#7  0x016abd98 in internal_error (
gmsgid=gmsgid@entry=0x1b2aebd  "%s")
at ../../gcc-11.3.0/gcc/diagnostic.c:1808
#8  0x00c53db1 in crash_signal (signo=22) at ../../gcc-11.3.0/gcc/toplev.c:327
#9  0x75608081 in raise () from C:\WINDOWS\SysWOW64\msvcrt.dll
#10 0x0016 in ?? ()
#11 0x4925a812 in ?? ()
#12 0x1367e7b0 in ?? ()
#13 0x7560c5ab in msvcrt!abort () from C:\WINDOWS\SysWOW64\msvcrt.dll
#14 0x0192e3d3 in uw_init_context_1 (context=0x0, context@entry=0x1367e730,
outer_cfa=outer_cfa@entry=0x1367e7d0, outer_ra=0x16)
at ../../../gcc-11.3.0/libgcc/unwind-dw2.c:1593
#15 0x0192e77f in _Unwind_RaiseException (exc=0x1619f880)
at ../../../gcc-11.3.0/libgcc/unwind.inc:93
#16 0x00473f47 in ada.exceptions.exception_propagation.propagate_gcc_exception
(gcc_exception=0x1619f880)
at ../../gcc-11.3.0/gcc/ada/libgnat/a-exexpr.adb:597
#17 0x00473f96 in ada.exceptions.exception_propagation.propagate_exception (
excep=...) at ../../gcc-11.3.0/gcc/ada/libgnat/a-exexpr.adb:628
#18 0x00474414 in ada.exceptions.complete_and_propagate_occurrence (
x=x@entry=0x1619f8b0) at ../../gcc-11.3.0/gcc/ada/libgnat/a-except.adb:924
#19 0x00474447 in <__gnat_raise_exception> (
e=e@entry=0x1a31698 ,
message=...) at ../../gcc-11.3.0/gcc/ada/libgnat/a-except.adb:960
#20 0x0068e352 in sem_ch13.build_discrete_static_predicate.stat_pred (
typ=32975) at ../../gcc-11.3.0/gcc/ada/sem_ch13.adb:9368
#21 0x0068fa75 in sem_ch13.build_discrete_static_predicate.get_rlist (
exp=) at ../../gcc-11.3.0/gcc/ada/sem_ch13.adb:9129
#22 0x0068f922 in sem_ch13.build_discrete_static_predicate.get_rlist (
exp=203158) at ../../gcc-11.3.0/gcc/ada/sem_ch13.adb:9015
#23 0x00693b59 in sem_ch13.build_discrete_static_predicate (typ=33050,
expr=203158, nam=-399989278) at ../../gcc-11.3.0/gcc/ada/sem_ch13.adb:9409
#24 0x00696f66 in sem_ch13.build_predicate_functions (typ=typ@entry=33050,
n=n@entry=203112) at ../../gcc-11.3.0/gcc/ada/sem_ch13.adb:10370
#25 0x006a59b2 in sem_ch13.freeze_entity_checks (n=203112)
at ../../gcc-11.3.0/gcc/ada/sem_ch13.adb:12728
#26 0x006a5ab5 in sem_ch13.analyze_freeze_entity (n=n@entry=203112)
at ../../gcc-11.3.0/gcc/ada/sem_ch13.adb:8155
#27 0x0064416a in sem.analyze (n=n@entry=203112)
at ../../gcc-11.3.0/gcc/ada/sem.adb:264
#28 0x00644d68 in sem.insert_list_after_and_analyze (n=203068, l=-99976824)
at ../../gcc-11.3.0/gcc/ada/sem.adb:1254
#29 0x005b490f in freeze.freeze_all.freeze_all_ent.process_flist ()
at ../../gcc-11.3.0/gcc/ada/freeze.adb:1852
#30 0x005bf0f5 in freeze.freeze_all.freeze_all_ent (after=36978, from=32525)
at ../../gcc-11.3.0/gcc/ada/freeze.adb:1940
#31 freeze.freeze_all (from=32525, after=36978)
at ../../gcc-11.3.0/gcc/ada/freeze.adb:2020
#32 0x006ad855 in sem_ch3.analyze_declarations (l=,
l@entry=-6744) at ../../gcc-11.3.0/gcc/ada/sem_ch3.adb:2837
#33 0x006fa1d7 in sem_ch7.analyze_package_specification (n=n@entry=32524)
at ../../gcc-11.3.0/gcc/ada/sem_ch7.adb:1738
#34 0x006442f7 in sem.analyze (n=32524)
at ../../gcc-11.3.0/gcc/ada/sem.adb:459
#35 0x006f978c in sem_ch7.analyze_package_declaration (n=n@entry=37004)
at ../../gcc-11.3.0/gcc/ada/sem_ch7.adb:1210
#36 0x00643e5e in sem.analyze (n=n@entry=37004)
at ../../gcc-11.3.0/gcc/ada/sem.adb:450
#37 0x0066c17a in sem_ch10.analyze_compilation_unit (n=32501)
at ../../gcc-11.3.0/gcc/ada/sem_ch10.adb:913
#38 0x00644102 in sem.analyze (n=n@entry=32501)
at ../../gcc-11.3.0/gcc/ada/sem.adb:180
#39 0x006454b1 in sem.semantics.do_analyze ()
at ../../gcc-11.3.0/gcc/ada/sem.adb:1421
#40 sem.semantics (comp_unit=32501) 

[Bug ada/105507] Ada build fails for 32bit Windows

2022-05-17 Thread reiter.christoph at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105507

--- Comment #1 from Christoph Reiter  ---
I've bisected it now:

https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=76f9c7f44fffb0b03266730b137313fe79f1c99e

76f9c7f44fffb0b03266730b137313fe79f1c99e is the first bad commit
commit 76f9c7f44fffb0b03266730b137313fe79f1c99e
Author: Bob Duff 
Date:   Wed Feb 3 05:31:16 2021 -0500

[Ada] Variable-sized node types

 167 files changed, 18305 insertions(+), 43812 deletions(-)