Patchwork [cygwin64] : Add and adjust some initial sources for x64 cygwin

login
register
mail settings
Submitter Kai Tietz
Date March 22, 2013, 9 a.m.
Message ID <CAEwic4aHSMyLT8oJGPQhnfRw=ciX+oFUvkV+0BVN7=LpWd9DfQ@mail.gmail.com>
Download mbox | patch
Permalink /patch/229929/
State New
Headers show

Comments

Kai Tietz - March 22, 2013, 9 a.m.
Hi,

Hi,

the first part of required code-changes for upcoming cygwin x64 target.

ChangeLog

2013-03-22 Kai Tietz  <ktietz@redhat.com>

	* config/i386/cygwin-stdint.h: Add support for cygwin x64 target.
	* config/i386/t-cygwin-w64: New file.
	* config/i386/cygwin-w64.h: New file.
	* config/i386/cygwin.h (EXTRA_OS_CPP_BUILTINS): Extend
	and add support for x64-cygwin target.
	(CPP_SPEC): Likewise.
	(CXX_WRAP_SPEC_LIST): Undefine before define.
	(LIBGCJ_SONAME): Make name minor-build-version dependent.

Tested for i686-pc-cygwin, and x86_64-pc-cygwin.  Dave, please
especially a look to LIBGCJ_SONAME change. I think we should include
MAJOR_VERSION here, too. Ok for apply?

Regards,
Kai

Tested with i686-pc-cygwin, and x86_64-pc-cygwin.  I will apply
tomorrow, if there are no objections by other
Windows-target-maintainers.

Regards,
Kai
Dave Korn - March 23, 2013, 12:07 a.m.
On 22/03/2013 09:00, Kai Tietz wrote:

> 	(LIBGCJ_SONAME): Make name minor-build-version dependent.
> 
> Tested for i686-pc-cygwin, and x86_64-pc-cygwin.  Dave, please
> especially a look to LIBGCJ_SONAME change. I think we should include
> MAJOR_VERSION here, too. Ok for apply?

  I'm not sure about it:

> -/* We should find a way to not have to update this manually.  */
> -#define LIBGCJ_SONAME "cyggcj" /*LIBGCC_EH_EXTN*/ "-13.dll"
> -
> +#ifndef BUILDING_GCC_MAJOR
> +#include "bversion.h"
> +#endif
> +#define ___cyg_mkstr(x)	#x
> +#define __cyg_mkstr(x)	___cyg_mkstr(x)
> +#if BUILDING_GCC_MAJOR == 4
> +#define LIBGCJ_SONAME "cyggcj-" __cyg_mkstr (BUILDING_GCC_MINOR+6) ".dll"
> +#else
> +#error LIBGCJ_SONAME versioning scheme needs attention
> +#endif


  AIUI, the libgcj soversion has no fixed relation to the GCC major/minor
version of necessity, but is specified by the parameters in
$srcdir/libjava/libtool-version, which is manually updated.  We really ought
to run a script to extract the version info fields from there and do the
calculation ourselves if we're going to try to automate it.  Even if it is
policy to bump the libgcj soversion with every minor release of GCC, there's
no use us having the "right" value if someone neglects to update libjava; only
generating it from the libjava file will guarantee everything stays in
absolute lockstep.

    cheers,
      DaveK
Dave Korn - March 23, 2013, 12:16 a.m.
On 22/03/2013 09:00, Kai Tietz wrote:

> 	(CXX_WRAP_SPEC_LIST): Undefine before define.

> @@ -73,6 +82,7 @@
> 
>  /* To implement C++ function replacement we always wrap the cxx
>     malloc-like operators.  See N2800 #17.6.4.6 [replacement.functions] */
> +#undef CXX_WRAP_SPEC_LIST
>  #define CXX_WRAP_SPEC_LIST " \
>    --wrap _Znwj \
>    --wrap _Znaj \

  Also, I don't think this is really necessary.  Isn't it the case that
cygwin.h provides base definitions, and cygwin-w64.h overrides them, and it
would always be an error to include cygwin-w64.h before cygwin.h?  In which
case the macro redefinition error would be a useful warning that somebody was
using the headers wrong.

    cheers,
      DaveK
