Commit 54fde020 by Bernd Edlinger Committed by Bernd Edlinger

Enable Java on Cygwin-64

Currently it is not possible to build GCC's libjava support on Cygwin-64.

This patch fixes the current build-problems on Cygwin-64 and the most
fundamental bugs on that platform.

Note you must still add --enable-threads=posix to successfully build the
java language support.


boehm-gc/ChangeLog:

2014-05-13  Bernd Edlinger  <bernd.edlinger@hotmail.de>

        Fix current cygwin-64 build problems.
        * include/gc_config_macros.h (GC_PTHREADS): Use __CYGWIN__ instead
        of __CYGWIN32__ here.
        * win32_threads.c (GC_push_all_stacks): Push all X86_64 registers.
        (GC_get_thread_stack_base): Get the stack base for X86_64.

libffi/ChangeLog:

2014-05-13  Bernd Edlinger  <bernd.edlinger@hotmail.de>

        Fix current cygwin-64 build problems.
        * src/java_raw_api.c: Remove if !defined(FFI_NO_RAW_API).
        * src/x86/ffi.c: Add if defined(__CYGWIN__).
        * src/x86/win64.S (ffi_closure_win64, ffi_call_win64): Added
        handling for FFI_TYPE_UINT64, FFI_TYPE_POINTER and FFI_TYPE_INT.
        Added SEH information.  Fixed formatting.

libgcc/ChangeLog:

2014-05-13  Bernd Edlinger  <bernd.edlinger@hotmail.de>

        * unwind-seh.c (_Unwind_Backtrace): Uncommented, finished
        implementation.

libjava/ChangeLog:

2014-05-13  Bernd Edlinger  <bernd.edlinger@hotmail.de>

        Fix current cygwin-64 build problems.
        * configure.host: Added handling for x86_64-*-cygwin/mingw.
        * boehm.cc (_Jv_GCAttachThread, _Jv_GCDetachThread): Don't compile if
        GC_WIN32_THREADS is defined.
        * java/lang/natClass.cc (_Jv_InterfaceAssignableFrom): Rename interface
        to source_interface.

libjava/classpath/ChangeLog:

2014-05-13  Bernd Edlinger  <bernd.edlinger@hotmail.de>

        Fix current cygwin-64 build problems.
        * native/fdlibm/mprec.c (_REENT_CHECK_MP, _REENT_MP_FREELIST,
        _REENT_MP_P5S, __ULong, __Long): Undefine previous definitions.

