Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

fix build for MSVC express 10

  • Loading branch information...
commit 6335fef0b1052dd0c885f522dccf06435e7274a2 1 parent 6ba364f
@twall authored
View
2  .gitignore
@@ -8,3 +8,5 @@ bin
contrib/ntservice/dist
contrib/platform/dist
doc
+*~
+**/*~
View
17 native/Makefile
@@ -50,6 +50,7 @@ JAVAH=$(BUILD)
INSTALLDIR=../build/$(OS)
JNIDISPATCH_OBJS=$(BUILD)/dispatch.o $(BUILD)/callback.o $(EXTRAOBJS)
RSRC=$(BUILD)/rsrc.o
+DLLCB=$(BUILD)/dll-callback.o
ifneq ($(DYNAMIC_LIBFFI),true)
FFI_SRC=$(shell pwd)/libffi
FFI_BUILD=$(BUILD)/libffi
@@ -129,6 +130,7 @@ STRIP=@echo
LIBPFX=
LIBSFX=.dll
+ifneq ($(ARCH),amd64)
ifeq ($(CC),gcc)
# -mno-cygwin is only available on GCC 3; GCC 4 requires an explicit mingw
# installation
@@ -142,17 +144,18 @@ CC += $(NOCYGWIN)
LD += $(NOCYGWIN) -Wl,--add-stdcall-alias
endif
-ifeq ($(ARCH),amd64)
+else
-# Uncomment to enable MINGW64 cross compiler; ensure mingw32-gcc is in PATH
-# Should build properly as of 111121, but lacks SEH, so MSVC build is preferred
+# Set CC to $(MINGW) to enable mingw64 cross compiler; ensure $(MINGW) is in
+# PATH. Should build properly as of 111121, but lacks SEH, so MSVC build is
+# preferred
MINGW=x86_64-w64-mingw32-gcc
# Still need windres from mingw distribution
WINDRES=x86_64-w64-mingw32-windres
-ifneq ($(MINGW),)
+ifeq ($(CC),$(MINGW))
+# No SEH under mingw64
CDEFINES=-DPSAPI_VERSION=1
-CC = $(MINGW)
LD = $(CC)
LDFLAGS=-o $@ -shared
LIBS= -lmingwex -lpsapi -lkernel32 -lmsvcrt
@@ -167,6 +170,7 @@ LIBS=psapi.lib
ARSFX=.lib
FFI_CONFIG+=--host=x86_64-pc-mingw32 && rm -f include/ffitarget.h && cp $(FFI_SRC)/include/*.h $(FFI_SRC)/src/x86/ffitarget.h include
FFI_ENV+=LD="$(LD) cpp=$(CPP)"
+EXTRAOBJS+=$(DLLCB)
endif
endif
endif
@@ -302,6 +306,9 @@ install:
mkdir $(INSTALLDIR)
cp $(LIBRARY) $(INSTALLDIR)
+$(DLLCB): dll-callback.S
+ $(CC) $(CFLAGS) -c $< $(COUT)
+
$(RSRC): $(BUILD)/jnidispatch.rc
$(WINDRES) -i $< -o $@ \
|| (echo > $@.c && $(CC) $(CFLAGS) -c $@.c $(COUT))
View
7 native/callback.c
@@ -32,11 +32,12 @@ extern "C" {
#ifdef _WIN32
#include "com_sun_jna_win32_DLLCallback.h"
-#ifdef __x86_64
+#ifndef __x86_64
#ifdef _MSC_VER
-#error MSVC does not support inline asm for amd64
+/* See dll-callback.S for actual definitions; no inline asm support. */
+#define ASMFN(X) extern void asmfn ## X ()
#else
-#define ASMFN(X)extern void asmfn ## X (); asm(".globl asmfn" #X "\n\
+#define ASMFN(X) extern void asmfn ## X (); asm(".globl asmfn" #X "\n\
asmfn" #X ":\n\
jmp *fn+8*" #X "(%rip)")
#endif
View
33 native/cc.sh
@@ -6,12 +6,12 @@
#
nowarn="/wd4127 /wd4820 /wd4706 /wd4100 /wd4255 /wd4668"
-args="/nologo /EHac /W3 /LD $nowarn" # /WX
+args="/nologo /EHac /W3 $nowarn" # /WX
cl="cl"
ml="ml"
-if [ -z "$INCLUDE" -o -z "$LIB" ]; then
+if [ -z "$INCLUDE" -a -z "$Include" -o -z "$LIB" -a -z "$Lib" ]; then
exit "INCLUDE and LIB must be set for CL.EXE to function properly"
fi
@@ -35,18 +35,26 @@ do
shift 1
;;
-m32)
- if echo $PATH | grep x64_amd64; then
+ if echo $PATH | grep amd64 >& /dev/null; then
echo "Wrong CL.EXE in path; use 32-bit version"
exit 1
fi
+ if echo $LIB | grep amd64 >& /dev/null; then
+ echo "Wrong paths in LIB; use 32-bit version"
+ exit 1
+ fi
ml=ml
shift 1
;;
-m64)
- if ! echo $PATH | grep x64_amd64; then
+ if ! echo $PATH | grep amd64 >& /dev/null; then
echo "Wrong CL.EXE in path; use 64-bit version"
exit 1
fi
+ if ! echo $LIB | grep amd64 >& /dev/null; then
+ echo "Wrong paths in LIB; use 64-bit version"
+ exit 1
+ fi
ml=ml64
shift 1
;;
@@ -66,6 +74,10 @@ do
single=/c
shift 1
;;
+ -shared)
+ args="$args /LD"
+ shift 1
+ ;;
-D*=*)
name="$(echo $1|sed 's/-D\([^=][^=]*\)=.*/\1/g')"
value="$(echo $1|sed 's/-D[^=][^=]*=//g')"
@@ -119,6 +131,9 @@ do
file=$(cygpath -m "$2")
outdir=$(dirname "$file")
base=$(basename "$file"|sed 's/\.[^.]*//g')
+ if [ -n "$assembly" ]; then
+ target="$file"
+ fi
if [ -n "$single" ]; then
output="/Fo$file"
else
@@ -134,8 +149,8 @@ do
*.S)
file=$(cygpath -m "$1")
src=$(echo $file|sed -e 's/.S$/.asm/g' -e 's%\\%/%g')
- echo "$cl /EP $includes $defines \"$file\" > \"$src\""
- "$cl" /nologo /EP $includes $defines "$file" > "$src" || exit $?
+ echo "$cl /nologo /EP $includes $defines \"$file\" > \"$src\""
+ eval "$cl /nologo /EP $includes $defines \"$file\"" > "$src" || exit $?
md=""
cl="$ml"
output=$(echo $output | sed 's%/F[dpa][^ ]*%%g')
@@ -161,12 +176,14 @@ do
done
args="$md $args"
+echo "Compiling..."
echo "$cl $args (INCLUDE=$INCLUDE LIB=$LIB)"
-eval "\"$cl\" $args"
+eval "$cl $args"
result=$?
# @#!%@!# ml64 broken output
if [ -n "$assembly" ]; then
+ echo "Currently in $(pwd)"
mv $src $outdir
- mv *.obj $outdir
+ mv *.obj $target
fi
exit $result
View
9 native/dispatch.c
@@ -93,6 +93,15 @@
#include "dispatch.h"
+/* Native memory fault protection */
+#ifdef HAVE_PROTECTION
+#define PROTECT is_protected()
+#endif
+#include "protect.h"
+#define ON_ERROR() throwByName(env, EError, "Invalid memory access")
+#define PSTART() PROTECTED_START()
+#define PEND() PROTECTED_END(ON_ERROR())
+
#ifdef HAVE_PROTECTION
static int _protect;
#undef PROTECT
View
9 native/dispatch.h
@@ -204,15 +204,6 @@ extern jobject initializeThread(callback*,AttachOptions*);
extern int lastError();
extern void setLastError(int err);
-/* Native memory fault protection */
-#ifdef HAVE_PROTECTION
-#define PROTECT is_protected()
-#endif
-#include "protect.h"
-#define ON_ERROR() throwByName(env, EError, "Invalid memory access")
-#define PSTART() PROTECTED_START()
-#define PEND() PROTECTED_END(ON_ERROR())
-
#ifdef __cplusplus
}
#endif
View
14 native/ld.sh
@@ -5,7 +5,7 @@
#args="/pdbtype:sept"
args="/nologo /opt:REF /incremental:no /subsystem:console /nodefaultlib:msvcrtd"
-if [ -z "$LIB" ]; then
+if [ -z "$LIB" -a "$Lib" ]; then
exit "LIB must be set for LINK.EXE to function properly"
fi
@@ -15,17 +15,25 @@ do
case $1
in
-m32)
- if echo $PATH | grep x64_amd64; then
+ if echo $PATH | grep amd64; then
echo "Wrong LINK.EXE in path; use 32-bit version"
exit 1
fi
+ if echo $LIB | grep amd64; then
+ echo "Wrong paths in LIB; use 32-bit version"
+ exit 1
+ fi
shift 1
;;
-m64)
- if ! echo $PATH | grep x64_amd64; then
+ if ! echo $PATH | grep amd64; then
echo "Wrong LINK.EXE in path; use 64-bit version"
exit 1
fi
+ if ! echo $LIB | grep amd64; then
+ echo "Wrong paths in LIB; use 64-bit version"
+ exit 1
+ fi
shift 1
;;
-g)
Please sign in to comment.
Something went wrong with that request. Please try again.