diff mbox

Allow configuration with --disable-sjlj-exceptions on biarch x86 Windows targets

Message ID 573DF982.8010405@codesourcery.com
State New
Headers show

Commit Message

Sandra Loosemore May 19, 2016, 5:36 p.m. UTC
This is a slightly revised version of the WIP patch against GCC 5.1 I 
previously posted here:

https://gcc.gnu.org/ml/gcc/2016-05/msg00135.html

To recap, I needed a biarch x86_64 mingw-w64 target compiler that uses 
DWARF-2 exception handling in 32-bit mode (for compatibility with an 
older i686-mingw32 toolchain configured with --disable-sjlj-exceptions). 
  But, the configuration machinery was rejecting this.  It used to be 
that SJLJ exceptions were the only choice for 64-bit mode so it was 
correct to reject --disable-sjlj-exceptions in a biarch toolchain, but 
now the default for 64-bit mode is SEH instead.  With this patch, 
configuring with --disable-sjlj-exceptions selects DWARF-2 EH in 32-bit 
mode and SEH in 64-bit mode.

I tested this in a cross-compiler configured to build C and C++ only for 
x86_64 mingw-w64 target, and test results look about the same as the 
default configuration, which uses SJLJ for 32-bit mode.  (If it's 
relevant, I also used the compiler built with the 5.1 version of the 
patch to build complete Windows-host toolchains for nios2-elf and 
nios2-linux-gnu, which I tested by running the GDB testsuite.)  There 
are no actual code changes here so I'd expect the 32-bit DWARF-2 EH 
support to work exactly the same as in a 32-bit-only x86 configuration.

OK to commit?

-Sandra

Comments

Jeff Law May 19, 2016, 6:05 p.m. UTC | #1
On 05/19/2016 11:36 AM, Sandra Loosemore wrote:
> This is a slightly revised version of the WIP patch against GCC 5.1 I
> previously posted here:
>
> https://gcc.gnu.org/ml/gcc/2016-05/msg00135.html
>
> To recap, I needed a biarch x86_64 mingw-w64 target compiler that uses
> DWARF-2 exception handling in 32-bit mode (for compatibility with an
> older i686-mingw32 toolchain configured with --disable-sjlj-exceptions).
>  But, the configuration machinery was rejecting this.  It used to be
> that SJLJ exceptions were the only choice for 64-bit mode so it was
> correct to reject --disable-sjlj-exceptions in a biarch toolchain, but
> now the default for 64-bit mode is SEH instead.  With this patch,
> configuring with --disable-sjlj-exceptions selects DWARF-2 EH in 32-bit
> mode and SEH in 64-bit mode.
>
> I tested this in a cross-compiler configured to build C and C++ only for
> x86_64 mingw-w64 target, and test results look about the same as the
> default configuration, which uses SJLJ for 32-bit mode.  (If it's
> relevant, I also used the compiler built with the 5.1 version of the
> patch to build complete Windows-host toolchains for nios2-elf and
> nios2-linux-gnu, which I tested by running the GDB testsuite.)  There
> are no actual code changes here so I'd expect the 32-bit DWARF-2 EH
> support to work exactly the same as in a 32-bit-only x86 configuration.
>
> OK to commit?
OK.

Thanks,
Jeff
Kai Tietz May 19, 2016, 6:40 p.m. UTC | #2
Hi,

hopefully this time gmail uses  mail-encoding elmz ask for ...

Sorry to object here.  I would like to point out that defaulting to
dw2 on 32-bit if SEH is used for 64-bit is nothing good in general.
This is reasoned by the problems existing in dw2 in combination with
other compiler-generated binaries.

Regards
Kai

