https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80556
simon at pushface dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Attachment #41474|0 |1
is obsolete| |
--- Comment #39 from simon at pushface dot org ---
Created attachment 41520
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=41520&action=edit
Patch (2) to top-level configure.ac, configure
The notes on -shared-libgcc at
https://gcc.gnu.org/onlinedocs/gcc/Link-Options.html say
However, if a library or main executable is supposed to throw or
catch exceptions, you must link it using the G++ driver, as
appropriate for the languages used in the program, or using the
option -shared-libgcc, such that it is linked with the shared
libgcc.
This seems not to be true for Linux (Debian Jessie) but is definitely
true for Darwin. If, using GCC 7.1.0, we build
with Ada.Text_IO; use Ada.Text_IO;
procedure Raiser is
begin
begin
raise Program_Error;
exception
when others =>
Put_Line ("caught it");
end;
end Raiser;
with
$ gnatmake raiser -largs -static-libgcc -static-libstdc++
then
$ ./raiser
Illegal instruction: 4
The actual ld invocation was
/usr/bin/ld -dynamic -arch x86_64 -macosx_version_min 10.12.0
-weak_reference_mismatches non-weak -o raiser -L./
-L/opt/gcc-7.1.0/lib/gcc/x86_64-apple-darwin15/7.1.0/adalib/
-L/opt/gcc-7.1.0/lib/gcc/x86_64-apple-darwin15/7.1.0
-L/opt/gcc-7.1.0/lib/gcc/x86_64-apple-darwin15/7.1.0/../../.. b~raiser.o
./raiser.o -v
/opt/gcc-7.1.0/lib/gcc/x86_64-apple-darwin15/7.1.0/adalib/libgnat.a
-no_compact_unwind -lgcc_eh -lgcc -lSystem
This PR was raised because of a mishandled exception raised by
Rtsfind.Load_Fail while processing g-exptty.adb. g-exptty.adb had been
updated on 2017-04-25 (but so had a lot of other parts of GNAT). Since
a lot of other compilations had been performed successfully by this
point, one may assume that this was the first that actually caused an
exception.
Comment 14 works because --with-boot-ldflags=-static-libstdc++ means
that the default boot-ldflags (-static-libgcc -static-libstdc++) is
overridden, so that libgcc defaults to being shared (and
-static-libstdc++ is ignored, as per comment 25, resulting in the
stage 2 problems in comment 5, comment 24).
Following the suggestion on comment 22 (put -lSystem before -lgcc),
I've tried gcc-8-20170528 with
--with-stage1-ldflags='-lSystem -static-libgcc -static-libstdc++'
--with-boot-ldflags='-lSystem -static-libgcc -static-libstdc++'
AND IT WORKS!!!! (on macOS Sierra, Debian jessie).
Changing the command line above to the equivalent
$ gnatmake raiser -largs -lSystem -static-libgcc -static-libstdc++
results in the ld invocation
/usr/bin/ld -dynamic -arch x86_64 -macosx_version_min 10.12.0
-weak_reference_mismatches non-weak -o raiser -L./
-L/opt/gcc-7.1.0/lib/gcc/x86_64-apple-darwin15/7.1.0/adalib/
-L/opt/gcc-7.1.0/lib/gcc/x86_64-apple-darwin15/7.1.0
-L/opt/gcc-7.1.0/lib/gcc/x86_64-apple-darwin15/7.1.0/../../.. b~raiser.o
./raiser.o -lSystem -v
/opt/gcc-7.1.0/lib/gcc/x86_64-apple-darwin15/7.1.0/adalib/libgnat.a
-no_compact_unwind -lgcc_eh -lgcc -lSystem
and
$ ./raiser
caught it
Updated patch posted here; working on gcc-patches@ submission.
========================================================================
I'd like to point out that even if gnat1 hadn't failed, building GNAT
tools without shared libgcc results in failures as in PR61027; but
they only affect users of the tools, not the bootstrap.