Kai Tietz - March 23, 2013, 12:16 a.m.
2013/3/23 Dave Korn <dave.korn.cygwin@gmail.com>:
> On 22/03/2013 09:00, Kai Tietz wrote:
>
>>       (LIBGCJ_SONAME): Make name minor-build-version dependent.
>>
>> Tested for i686-pc-cygwin, and x86_64-pc-cygwin.  Dave, please
>> especially a look to LIBGCJ_SONAME change. I think we should include
>> MAJOR_VERSION here, too. Ok for apply?
>
>   I'm not sure about it:
>
>> -/* We should find a way to not have to update this manually.  */
>> -#define LIBGCJ_SONAME "cyggcj" /*LIBGCC_EH_EXTN*/ "-13.dll"
>> -
>> +#ifndef BUILDING_GCC_MAJOR
>> +#include "bversion.h"
>> +#endif
>> +#define ___cyg_mkstr(x)      #x
>> +#define __cyg_mkstr(x)       ___cyg_mkstr(x)
>> +#if BUILDING_GCC_MAJOR == 4
>> +#define LIBGCJ_SONAME "cyggcj-" __cyg_mkstr (BUILDING_GCC_MINOR+6) ".dll"
>> +#else
>> +#error LIBGCJ_SONAME versioning scheme needs attention
>> +#endif
>
>
>   AIUI, the libgcj soversion has no fixed relation to the GCC major/minor
> version of necessity, but is specified by the parameters in
> $srcdir/libjava/libtool-version, which is manually updated.  We really ought
> to run a script to extract the version info fields from there and do the
> calculation ourselves if we're going to try to automate it.  Even if it is
> policy to bump the libgcj soversion with every minor release of GCC, there's
> no use us having the "right" value if someone neglects to update libjava; only
> generating it from the libjava file will guarantee everything stays in
> absolute lockstep.
>
>     cheers,
>       DaveK

Hmm, well, not sure about that too.  We shouldn't put hard
dependencies into gcc's build about target-libraries, but yes - if
unavoidable - a automated way to detect version-number I would
welcome, too.  It would be even better if we could rethink actual the
need of loading java-library within libgcc's cygwin's/mingw's crtbegin
at all.  I am actual not that sure, if we need this at all.

Cheers,
Kai
Kai Tietz - March 23, 2013, 12:20 a.m.
2013/3/23 Dave Korn <dave.korn.cygwin@gmail.com>:
> On 22/03/2013 09:00, Kai Tietz wrote:
>
>>       (CXX_WRAP_SPEC_LIST): Undefine before define.
>
>> @@ -73,6 +82,7 @@
>>
>>  /* To implement C++ function replacement we always wrap the cxx
>>     malloc-like operators.  See N2800 #17.6.4.6 [replacement.functions] */
>> +#undef CXX_WRAP_SPEC_LIST
>>  #define CXX_WRAP_SPEC_LIST " \
>>    --wrap _Znwj \
>>    --wrap _Znaj \
>
>   Also, I don't think this is really necessary.  Isn't it the case that
> cygwin.h provides base definitions, and cygwin-w64.h overrides them, and it
> would always be an error to include cygwin-w64.h before cygwin.h?  In which
> case the macro redefinition error would be a useful warning that somebody was
> using the headers wrong.
>
>     cheers,
>       DaveK

Yes, that's a fair point.

Cheers,
Kai
Kai Tietz - March 23, 2013, 12:24 a.m.
2013/3/23 Dave Korn <dave.korn.cygwin@gmail.com>:
> On 23/03/2013 00:16, Kai Tietz wrote:
>
>> welcome, too.  It would be even better if we could rethink actual the
>> need of loading java-library within libgcc's cygwin's/mingw's crtbegin
>> at all.  I am actual not that sure, if we need this at all.
>
>
>   Somebody has to register the default classes at startup, or attempts to
> classload them will fail.
>
>     cheers,
>       DaveK

Right, but shouldn't that be done by libjava-DLL itself on loading
(and deregistration on unloading)?  I see no good point to add this
into a different dll?  But well, I might miss here an important point.

Kai
Dave Korn - March 23, 2013, 12:24 a.m.
On 23/03/2013 00:16, Kai Tietz wrote:

