From 86188cfc04147b7b9b6daff6288f2565e48e1c12 Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Mon, 15 Nov 2010 20:28:53 -0700 Subject: [PATCH] fix OS X openjdk and openjdk-src builds --- makefile | 28 ++++++++++++++++++++-------- openjdk-src.mk | 6 ++++++ src/classpath-openjdk.cpp | 10 ++-------- src/common.h | 2 +- src/posix.cpp | 2 +- src/windows.cpp | 2 +- test/test.sh | 5 ++--- 7 files changed, 33 insertions(+), 22 deletions(-) diff --git a/makefile b/makefile index 96361d6136..ba76e7afd4 100644 --- a/makefile +++ b/makefile @@ -66,7 +66,18 @@ ifneq (,$(filter mingw32 cygwin,$(build-platform))) path-separator = ; endif +library-path-variable = LD_LIBRARY_PATH + +ifeq ($(build-platform),darwin) + library-path-variable = DYLD_LIBRARY_PATH +endif + ifdef openjdk + openjdk-arch = $(arch) + ifeq ($(arch),x86_64) + openjdk-arch = amd64 + endif + ifdef openjdk-src include openjdk-src.mk options := $(options)-openjdk-src @@ -83,7 +94,8 @@ ifdef openjdk else options := $(options)-openjdk test-executable = $(executable-dynamic) - library-path = LD_LIBRARY_PATH=$(build) + library-path = \ + $(library-path-variable)=$(build):$(openjdk)/jre/lib/$(openjdk-arch) javahome = "$$($(native-path) "$(openjdk)/jre")" endif @@ -155,8 +167,6 @@ lflags = $(common-lflags) -lpthread -ldl version-script-flag = -Wl,--version-script=openjdk.ld -jvm-flags = -L$(build) -ljvm - build-system = posix system = posix @@ -185,7 +195,6 @@ endif ifeq ($(platform),darwin) version-script-flag = - jvm-flags = $(build)/libjvm.jnilib build-cflags = $(common-cflags) -fPIC -fvisibility=hidden -I$(src) build-lflags += -framework CoreFoundation lflags = $(common-lflags) -ldl -framework CoreFoundation -framework CoreServices @@ -194,22 +203,25 @@ ifeq ($(platform),darwin) endif rdynamic = strip-all = -S -x - so-suffix = .jnilib + so-suffix = .dylib shared = -dynamiclib ifeq ($(arch),powerpc) + openjdk-extra-cflags += -arch ppc cflags += -arch ppc asmflags += -arch ppc lflags += -arch ppc endif ifeq ($(arch),i386) + openjdk-extra-cflags += -arch i386 cflags += -arch i386 asmflags += -arch i386 lflags += -arch i386 endif ifeq ($(arch),x86_64) + openjdk-extra-cflags += -arch x86_64 cflags += -arch x86_64 asmflags += -arch x86_64 lflags += -arch x86_64 @@ -532,8 +544,8 @@ vg: build .PHONY: test test: build - /bin/sh $(test)/test.sh 2>/dev/null \ - $(build) $(test-executable) $(mode) "$(test-flags)" \ + $(library-path) /bin/sh $(test)/test.sh 2>/dev/null \ + $(test-executable) $(mode) "$(test-flags)" \ $(call class-names,$(test-build),$(test-classes)) .PHONY: tarball @@ -770,7 +782,7 @@ ifdef msvc -PDB:$(@).pdb -IMPLIB:$(@).lib $(<) -out:$(@) -MANIFESTFILE:$(@).manifest $(mt) -manifest $(@).manifest -outputresource:"$(@);1" else - $(ld) $(<) $(jvm-flags) $(lflags) -o $(@) + $(ld) $(<) -L$(build) -ljvm $(lflags) -o $(@) endif $(strip) $(strip-all) $(@) diff --git a/openjdk-src.mk b/openjdk-src.mk index 1c2e62d0cd..84b6c91786 100644 --- a/openjdk-src.mk +++ b/openjdk-src.mk @@ -127,6 +127,12 @@ openjdk-cflags = \ -DJDK_BUILD_NUMBER=\"0\" \ -D_GNU_SOURCE +ifeq ($(platform),darwin) + openjdk-cflags += \ + -D_LFS_LARGEFILE=1 \ + -D_ALLBSD_SOURCE +endif + ifeq ($(platform),windows) openjdk-sources += \ $(openjdk-src)/windows/native/java/io/canonicalize_md.c \ diff --git a/src/classpath-openjdk.cpp b/src/classpath-openjdk.cpp index 13cab76928..8d6c5994a5 100644 --- a/src/classpath-openjdk.cpp +++ b/src/classpath-openjdk.cpp @@ -52,9 +52,6 @@ # define EXPORT(x) _##x # endif -# define LIBRARY_PREFIX "" -# define LIBRARY_SUFFIX ".dll" - typedef int socklen_t; #else // not PLATFORM_WINDOWS @@ -78,9 +75,6 @@ typedef int socklen_t; # define EXPORT(x) x -# define LIBRARY_PREFIX "lib" -# define LIBRARY_SUFFIX ".so" - #endif // not PLATFORM_WINDOWS using namespace vm; @@ -245,9 +239,9 @@ class MyClasspath : public Classpath { this->zipLibrary = sb.pointer; sb.append(this->libraryPath); sb.append("/"); - sb.append(LIBRARY_PREFIX); + sb.append(SO_PREFIX); sb.append("zip"); - sb.append(LIBRARY_SUFFIX); + sb.append(SO_SUFFIX); sb.append('\0'); this->tzMappings = sb.pointer; diff --git a/src/common.h b/src/common.h index 6ab13f23ec..7cf95a85e3 100644 --- a/src/common.h +++ b/src/common.h @@ -132,7 +132,7 @@ typedef uint64_t uintptr_t; #endif #ifdef __APPLE__ -# define SO_SUFFIX ".jnilib" +# define SO_SUFFIX ".dylib" #elif defined PLATFORM_WINDOWS # define SO_SUFFIX ".dll" #else diff --git a/src/posix.cpp b/src/posix.cpp index cf7d600bb5..e72587eea6 100644 --- a/src/posix.cpp +++ b/src/posix.cpp @@ -719,7 +719,7 @@ class MySystem: public System { } virtual const char* libraryPrefix() { - return "lib"; + return SO_PREFIX; } virtual const char* librarySuffix() { diff --git a/src/windows.cpp b/src/windows.cpp index 405d626d82..8b93f96e5c 100644 --- a/src/windows.cpp +++ b/src/windows.cpp @@ -716,7 +716,7 @@ class MySystem: public System { } virtual const char* libraryPrefix() { - return ""; + return SO_PREFIX; } virtual const char* librarySuffix() { diff --git a/test/test.sh b/test/test.sh index 786c9e24c0..72d7734832 100644 --- a/test/test.sh +++ b/test/test.sh @@ -4,7 +4,6 @@ log=build/log.txt vg="nice valgrind --leak-check=full --num-callers=32 \ --freelist-vol=100000000 --error-exitcode=1" -library_path=${1}; shift vm=${1}; shift mode=${1}; shift flags=${1}; shift @@ -19,10 +18,10 @@ for test in ${tests}; do case ${mode} in debug|debug-fast|fast|small ) - LD_LIBRARY_PATH=${library_path} ${vm} ${flags} ${test} >>${log} 2>&1;; + ${vm} ${flags} ${test} >>${log} 2>&1;; stress* ) - LD_LIBRARY_PATH=${library_path} ${vg} ${vm} ${flags} ${test} \ + ${vg} ${vm} ${flags} ${test} \ >>${log} 2>&1;; * )