On 05/12/2016 09:27 AM, Sandra Loosemore wrote:
I see that the default EH behavior for a biarch mingw-w64 target GCC is
to use SJLJ for the 32-bit multilib and SEH for the 64-bit one, but that
there are #errors in cygming.h and mingw32.h that prevent you from
configuring a biarch build with --disable-sjlj-exceptions to use DWARF-2
and SEH, respectively. Is there a deep reason for this, or is this just
a case where nobody updated the configuration logic after SEH was
implemented? I understand that before that, you had to use SJLJ for
64-bit targets because the DWARF-2 support is restricted to 32-bit
targets, so it was completely reasonable to error out.
Following up my own post....
I did some experimentation, and it looks like this is indeed just a
result of bit-rotten configuration logic. I hacked up the attached
patch against our local GCC 5.2 branch and built and tested it as a
cross-compiler (C and C++ front ends only). Test results for the
--disable-sjlj-exceptions case have a few differences compared to
--enable-sjlj-exceptions but they're not particularly better or worse.
Maintainers, any guidance on getting this into trunk? E.g. I am not
particularly interested in Cygwin target and have not tried to build
that, but this affects code common to both Cygwin and Mingw-w64.
-Sandra
2016-05-13 Sandra Loosemore <san...@codesourcery.com>
gcc/
* config/i386/cygming.h (DWARF2_UNWIND_INFO): Allow
--disable-sjlj-exceptions for TARGET_BI_ARCH to select DWARF-2 EH
for 32-bit mode and SEH for 64-bit.
* config/i386/mingw32.h (SHARED_LIBGCC_UNDEFS_SPEC): Handle
TARGET_64BIT_DEFAULT.
libgcc/
* config.host [x86_64-*-cygwin*]: Handle tmake_eh_file for mixed
dw2/seh configuration.
[x86_64-*-mingw*]: Likewise.
Index: gcc/config/i386/cygming.h
===================================================================
--- gcc/config/i386/cygming.h (revision 464590)
+++ gcc/config/i386/cygming.h (working copy)
@@ -347,16 +347,13 @@ do { \
#define ASM_COMMENT_START " #"
#ifndef DWARF2_UNWIND_INFO
-/* If configured with --disable-sjlj-exceptions, use DWARF2, else
- default to SJLJ. */
+/* If configured with --disable-sjlj-exceptions, use DWARF2 for 32-bit
+ mode else default to SJLJ. 64-bit code uses SEH unless you request
+ SJLJ. */
#if (defined (CONFIG_SJLJ_EXCEPTIONS) && !CONFIG_SJLJ_EXCEPTIONS)
/* The logic of this #if must be kept synchronised with the logic
- for selecting the tmake_eh_file fragment in config.gcc. */
+ for selecting the tmake_eh_file fragment in libgcc/config.host. */
#define DWARF2_UNWIND_INFO 1
-/* If multilib is selected break build as sjlj is required. */
-#if defined (TARGET_BI_ARCH)
-#error For 64-bit windows and 32-bit based multilib version of gcc just SJLJ exceptions are supported.
-#endif
#else
#define DWARF2_UNWIND_INFO 0
#endif
Index: gcc/config/i386/mingw32.h
===================================================================
--- gcc/config/i386/mingw32.h (revision 464590)
+++ gcc/config/i386/mingw32.h (working copy)
@@ -100,10 +100,12 @@ along with GCC; see the file COPYING3.
#if DWARF2_UNWIND_INFO
/* DW2-unwind is just available for 32-bit mode. */
#if TARGET_64BIT_DEFAULT
-#error DW2 unwind is not available for 64-bit.
-#endif
+#define SHARED_LIBGCC_UNDEFS_SPEC \
+ "%{m32: %{shared-libgcc: -u ___register_frame_info -u ___deregister_frame_info}}"
+#else
#define SHARED_LIBGCC_UNDEFS_SPEC \
"%{shared-libgcc: -u ___register_frame_info -u ___deregister_frame_info}"
+#endif
#else
#define SHARED_LIBGCC_UNDEFS_SPEC ""
#endif
Index: libgcc/config.host
===================================================================
--- libgcc/config.host (revision 464590)
+++ libgcc/config.host (working copy)
@@ -661,6 +661,10 @@ x86_64-*-cygwin*)
# This has to match the logic for DWARF2_UNWIND_INFO in gcc/config/i386/cygming.h
if test x$enable_sjlj_exceptions = xyes; then
tmake_eh_file="i386/t-sjlj-eh"
+ elif test "${libgcc_cv_lib_sjlj_exceptions}" = no \
+ && test "${host_address}" = 32; then
+ # biarch -m32 with --disable-sjlj-exceptions
+ tmake_eh_file="i386/t-dw2-eh"
else
tmake_eh_file="i386/t-seh-eh"
fi
@@ -713,6 +717,10 @@ x86_64-*-mingw*)
# This has to match the logic for DWARF2_UNWIND_INFO in gcc/config/i386/cygming.h
if test x$enable_sjlj_exceptions = xyes; then
tmake_eh_file="i386/t-sjlj-eh"
+ elif test "${libgcc_cv_lib_sjlj_exceptions}" = no \
+ && test "${host_address}" = 32; then
+ # biarch -m32 with --disable-sjlj-exceptions
+ tmake_eh_file="i386/t-dw2-eh"
else
tmake_eh_file="i386/t-seh-eh"
fi