2016-05-19 20:05 GMT+02:00 Jeff Law <law@redhat.com>:
> On 05/19/2016 11:36 AM, Sandra Loosemore wrote:
>>
>> This is a slightly revised version of the WIP patch against GCC 5.1 I
>> previously posted here:
>>
>> https://gcc.gnu.org/ml/gcc/2016-05/msg00135.html
>>
>> To recap, I needed a biarch x86_64 mingw-w64 target compiler that uses
>> DWARF-2 exception handling in 32-bit mode (for compatibility with an
>> older i686-mingw32 toolchain configured with --disable-sjlj-exceptions).
>>  But, the configuration machinery was rejecting this.  It used to be
>> that SJLJ exceptions were the only choice for 64-bit mode so it was
>> correct to reject --disable-sjlj-exceptions in a biarch toolchain, but
>> now the default for 64-bit mode is SEH instead.  With this patch,
>> configuring with --disable-sjlj-exceptions selects DWARF-2 EH in 32-bit
>> mode and SEH in 64-bit mode.
>>
>> I tested this in a cross-compiler configured to build C and C++ only for
>> x86_64 mingw-w64 target, and test results look about the same as the
>> default configuration, which uses SJLJ for 32-bit mode.  (If it's
>> relevant, I also used the compiler built with the 5.1 version of the
>> patch to build complete Windows-host toolchains for nios2-elf and
>> nios2-linux-gnu, which I tested by running the GDB testsuite.)  There
>> are no actual code changes here so I'd expect the 32-bit DWARF-2 EH
>> support to work exactly the same as in a 32-bit-only x86 configuration.
>>
>> OK to commit?
>
> OK.
>
> Thanks,
> Jeff
Sandra Loosemore May 19, 2016, 6:55 p.m. UTC | #3
On 05/19/2016 12:40 PM, Kai Tietz wrote:
> Hi,
>
> hopefully this time gmail uses  mail-encoding elmz ask for ...
>
> Sorry to object here.  I would like to point out that defaulting to
> dw2 on 32-bit if SEH is used for 64-bit is nothing good in general.
> This is reasoned by the problems existing in dw2 in combination with
> other compiler-generated binaries.

The patch does not change the default behavior for any target.  It only 
makes configuring with --disable-sjlj-exceptions work in a situation 
where it previously triggered a build error.

The reason why I need this is precisely because of a compatibility issue 
-- I have an existing 32-bit library supplied by a third party that uses 
DW2 EH that I need to link with.

-Sandra
Jeff Law May 19, 2016, 7:07 p.m. UTC | #4
On 05/19/2016 12:55 PM, Sandra Loosemore wrote:
> On 05/19/2016 12:40 PM, Kai Tietz wrote:
>> Hi,
>>
>> hopefully this time gmail uses  mail-encoding elmz ask for ...
>>
>> Sorry to object here.  I would like to point out that defaulting to
>> dw2 on 32-bit if SEH is used for 64-bit is nothing good in general.
>> This is reasoned by the problems existing in dw2 in combination with
>> other compiler-generated binaries.
>
> The patch does not change the default behavior for any target.  It only
> makes configuring with --disable-sjlj-exceptions work in a situation
> where it previously triggered a build error.
Precisely.

jeff
Kai Tietz May 19, 2016, 7:07 p.m. UTC | #5
Ok.  I just looked into patch.  Sorry for the delay.

As it is still possible to build old behavior, the patch is ok for me.

Thanks,
Kai


2016-05-19 20:55 GMT+02:00 Sandra Loosemore <sandra@codesourcery.com>:
> On 05/19/2016 12:40 PM, Kai Tietz wrote:
>>
>> Hi,
>>
>> hopefully this time gmail uses  mail-encoding elmz ask for ...
>>
>> Sorry to object here.  I would like to point out that defaulting to
>> dw2 on 32-bit if SEH is used for 64-bit is nothing good in general.
>> This is reasoned by the problems existing in dw2 in combination with
>> other compiler-generated binaries.
>
>
> The patch does not change the default behavior for any target.  It only
> makes configuring with --disable-sjlj-exceptions work in a situation where
> it previously triggered a build error.
>
> The reason why I need this is precisely because of a compatibility issue --
> I have an existing 32-bit library supplied by a third party that uses DW2 EH
> that I need to link with.
>
> -Sandra
>
>
diff mbox

Patch

Index: gcc/config/i386/cygming.h
===================================================================
--- gcc/config/i386/cygming.h	(revision 236256)
+++ gcc/config/i386/cygming.h	(working copy)
@@ -339,16 +339,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 236256)
+++ 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 236256)
+++ libgcc/config.host	(working copy)
@@ -678,6 +678,9 @@  x86_64-*-cygwin*)
 	# 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
 		tmake_eh_file="i386/t-sjlj-eh"
+	elif 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
@@ -730,6 +733,10 @@  x86_64-*-mingw*)
 	# 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
 		tmake_eh_file="i386/t-sjlj-eh"
+	elif test "${host_address}" = 32; then
+	        # biarch -m32 with --disable-sjlj-exceptions
+	     	tmake_eh_file="i386/t-dw2-eh"
+		md_unwind_header=i386/w32-unwind.h
 	else
 		tmake_eh_file="i386/t-seh-eh"
 	fi