> welcome, too.  It would be even better if we could rethink actual the
> need of loading java-library within libgcc's cygwin's/mingw's crtbegin
> at all.  I am actual not that sure, if we need this at all.


  Somebody has to register the default classes at startup, or attempts to
classload them will fail.

    cheers,
      DaveK
Dave Korn - March 23, 2013, 12:35 a.m.
On 23/03/2013 00:24, Kai Tietz wrote:
> 2013/3/23 Dave Korn <dave.korn.cygwin@gmail.com>:
>> On 23/03/2013 00:16, Kai Tietz wrote:
>>
>>> welcome, too.  It would be even better if we could rethink actual the
>>> need of loading java-library within libgcc's cygwin's/mingw's crtbegin
>>> at all.  I am actual not that sure, if we need this at all.
>>
>>   Somebody has to register the default classes at startup, or attempts to
>> classload them will fail.
>>
>>     cheers,
>>       DaveK
> 
> Right, but shouldn't that be done by libjava-DLL itself on loading
> (and deregistration on unloading)?  I see no good point to add this
> into a different dll?  But well, I might miss here an important point.

  Well, libgcc is always there, and libjava doesn't have any specific hooks
where we could add startup code, which is why all targets do it by default in
libgcc/crtstuff.c along with the C++ default ctor stuff.

    cheers,
      DaveK
Kai Tietz - March 23, 2013, 12:57 a.m.
2013/3/23 Dave Korn <dave.korn.cygwin@gmail.com>:
> On 23/03/2013 00:24, Kai Tietz wrote:
>> 2013/3/23 Dave Korn <dave.korn.cygwin@gmail.com>:
>>> On 23/03/2013 00:16, Kai Tietz wrote:
>>>
>>>> welcome, too.  It would be even better if we could rethink actual the
>>>> need of loading java-library within libgcc's cygwin's/mingw's crtbegin
>>>> at all.  I am actual not that sure, if we need this at all.
>>>
>>>   Somebody has to register the default classes at startup, or attempts to
>>> classload them will fail.
>>>
>>>     cheers,
>>>       DaveK
>>
>> Right, but shouldn't that be done by libjava-DLL itself on loading
>> (and deregistration on unloading)?  I see no good point to add this
>> into a different dll?  But well, I might miss here an important point.
>
>   Well, libgcc is always there, and libjava doesn't have any specific hooks
> where we could add startup code, which is why all targets do it by default in
> libgcc/crtstuff.c along with the C++ default ctor stuff.
>
>     cheers,
>       DaveK
>

Hmm, we have DllMain. it is enough for native Windows. And cygwin has
same feature via DECLARE_CYGWIN_DLL( DllMain ); AFAIK.

Cheers,
Kai
Dave Korn - March 23, 2013, 1:30 a.m.
On 23/03/2013 00:57, Kai Tietz wrote:
> 2013/3/23 Dave Korn <dave.korn.cygwin@gmail.com>:
>> On 23/03/2013 00:24, Kai Tietz wrote:
>>> 2013/3/23 Dave Korn <dave.korn.cygwin@gmail.com>:
>>>> On 23/03/2013 00:16, Kai Tietz wrote:
>>>>
>>>>> welcome, too.  It would be even better if we could rethink actual the
>>>>> need of loading java-library within libgcc's cygwin's/mingw's crtbegin
>>>>> at all.  I am actual not that sure, if we need this at all.
>>>>   Somebody has to register the default classes at startup, or attempts to
>>>> classload them will fail.

>>> Right, but shouldn't that be done by libjava-DLL itself on loading
>>> (and deregistration on unloading)?  I see no good point to add this
>>> into a different dll?  But well, I might miss here an important point.
>>   Well, libgcc is always there, and libjava doesn't have any specific hooks
>> where we could add startup code, which is why all targets do it by default in
>> libgcc/crtstuff.c along with the C++ default ctor stuff.

> Hmm, we have DllMain. it is enough for native Windows. And cygwin has
> same feature via DECLARE_CYGWIN_DLL( DllMain ); AFAIK.

  Well, yes we do, but why not just do it the same way every other target does it?

  Also, DllMain is very risky to do anything complex in.  Without having some