From-SVN: r210386
parent af2db4c5
2014-05-13 Bernd Edlinger <bernd.edlinger@hotmail.de>
Fix current cygwin-64 build problems.
* include/gc_config_macros.h (GC_PTHREADS): Use __CYGWIN__ instead
of __CYGWIN32__ here.
* win32_threads.c (GC_push_all_stacks): Push all X86_64 registers.
(GC_get_thread_stack_base): Get the stack base for X86_64.
2014-04-22 Jakub Jelinek <jakub@redhat.com> 2014-04-22 Jakub Jelinek <jakub@redhat.com>
PR other/43620 PR other/43620
......
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
defined(GC_HPUX_THREADS) || defined(GC_OSF1_THREADS) || \ defined(GC_HPUX_THREADS) || defined(GC_OSF1_THREADS) || \
defined(GC_DGUX386_THREADS) || defined(GC_DARWIN_THREADS) || \ defined(GC_DGUX386_THREADS) || defined(GC_DARWIN_THREADS) || \
defined(GC_AIX_THREADS) || \ defined(GC_AIX_THREADS) || \
(defined(GC_WIN32_THREADS) && defined(__CYGWIN32__)) (defined(GC_WIN32_THREADS) && defined(__CYGWIN__))
# define GC_PTHREADS # define GC_PTHREADS
# endif # endif
......
...@@ -365,7 +365,11 @@ void GC_push_all_stacks() ...@@ -365,7 +365,11 @@ void GC_push_all_stacks()
# define PUSH1(reg) GC_push_one((word)context.reg) # define PUSH1(reg) GC_push_one((word)context.reg)
# define PUSH2(r1,r2) PUSH1(r1), PUSH1(r2) # define PUSH2(r1,r2) PUSH1(r1), PUSH1(r2)
# define PUSH4(r1,r2,r3,r4) PUSH2(r1,r2), PUSH2(r3,r4) # define PUSH4(r1,r2,r3,r4) PUSH2(r1,r2), PUSH2(r3,r4)
# if defined(I386) # if defined(__x86_64__)
PUSH4(Rdi,Rsi,Rbx,Rdx), PUSH2(Rcx,Rax), PUSH1(Rbp);
PUSH4(R8,R9,R10,R11), PUSH4(R12,R13,R14,R15);
sp = (ptr_t)context.Rsp;
# elif defined(I386)
PUSH4(Edi,Esi,Ebx,Edx), PUSH2(Ecx,Eax), PUSH1(Ebp); PUSH4(Edi,Esi,Ebx,Edx), PUSH2(Ecx,Eax), PUSH1(Ebp);
sp = (ptr_t)context.Esp; sp = (ptr_t)context.Esp;
# elif defined(ARM32) # elif defined(ARM32)
...@@ -755,8 +759,12 @@ int GC_pthread_detach(pthread_t thread) ...@@ -755,8 +759,12 @@ int GC_pthread_detach(pthread_t thread)
GC_PTR GC_get_thread_stack_base() GC_PTR GC_get_thread_stack_base()
{ {
#ifdef __x86_64__
return ((NT_TIB*)NtCurrentTeb())->StackBase;
#else
extern GC_PTR _tlsbase __asm__ ("%fs:4"); extern GC_PTR _tlsbase __asm__ ("%fs:4");
return _tlsbase; return _tlsbase;
#endif
} }
#else /* !CYGWIN32 */ #else /* !CYGWIN32 */
......
2014-05-13 Bernd Edlinger <bernd.edlinger@hotmail.de>
Fix current cygwin-64 build problems.
* src/java_raw_api.c: Remove if !defined(FFI_NO_RAW_API).
* src/x86/ffi.c: Add if defined(__CYGWIN__).
* src/x86/win64.S (ffi_closure_win64, ffi_call_win64): Added
handling for FFI_TYPE_UINT64, FFI_TYPE_POINTER and FFI_TYPE_INT.
Added SEH information. Fixed formatting.
2014-04-22 Jakub Jelinek <jakub@redhat.com> 2014-04-22 Jakub Jelinek <jakub@redhat.com>
PR other/43620 PR other/43620
......
...@@ -39,7 +39,7 @@ ...@@ -39,7 +39,7 @@
#include <ffi_common.h> #include <ffi_common.h>
#include <stdlib.h> #include <stdlib.h>
#if !defined(NO_JAVA_RAW_API) && !defined(FFI_NO_RAW_API) #if !defined(NO_JAVA_RAW_API)
size_t size_t
ffi_java_raw_size (ffi_cif *cif) ffi_java_raw_size (ffi_cif *cif)
...@@ -353,4 +353,4 @@ ffi_prep_java_raw_closure (ffi_java_raw_closure* cl, ...@@ -353,4 +353,4 @@ ffi_prep_java_raw_closure (ffi_java_raw_closure* cl,
#endif /* FFI_CLOSURES */ #endif /* FFI_CLOSURES */
#endif /* !FFI_NATIVE_RAW_API */ #endif /* !FFI_NATIVE_RAW_API */
#endif /* !FFI_NO_RAW_API */ #endif /* !NO_JAVA_RAW_API */
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
DEALINGS IN THE SOFTWARE. DEALINGS IN THE SOFTWARE.
----------------------------------------------------------------------- */ ----------------------------------------------------------------------- */
#if !defined(__x86_64__) || defined(_WIN64) #if !defined(__x86_64__) || defined(_WIN64) || defined(__CYGWIN__)
#ifdef _WIN64 #ifdef _WIN64
#include <windows.h> #include <windows.h>
......
...@@ -209,20 +209,45 @@ ret_float$: ...@@ -209,20 +209,45 @@ ret_float$:
ret_double$: ret_double$:
cmp DWORD PTR CIF_FLAGS[rbp], FFI_TYPE_DOUBLE cmp DWORD PTR CIF_FLAGS[rbp], FFI_TYPE_DOUBLE
jne SHORT ret_sint64$ jne SHORT ret_uint64$
mov rax, QWORD PTR RVALUE[rbp] mov rax, QWORD PTR RVALUE[rbp]
movlpd QWORD PTR [rax], xmm0 movlpd QWORD PTR [rax], xmm0
jmp SHORT ret_void$ jmp SHORT ret_void$
ret_uint64$:
cmp DWORD PTR CIF_FLAGS[rbp], FFI_TYPE_UINT64
jne SHORT ret_sint64$
mov rcx, QWORD PTR RVALUE[rbp]
mov QWORD PTR [rcx], rax
jmp SHORT ret_void$
ret_sint64$: ret_sint64$:
cmp DWORD PTR CIF_FLAGS[rbp], FFI_TYPE_SINT64 cmp DWORD PTR CIF_FLAGS[rbp], FFI_TYPE_SINT64
jne ret_void$ jne SHORT ret_pointer$
mov rcx, QWORD PTR RVALUE[rbp] mov rcx, QWORD PTR RVALUE[rbp]
mov QWORD PTR [rcx], rax mov QWORD PTR [rcx], rax
jmp SHORT ret_void$ jmp SHORT ret_void$
ret_pointer$:
cmp DWORD PTR CIF_FLAGS[rbp], FFI_TYPE_POINTER
jne SHORT ret_int$
mov rcx, QWORD PTR RVALUE[rbp]
mov QWORD PTR [rcx], rax
jmp SHORT ret_void$
ret_int$:
cmp DWORD PTR CIF_FLAGS[rbp], FFI_TYPE_INT
jne SHORT ret_void$
mov rcx, QWORD PTR RVALUE[rbp]
cdqe
mov QWORD PTR [rcx], rax
jmp SHORT ret_void$
ret_void$: ret_void$:
xor rax, rax xor rax, rax
...@@ -255,6 +280,7 @@ END ...@@ -255,6 +280,7 @@ END
# #
.balign 16 .balign 16
.globl SYMBOL_NAME(ffi_closure_win64) .globl SYMBOL_NAME(ffi_closure_win64)
.seh_proc SYMBOL_NAME(ffi_closure_win64)
SYMBOL_NAME(ffi_closure_win64): SYMBOL_NAME(ffi_closure_win64):
# copy register arguments onto stack # copy register arguments onto stack
test $1,%r11 test $1,%r11
...@@ -289,9 +315,9 @@ SYMBOL_NAME(ffi_closure_win64): ...@@ -289,9 +315,9 @@ SYMBOL_NAME(ffi_closure_win64):
movlpd %xmm3, 32(%rsp) movlpd %xmm3, 32(%rsp)
.Ldone: .Ldone:
#.ALLOCSTACK 40 .seh_stackalloc 40
sub $40, %rsp sub $40, %rsp
#.ENDPROLOG .seh_endprologue
mov %rax, %rcx # context is first parameter mov %rax, %rcx # context is first parameter
mov %rsp, %rdx # stack is second parameter mov %rsp, %rdx # stack is second parameter
add $48, %rdx # point to start of arguments add $48, %rdx # point to start of arguments
...@@ -301,23 +327,24 @@ SYMBOL_NAME(ffi_closure_win64): ...@@ -301,23 +327,24 @@ SYMBOL_NAME(ffi_closure_win64):
movq %rax, %xmm0 # If the closure returned a float, movq %rax, %xmm0 # If the closure returned a float,
# ffi_closure_win64_inner wrote it to rax # ffi_closure_win64_inner wrote it to rax
retq retq
.ffi_closure_win64_end: .seh_endproc
.balign 16 .balign 16
.globl SYMBOL_NAME(ffi_call_win64) .globl SYMBOL_NAME(ffi_call_win64)
.seh_proc SYMBOL_NAME(ffi_call_win64)
SYMBOL_NAME(ffi_call_win64): SYMBOL_NAME(ffi_call_win64):
# copy registers onto stack # copy registers onto stack
mov %r9,32(%rsp) mov %r9,32(%rsp)
mov %r8,24(%rsp) mov %r8,24(%rsp)
mov %rdx,16(%rsp) mov %rdx,16(%rsp)
mov %rcx,8(%rsp) mov %rcx,8(%rsp)
#.PUSHREG rbp .seh_pushreg rbp
push %rbp push %rbp
#.ALLOCSTACK 48 .seh_stackalloc 48
sub $48,%rsp sub $48,%rsp
#.SETFRAME rbp, 32 .seh_setframe rbp, 32
lea 32(%rsp),%rbp lea 32(%rsp),%rbp
#.ENDPROLOG .seh_endprologue
mov CIF_BYTES(%rbp),%eax mov CIF_BYTES(%rbp),%eax
add $15, %rax add $15, %rax
...@@ -443,26 +470,51 @@ Lch_done: ...@@ -443,26 +470,51 @@ Lch_done:
.Lret_double: .Lret_double:
cmpl $FFI_TYPE_DOUBLE, CIF_FLAGS(%rbp) cmpl $FFI_TYPE_DOUBLE, CIF_FLAGS(%rbp)
jne .Lret_sint64 jne .Lret_uint64
mov RVALUE(%rbp), %rax mov RVALUE(%rbp), %rax
movlpd %xmm0, (%rax) movlpd %xmm0, (%rax)
jmp .Lret_void jmp .Lret_void
.Lret_uint64:
cmpl $FFI_TYPE_UINT64, CIF_FLAGS(%rbp)
jne .Lret_sint64
mov RVALUE(%rbp), %rcx
mov %rax, (%rcx)
jmp .Lret_void
.Lret_sint64: .Lret_sint64:
cmpl $FFI_TYPE_SINT64, CIF_FLAGS(%rbp) cmpl $FFI_TYPE_SINT64, CIF_FLAGS(%rbp)
jne .Lret_void jne .Lret_pointer
mov RVALUE(%rbp), %rcx mov RVALUE(%rbp), %rcx
mov %rax, (%rcx) mov %rax, (%rcx)
jmp .Lret_void jmp .Lret_void
.Lret_pointer:
cmpl $FFI_TYPE_POINTER, CIF_FLAGS(%rbp)
jne .Lret_int
mov RVALUE(%rbp), %rcx
mov %rax, (%rcx)
jmp .Lret_void
.Lret_int:
cmpl $FFI_TYPE_INT, CIF_FLAGS(%rbp)
jne .Lret_void
mov RVALUE(%rbp), %rcx
cltq
movq %rax, (%rcx)
jmp .Lret_void
.Lret_void: .Lret_void:
xor %rax, %rax xor %rax, %rax
lea 16(%rbp), %rsp lea 16(%rbp), %rsp
pop %rbp pop %rbp
retq retq
.ffi_call_win64_end: .seh_endproc
#endif /* !_MSC_VER */ #endif /* !_MSC_VER */
2014-05-13 Bernd Edlinger <bernd.edlinger@hotmail.de>
* unwind-seh.c (_Unwind_Backtrace): Uncommented, finished
implementation.
2014-05-12 Georg-Johann Lay <avr@gjlay.de> 2014-05-12 Georg-Johann Lay <avr@gjlay.de>
* config/arm/bpabi-lib.h (License): Add GCC Runtime Library Exception. * config/arm/bpabi-lib.h (License): Add GCC Runtime Library Exception.
......
...@@ -431,43 +431,40 @@ _Unwind_DeleteException (struct _Unwind_Exception *exc) ...@@ -431,43 +431,40 @@ _Unwind_DeleteException (struct _Unwind_Exception *exc)
/* Perform stack backtrace through unwind data. */ /* Perform stack backtrace through unwind data. */
_Unwind_Reason_Code _Unwind_Reason_Code
_Unwind_Backtrace(_Unwind_Trace_Fn trace ATTRIBUTE_UNUSED, _Unwind_Backtrace(_Unwind_Trace_Fn trace,
void *trace_argument ATTRIBUTE_UNUSED) void *trace_argument)
{ {
#if 0
UNWIND_HISTORY_TABLE ms_history; UNWIND_HISTORY_TABLE ms_history;
CONTEXT ms_context; CONTEXT ms_context;
struct _Unwind_Context gcc_context; struct _Unwind_Context gcc_context;
DISPATCHER_CONTEXT disp_context;
memset (&ms_history, 0, sizeof(ms_history)); memset (&ms_history, 0, sizeof(ms_history));
memset (&gcc_context, 0, sizeof(gcc_context)); memset (&gcc_context, 0, sizeof(gcc_context));
memset (&disp_context, 0, sizeof(disp_context));
ms_context.ContextFlags = CONTEXT_ALL; ms_context.ContextFlags = CONTEXT_ALL;
RtlCaptureContext (&ms_context); RtlCaptureContext (&ms_context);
gcc_context.disp.ContextRecord = &ms_context; gcc_context.disp = &disp_context;
gcc_context.disp.HistoryTable = &ms_history; gcc_context.disp->ContextRecord = &ms_context;
gcc_context.disp->HistoryTable = &ms_history;
while (1) while (1)
{ {
gcc_context.disp.ControlPc = ms_context.Rip; gcc_context.disp->ControlPc = ms_context.Rip;
gcc_context.disp.FunctionEntry gcc_context.disp->FunctionEntry
= RtlLookupFunctionEntry (ms_context.Rip, &gcc_context.disp.ImageBase, = RtlLookupFunctionEntry (ms_context.Rip, &gcc_context.disp->ImageBase,
&ms_history); &ms_history);
if (gcc_context.disp.FunctionEntry) if (!gcc_context.disp->FunctionEntry)
{ return _URC_END_OF_STACK;
gcc_context.disp.LanguageHandler
= RtlVirtualUnwind (0, gcc_context.disp.ImageBase, ms_context.Rip, gcc_context.disp->LanguageHandler
gcc_context.disp.FunctionEntry, &ms_context, = RtlVirtualUnwind (0, gcc_context.disp->ImageBase, ms_context.Rip,
&gcc_context.disp.HandlerData, gcc_context.disp->FunctionEntry, &ms_context,
&gcc_context.disp.EstablisherFrame, NULL); &gcc_context.disp->HandlerData,
} &gcc_context.disp->EstablisherFrame, NULL);
else
{
ms_context.Rip = *(ULONG_PTR *)ms_context.Rsp;
ms_context.Rsp += 8;
}
/* Call trace function. */ /* Call trace function. */
if (trace (&gcc_context, trace_argument) != _URC_NO_REASON) if (trace (&gcc_context, trace_argument) != _URC_NO_REASON)
...@@ -477,8 +474,5 @@ _Unwind_Backtrace(_Unwind_Trace_Fn trace ATTRIBUTE_UNUSED, ...@@ -477,8 +474,5 @@ _Unwind_Backtrace(_Unwind_Trace_Fn trace ATTRIBUTE_UNUSED,
if (ms_context.Rip == 0) if (ms_context.Rip == 0)
return _URC_END_OF_STACK; return _URC_END_OF_STACK;
} }
#else
return _URC_END_OF_STACK;
#endif
} }
#endif /* __SEH__ && !defined (__USING_SJLJ_EXCEPTIONS__) */ #endif /* __SEH__ && !defined (__USING_SJLJ_EXCEPTIONS__) */
2014-05-13 Bernd Edlinger <bernd.edlinger@hotmail.de>
Fix current cygwin-64 build problems.
* configure.host: Added handling for x86_64-*-cygwin/mingw.
* boehm.cc (_Jv_GCAttachThread, _Jv_GCDetachThread): Don't compile if
GC_WIN32_THREADS is defined.
* java/lang/natClass.cc (_Jv_InterfaceAssignableFrom): Rename interface
to source_interface.
2014-04-22 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE> 2014-04-22 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
* configure.ac (THREADLIBS, THREADSPEC): Remove *-*-solaris2.9 * configure.ac (THREADLIBS, THREADSPEC): Remove *-*-solaris2.9
......
...@@ -747,7 +747,8 @@ _Jv_GCAttachThread () ...@@ -747,7 +747,8 @@ _Jv_GCAttachThread ()
// The registration interface is only defined on posixy systems and // The registration interface is only defined on posixy systems and
// only actually works if pthread_getattr_np is defined. // only actually works if pthread_getattr_np is defined.
// FIXME: until gc7 it is simpler to disable this on solaris. // FIXME: until gc7 it is simpler to disable this on solaris.
#if defined(HAVE_PTHREAD_GETATTR_NP) && !defined(GC_SOLARIS_THREADS) #if defined(HAVE_PTHREAD_GETATTR_NP) && !defined(GC_SOLARIS_THREADS) \
&& !defined(GC_WIN32_THREADS)
GC_register_my_thread (); GC_register_my_thread ();
#endif #endif
} }
...@@ -755,7 +756,8 @@ _Jv_GCAttachThread () ...@@ -755,7 +756,8 @@ _Jv_GCAttachThread ()
void void
_Jv_GCDetachThread () _Jv_GCDetachThread ()
{ {
#if defined(HAVE_PTHREAD_GETATTR_NP) && !defined(GC_SOLARIS_THREADS) #if defined(HAVE_PTHREAD_GETATTR_NP) && !defined(GC_SOLARIS_THREADS) \
&& !defined(GC_WIN32_THREADS)
GC_unregister_my_thread (); GC_unregister_my_thread ();
#endif #endif
} }
2014-05-13 Bernd Edlinger <bernd.edlinger@hotmail.de>
Fix current cygwin-64 build problems.
* native/fdlibm/mprec.c (_REENT_CHECK_MP, _REENT_MP_FREELIST,
_REENT_MP_P5S, __ULong, __Long): Undefine previous definitions.
2013-09-20 Alan Modra <amodra@gmail.com> 2013-09-20 Alan Modra <amodra@gmail.com>
* configure: Regenerate. * configure: Regenerate.
......
...@@ -93,12 +93,17 @@ ...@@ -93,12 +93,17 @@
#define _reent _Jv_reent #define _reent _Jv_reent
#define _Bigint _Jv_Bigint #define _Bigint _Jv_Bigint
#undef _REENT_CHECK_MP
#define _REENT_CHECK_MP(x) #define _REENT_CHECK_MP(x)
#undef _REENT_MP_FREELIST
#define _REENT_MP_FREELIST(x) ((x)->_freelist) #define _REENT_MP_FREELIST(x) ((x)->_freelist)
#undef _REENT_MP_P5S
#define _REENT_MP_P5S(x) ((x)->_p5s) #define _REENT_MP_P5S(x) ((x)->_p5s)
typedef unsigned long __ULong; #undef __ULong
typedef long __Long; #define __ULong unsigned long
#undef __Long
#define __Long long
static void * static void *
mprec_calloc (void *ignore, size_t x1, size_t x2) mprec_calloc (void *ignore, size_t x1, size_t x2)
......
...@@ -365,6 +365,13 @@ EOF ...@@ -365,6 +365,13 @@ EOF
esac esac
case "${host}" in case "${host}" in
x86_64-*-cygwin* | x86_64-*-mingw*)
# Win32 DLLs are limited to 64k exported symbols each.
enable_libgcj_sublibs_default=yes
libgcj_sublib_ltflags='$(lt_host_flags) \
-Wl,-u,_ZN3org4ietf4jgss10GSSManagerC1Ev,-L..,-lgcj-noncore-dummy'
libgcj_sublib_core_extra_deps=libgcj-noncore-dummy.dll.a
;;
*-cygwin* | *-mingw*) *-cygwin* | *-mingw*)
fallback_backtrace_h=sysdep/i386/backtrace.h fallback_backtrace_h=sysdep/i386/backtrace.h
# We need a frame pointer on Windows, so override BACKTRACESPEC # We need a frame pointer on Windows, so override BACKTRACESPEC
......
...@@ -1870,9 +1870,9 @@ _Jv_InterfaceAssignableFrom (jclass source, jclass iface) ...@@ -1870,9 +1870,9 @@ _Jv_InterfaceAssignableFrom (jclass source, jclass iface)
{ {
for (int i = 0; i < source->interface_count; i++) for (int i = 0; i < source->interface_count; i++)
{ {
jclass interface = source->interfaces[i]; jclass source_interface = source->interfaces[i];
if (iface == interface if (iface == source_interface
|| _Jv_InterfaceAssignableFrom (interface, iface)) || _Jv_InterfaceAssignableFrom (source_interface, iface))
return true; return true;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment