This patch fixes two issues with LINK_SPEC on Cygwin targets:

1) --tsaware makes sense only for EXEs, not DLLs.

2) Under WoW64 (32-bit Cygwin on 64-bit Windows), Cygwin applications can access up to 4 GiB of address space (for DLLs, Cygwin heap, mmap()s, etc.) if they are linked with --large-address-aware. Because of how Cygwin implements fork(), the ability to use this extra space is a huge benefit. This flag too is only for EXEs, not DLLs.

Patch attached.

--
Yaakov Selkowitz
Associate Software Engineer, ARM
Red Hat, Inc.
2014-08-12  Yaakov Selkowitz  <yselk...@redhat.com>

        * config/i386/cygwin.h (LINK_SPEC): Pass --tsaware flag only
        when building executables, not DLLs.  Add --large-address-aware
        under the same conditions.
        * config/i386/cygwin-w64.h (LINK_SPEC): Pass --tsaware flag only
        when building executables, not DLLs.  Add --large-address-aware
        under the same conditions when using -m32.

Index: gcc/config/i386/cygwin-w64.h
===================================================================
--- gcc/config/i386/cygwin-w64.h        (revision 213759)
+++ gcc/config/i386/cygwin-w64.h        (working copy)
@@ -66,7 +66,8 @@
   %{static:-Bstatic} %{!static:-Bdynamic} \
   %{shared|mdll: " SUB_LINK_ENTRY " --enable-auto-image-base} \
   %(shared_libgcc_undefs) \
-  --dll-search-prefix=cyg -tsaware"
+  --dll-search-prefix=cyg \
+  %{!shared: %{!mdll: %{" SPEC_32 ":--large-address-aware} --tsaware}}"
 
 /* Cygwin64 will have a 64-bit long type. */
 #undef LONG_TYPE_SIZE
Index: gcc/config/i386/cygwin.h
===================================================================
--- gcc/config/i386/cygwin.h    (revision 213759)
+++ gcc/config/i386/cygwin.h    (working copy)
@@ -120,7 +120,8 @@
   %{shared: --shared} %{mdll:--dll} \
   %{static:-Bstatic} %{!static:-Bdynamic} \
   %{shared|mdll: --enable-auto-image-base -e __cygwin_dll_entry@12} \
-  --dll-search-prefix=cyg -tsaware"
+  --dll-search-prefix=cyg \
+  %{!shared: %{!mdll: --large-address-aware --tsaware}}"
 
 /* Binutils does not handle weak symbols from dlls correctly.  For now,
    do not use them unnecessarily in gthr-posix.h.  */

Reply via email to