strong guarantees about how the default java class registration code might or
might not behave, I don't want to call it from DllMain.  (You've read
http://www.microsoft.com/whdc/driver/kernel/DLL_bestprac.mspx?)

    cheers,
      DaveK
Kai Tietz - March 24, 2013, 10:21 p.m.
2013/3/23 Dave Korn <dave.korn.cygwin@gmail.com>:
> On 23/03/2013 00:57, Kai Tietz wrote:
>> 2013/3/23 Dave Korn <dave.korn.cygwin@gmail.com>:
>>> On 23/03/2013 00:24, Kai Tietz wrote:
>>>> 2013/3/23 Dave Korn <dave.korn.cygwin@gmail.com>:
>>>>> On 23/03/2013 00:16, Kai Tietz wrote:
>>>>>
>>>>>> welcome, too.  It would be even better if we could rethink actual the
>>>>>> need of loading java-library within libgcc's cygwin's/mingw's crtbegin
>>>>>> at all.  I am actual not that sure, if we need this at all.
>>>>>   Somebody has to register the default classes at startup, or attempts to
>>>>> classload them will fail.
>
>>>> Right, but shouldn't that be done by libjava-DLL itself on loading
>>>> (and deregistration on unloading)?  I see no good point to add this
>>>> into a different dll?  But well, I might miss here an important point.
>>>   Well, libgcc is always there, and libjava doesn't have any specific hooks
>>> where we could add startup code, which is why all targets do it by default in
>>> libgcc/crtstuff.c along with the C++ default ctor stuff.
>
>> Hmm, we have DllMain. it is enough for native Windows. And cygwin has
>> same feature via DECLARE_CYGWIN_DLL( DllMain ); AFAIK.
>
>   Well, yes we do, but why not just do it the same way every other target does it?
>
>   Also, DllMain is very risky to do anything complex in.  Without having some
> strong guarantees about how the default java class registration code might or
> might not behave, I don't want to call it from DllMain.  (You've read
> http://www.microsoft.com/whdc/driver/kernel/DLL_bestprac.mspx?)
>
>     cheers,
>       DaveK

Well, I can't see that the required code here is something pretty
complex.  Also we are not talking here about kernel-driver DLL files,
are we?

Cheers,
Kai
Kai Tietz - March 27, 2013, 8:57 p.m.
So I committed the patch with two modifications at revision 197168 as

	* config/i386/cygwin-stdint.h: Add support for cygwin x64 target.
	* config/i386/t-cygwin-w64: New file.
	* config/i386/cygwin-w64.h: New file.
	* config/i386/cygwin.h (EXTRA_OS_CPP_BUILTINS): Extend
	and add support for x64-cygwin target.
	(CPP_SPEC): Likewise.
	(CXX_WRAP_SPEC_LIST): Undefine before define.
	(LIBGCJ_SONAME): Use 15 as version.

  First I removed useless undef in cygwin.h header.  Also I removed
this version-number calculation and changed version to use 15 for
libjava's DLL.

Regards,
Kai

Patch

Index: gcc/config/i386/cygwin-stdint.h
===================================================================
--- gcc/config/i386/cygwin-stdint.h	(Revision 196898)
+++ gcc/config/i386/cygwin-stdint.h	(Arbeitskopie)
@@ -24,39 +24,71 @@  along with GCC; see the file COPYING3.  If not see
 #define INT8_TYPE "signed char"
 #define INT16_TYPE "short int"
 #define INT32_TYPE "int"
+#ifdef __x86_64__
+#define INT64_TYPE "long int"
+#else
 #define INT64_TYPE "long long int"
+#endif

 #define UINT8_TYPE "unsigned char"
 #define UINT16_TYPE "short unsigned int"
 #define UINT32_TYPE "unsigned int"
+#ifdef __x86_64__
+#define UINT64_TYPE "long unsigned int"
+#else
 #define UINT64_TYPE "long long unsigned int"
+#endif

 /* Minimum-width integer types */

 #define INT_LEAST8_TYPE "signed char"
 #define INT_LEAST16_TYPE "short int"
 #define INT_LEAST32_TYPE "int"
+#ifdef __x86_64__
+#define INT_LEAST64_TYPE "long int"
+#else
 #define INT_LEAST64_TYPE "long long int"
+#endif

 #define UINT_LEAST8_TYPE "unsigned char"
 #define UINT_LEAST16_TYPE "short unsigned int"
 #define UINT_LEAST32_TYPE "unsigned int"
+#ifdef __x86_64__
+#define UINT_LEAST64_TYPE "long unsigned int"
+#else
 #define UINT_LEAST64_TYPE "long long unsigned int"
+#endif

 /* Fastest minimum-width integer types */

 #define INT_FAST8_TYPE "signed char"
+#ifdef __x86_64__
+#define INT_FAST16_TYPE "long int"
+#define INT_FAST32_TYPE "long int"
+#define INT_FAST64_TYPE "long int"
+#else
 #define INT_FAST16_TYPE "int"
 #define INT_FAST32_TYPE "int"
 #define INT_FAST64_TYPE "long long int"
+#endif

 #define UINT_FAST8_TYPE "unsigned char"
+#ifdef __x86_64__
+#define UINT_FAST16_TYPE "long unsigned int"
+#define UINT_FAST32_TYPE "long unsigned int"
+#define UINT_FAST64_TYPE "long unsigned int"
+#else
 #define UINT_FAST16_TYPE "unsigned int"
 #define UINT_FAST32_TYPE "unsigned int"
 #define UINT_FAST64_TYPE "long long unsigned int"
+#endif

 /* Integer types capable of holding object pointers */

+#ifdef __x86_64__
+#define INTPTR_TYPE "long int"
+#define UINTPTR_TYPE "long unsigned int"
+#else
 #define INTPTR_TYPE "int"
 #define UINTPTR_TYPE "unsigned int"
-
+#endif
Index: gcc/config/i386/cygwin.h
===================================================================
--- gcc/config/i386/cygwin.h	(revision 196791)
+++ gcc/config/i386/cygwin.h	(working copy)
@@ -18,11 +18,20 @@ 
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */

-#define EXTRA_OS_CPP_BUILTINS()  /* Nothing.  */
+#define EXTRA_OS_CPP_BUILTINS()					\
+  do								\
+    {								\
+      builtin_define ("__CYGWIN__");				\
+      if (!TARGET_64BIT)					\
+	builtin_define ("__CYGWIN32__");			\
+      builtin_define ("__unix__");				\
+      builtin_define ("__unix");				\
+    }								\
+  while (0)

 #undef CPP_SPEC
 #define CPP_SPEC "%(cpp_cpu) %{posix:-D_POSIX_SOURCE} \
-  -D__CYGWIN32__ -D__CYGWIN__ %{!ansi:-Dunix} -D__unix__ -D__unix \
+  %{!ansi:-Dunix} \
   %{mwin32:-DWIN32 -D_WIN32 -D__WIN32 -D__WIN32__ %{!ansi:-DWINNT}} \
   %{!nostdinc:%{!mno-win32:-idirafter ../include/w32api%s -idirafter
../../include/w32api%s}}\
 "
@@ -73,6 +82,7 @@ 

 /* To implement C++ function replacement we always wrap the cxx
    malloc-like operators.  See N2800 #17.6.4.6 [replacement.functions] */
+#undef CXX_WRAP_SPEC_LIST
 #define CXX_WRAP_SPEC_LIST " \
   --wrap _Znwj \
   --wrap _Znaj \
@@ -132,6 +142,13 @@ 
 #endif
 #define LIBGCC_SONAME "cyggcc_s" LIBGCC_EH_EXTN "-1.dll"

-/* We should find a way to not have to update this manually.  */
-#define LIBGCJ_SONAME "cyggcj" /*LIBGCC_EH_EXTN*/ "-13.dll"
-
+#ifndef BUILDING_GCC_MAJOR
+#include "bversion.h"
+#endif
+#define ___cyg_mkstr(x)	#x
+#define __cyg_mkstr(x)	___cyg_mkstr(x)
+#if BUILDING_GCC_MAJOR == 4
+#define LIBGCJ_SONAME "cyggcj-" __cyg_mkstr (BUILDING_GCC_MINOR+6) ".dll"
+#else
+#error LIBGCJ_SONAME versioning scheme needs attention
+#endif
Index: gcc/config/i386/cygwin-w64.h
===================================================================
--- gcc/config/i386/cygwin-w64.h	(revision 0)
+++ gcc/config/i386/cygwin-w64.h	(working copy)
@@ -0,0 +1,83 @@ 
+/* Operating system specific defines to be used when targeting GCC for
+   hosting on Windows 32/64 via Cygwin runtime, using GNU tools and
+   the Windows API Library.
+   Copyright (C) 2013 Free Software Foundation, Inc.
+
+This file is part of GCC.
+
+GCC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 3, or (at your option)
+any later version.
+
+GCC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GCC; see the file COPYING3.  If not see
+<http://www.gnu.org/licenses/>.  */
+
+/* Enable multilib.  */
+
+#undef ASM_SPEC
+#define ASM_SPEC "%{m32:--32} %{m64:--64}"
+
+/* To implement C++ function replacement we always wrap the cxx
+   malloc-like operators.  See N2800 #17.6.4.6 [replacement.functions] */
+#undef CXX_WRAP_SPEC_LIST
+#define CXX_WRAP_SPEC_LIST " \
+  --wrap _Znwm \
+  --wrap _Znam \
+  --wrap _ZdlPv \
+  --wrap _ZdaPv \
+  --wrap _ZnwmRKSt9nothrow_t \
+  --wrap _ZnamRKSt9nothrow_t \
+  --wrap _ZdlPvRKSt9nothrow_t \
+  --wrap _ZdaPvRKSt9nothrow_t \
+"
+
+#undef SPEC_32
+#undef SPEC_64
+#define SPEC_32 "m32"
+#define SPEC_64 "!m32"
+
+#undef SUB_LINK_ENTRY32
+#undef SUB_LINK_ENTRY64
+#define SUB_LINK_ENTRY32 "-e __cygwin_dll_entry@12"
+#define SUB_LINK_ENTRY64 "-e _cygwin_dll_entry"
+
+#undef SUB_LINK_SPEC
+#undef SUB_LINK_ENTRY
+#define SUB_LINK_SPEC "%{" SPEC_64 ":-m i386pep} %{" SPEC_32 ":-m i386pe}"
+#define SUB_LINK_ENTRY "%{" SPEC_64 ":" SUB_LINK_ENTRY64 "} %{"
SPEC_32 ":" SUB_LINK_ENTRY32 "}"
+
+#undef MULTILIB_DEFAULTS
+#define MULTILIB_DEFAULTS { "m64" }
+
+#undef LINK_SPEC
+#define LINK_SPEC SUB_LINK_SPEC "\
+  %{mwindows:--subsystem windows} \
+  %{mconsole:--subsystem console} \
+  " CXX_WRAP_SPEC " \
+  %{shared: %{mdll: %eshared and mdll are not compatible}} \
+  %{shared: --shared} %{mdll:--dll} \
+  %{static:-Bstatic} %{!static:-Bdynamic} \
+  %{shared|mdll: " SUB_LINK_ENTRY " --enable-auto-image-base} \
+  %(shared_libgcc_undefs) \
+  --dll-search-prefix=cyg -tsaware"
+
+/* Cygwin64 will have a 64-bit long type. */
+#undef LONG_TYPE_SIZE
+#undef LONG_TYPE_SIZE
+#define LONG_TYPE_SIZE (TARGET_64BIT ? 64 : 32)
+
+/* Override default "long long unsigned int" from cygming.h. */
+#undef SIZE_TYPE
+#define SIZE_TYPE (TARGET_64BIT ? "long unsigned int" : "unsigned int")
+#undef PTRDIFF_TYPE
+#define PTRDIFF_TYPE (TARGET_64BIT ? "long int" : "int")
+
+#undef LIBGCC_SONAME
+#define LIBGCC_SONAME "cyggcc_s-seh-1.dll"
Index: gcc/config/i386/t-cygwin-w64
===================================================================
--- gcc/config/i386/t-cygwin-w64	(revision 0)
+++ gcc/config/i386/t-cygwin-w64	(working copy)
@@ -0,0 +1,3 @@ 
+MULTILIB_OPTIONS = m64/m32
+MULTILIB_DIRNAMES = 64
+MULTILIB_OSDIRNAMES = ../lib ../lib32