NetBSD-Java archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

patches for native jdk6 on amd64



Attached is a bunch of patches to make sun jdk6 build and run
on -current NetBSD/amd64.

Patch Sun sources first with patches from

        http://www.eyesbeyond.com/freebsddom/java/jdk16.html

and then apply the attached patches, and follow the build instructions
from FreeBSD patches to build JDK. You don't need libiconv, but you
do need CUPS installed to build (or at least CUPS headers available).

The patches do this:

 - All /usr/X11R6 replaced with /usr/pkg
 - Two -L$(X11DIR) fixed to -L$(X11DIR)/lib
 - Dropped libiconv requirement
 - Added required definitions for NetBSD/amd64 to plugin and vm
   build
 - Fixed build of unpack200 binary to happen with $ORIGIN in
   rpath.
 - Don't add "soname=lib.so" to all executables
 - On NetBSD NAWK=awk

 - A few installation image builds change to use pax instead of cpio.
   The reason for this is some bug in NetBSD cpio, or more likely
   fts-family functions in libc (I built a test version of cpio with
   a few printfs here and there, and came to the conclusion that the
   bug is in fts).

   What happened is that a find command produced a list of files
   that cpio read from stdin. On every run, either through java build
   infrastructure, or manually running the commands, cpio failed in
   exactly the same way at exactly the same location. Two of the
   file names read with fts_read had been truncated, and apparently
   garbled: before NUL byte there was a byte with value 4.

   From buildlog:

cpio: Unable to open ./lib/desktop/icons/Hi^D to read (No such file or directory) cpio: Unable to open ./lib/desktop/icons/Hi^D to read (No such file or directory)

   The "^D" is rendered by vim, meaning byte with value 4.
   The actual file name continued for 20-30 characters after "Hi".
--- ./deploy/make/common/Defs-bsd.gmk   2007-11-27 21:07:58.000000000 +0200
+++ ../jdk16/deploy/make/common/Defs-bsd.gmk    2007-11-27 20:26:05.000000000 
+0200
@@ -23,7 +23,7 @@
 JUMP_EXE       = $(BIN_DIR)/javaws
 CLASSPATH_SEP  = $(CLASSPATH_SEPARATOR)
 PATH_SEP       = /
-X11DIR         = /usr/X11R6
+X11DIR         = /usr/pkg
 LOCALDIR       = /usr/local
 ifneq ($(OS_VENDOR), NetBSD)
 LIBS           = -L$(X11DIR)/lib -lX11 -L$(LOCALDIR)/lib -liconv
--- ./deploy/make/common/Release.gmk    2007-11-27 21:07:58.000000000 +0200
+++ ../jdk16/deploy/make/common/Release.gmk     2007-11-28 00:00:55.000000000 
+0200
@@ -255,7 +255,7 @@
          $(CP) $(DEPLOY_COMMON_JAR) $(TMP_DEPLOY_IMAGE_DIR)/lib/; \
        fi
        @# Now copy plugin image into the jre image
-       $(CD) $(TMP_DEPLOY_IMAGE_DIR) ; $(FIND) . -depth -print | $(CPIO) -pdum 
$(JRE_IMAGE_DIR)
+       $(CD) $(TMP_DEPLOY_IMAGE_DIR) ; pax -rw -pe . $(JRE_IMAGE_DIR)
        @# all done with plugin image
 
 ######################################################
@@ -266,7 +266,7 @@
        @# Grab tmp-plugin-jre.
        @#
        $(MKDIR) -p $(JDK_IMAGE_DIR)/jre
-       $(CD) $(TMP_DEPLOY_IMAGE_DIR) ; $(FIND) . -depth -print | $(CPIO) -pdum 
$(JDK_IMAGE_DIR)/jre
+       $(CD) $(TMP_DEPLOY_IMAGE_DIR) ; pax -rw -pe . $(JDK_IMAGE_DIR)/jre
        @#
        $(MKDIR) -p $(JDK_IMAGE_DIR)/bin
        if [ -r $(BINDIR)/HtmlConverter$(EXE_SUFFIX) ]; then \
--- ./deploy/make/plugin/adapter/oji-adapter/Makefile   2007-11-27 
21:07:58.000000000 +0200
+++ ../jdk16/deploy/make/plugin/adapter/oji-adapter/Makefile    2007-11-27 
20:21:58.000000000 +0200
@@ -44,7 +44,7 @@
 LIB_LOCATION=$(OUTPUTDIR)/plugin/$(LIBARCH)/ns7
 dummy:=$(shell $(MKDIR) -p $(LIB_LOCATION))
 
-X11DIR = /usr/X11R6
+X11DIR = /usr/pkg
 
 ifeq ($(PLATFORM), solaris)
 LDLIBS = -lX11 -ldl -lCrun -lc
@@ -55,7 +55,7 @@
 endif
 
 ifeq ($(PLATFORM), bsd)
-LDLIBS = -L$(X11DIR) -lX11
+LDLIBS = -L$(X11DIR)/lib -lX11
 endif
 
 ifeq ($(ARCH_DATA_MODEL), 64)
--- ./deploy/make/plugin/jvmnative/Makefile     2007-11-27 21:07:58.000000000 
+0200
+++ ../jdk16/deploy/make/plugin/jvmnative/Makefile      2007-11-27 
20:18:55.000000000 +0200
@@ -14,7 +14,7 @@
 
 include $(DEPLOY_TOPDIR)/make/plugin/common/Defs.gmk
 
-X11DIR = /usr/X11R6
+X11DIR = /usr/pkg
 
 ifeq ($(PLATFORM), bsd)
 LDLIBS = -L$(X11DIR)/lib -lX11
--- ./deploy/make/plugin/nscore/unix/Makefile   2007-11-27 21:07:58.000000000 
+0200
+++ ../jdk16/deploy/make/plugin/nscore/unix/Makefile    2007-11-27 
20:21:06.000000000 +0200
@@ -16,7 +16,7 @@
 
 include $(DEPLOY_TOPDIR)/make/plugin/common/Defs.gmk
 
-X11DIR = /usr/X11R6
+X11DIR = /usr/pkg
 
 ifeq ($(PLATFORM), linux)
 LDLIBS = -lX11 -ldl -lc
@@ -29,7 +29,7 @@
 endif
 
 ifeq ($(PLATFORM), bsd)
-LDLIBS = -L$(X11DIR) -lX11
+LDLIBS = -L$(X11DIR)/lib -lX11
 PLATFORM_DEFINE = _ALLBSD_SOURCE
 endif
 
--- ./deploy/src/plugin/share/plugin/mozilla_headers_18/nspr/md/_netbsd.cfg     
2007-11-27 21:07:22.000000000 +0200
+++ 
../jdk16/deploy/src/plugin/share/plugin/mozilla_headers_18/nspr/md/_netbsd.cfg  
    2007-11-27 22:23:09.000000000 +0200
@@ -234,6 +234,54 @@
 #define PR_BYTES_PER_WORD_LOG2   2
 #define PR_BYTES_PER_DWORD_LOG2  3
 
+#elif defined(__amd64__)
+
+#define IS_LITTLE_ENDIAN 1
+#undef  IS_BIG_ENDIAN
+#define        HAVE_LONG_LONG
+#define        HAVE_ALIGNED_DOUBLES
+#define        HAVE_ALIGNED_LONGLONGS
+#define IS_64
+
+#define PR_BYTES_PER_BYTE   1
+#define PR_BYTES_PER_SHORT  2
+#define PR_BYTES_PER_INT    4
+#define PR_BYTES_PER_INT64  8
+#define PR_BYTES_PER_LONG   8
+#define PR_BYTES_PER_FLOAT  4
+#define PR_BYTES_PER_DOUBLE 8
+#define PR_BYTES_PER_WORD   8
+#define PR_BYTES_PER_DWORD  8
+#define PR_BYTES_PER_WORD_LOG2   3
+#define PR_BYTES_PER_DWORD_LOG2  3
+
+#define PR_BITS_PER_BYTE    8
+#define PR_BITS_PER_SHORT   16
+#define PR_BITS_PER_INT     32
+#define PR_BITS_PER_INT64   64
+#define PR_BITS_PER_LONG    64
+#define PR_BITS_PER_FLOAT   32
+#define PR_BITS_PER_DOUBLE  64
+#define PR_BITS_PER_WORD    64
+
+#define PR_BITS_PER_BYTE_LOG2   3
+#define PR_BITS_PER_SHORT_LOG2  4
+#define PR_BITS_PER_INT_LOG2    5
+#define PR_BITS_PER_INT64_LOG2  6
+#define PR_BITS_PER_LONG_LOG2   6
+#define PR_BITS_PER_FLOAT_LOG2  5
+#define PR_BITS_PER_DOUBLE_LOG2 6
+#define PR_BITS_PER_WORD_LOG2   6
+
+#define PR_ALIGN_OF_SHORT   2
+#define PR_ALIGN_OF_INT     4
+#define PR_ALIGN_OF_LONG    8
+#define PR_ALIGN_OF_INT64   8
+#define PR_ALIGN_OF_FLOAT   4
+#define PR_ALIGN_OF_DOUBLE  8
+#define PR_ALIGN_OF_POINTER 8
+#define PR_ALIGN_OF_WORD    8
+
 #else
 
 #error Must define constants for type sizes here.
--- ./hotspot/src/os_cpu/bsd_amd64/vm/bytes_bsd_amd64.inline.hpp        
2007-11-27 21:07:59.000000000 +0200
+++ ../jdk16/hotspot/src/os_cpu/bsd_amd64/vm/bytes_bsd_amd64.inline.hpp 
2007-11-27 20:51:40.000000000 +0200
@@ -13,6 +13,8 @@
 {
 #ifdef __OpenBSD__
   return swap16(x);
+#elif defined(__NetBSD__)
+  return bswap16(x);
 #else
   return __bswap16(x);
 #endif
@@ -22,6 +24,8 @@
 {
 #ifdef __OpenBSD__
   return swap32(x);
+#elif defined(__NetBSD__)
+  return bswap32(x);
 #else
   return __bswap32(x);
 #endif
@@ -31,6 +35,8 @@
 {
 #ifdef __OpenBSD__
   return swap64(x);
+#elif defined(__NetBSD__)
+  return bswap64(x);
 #else
   return __bswap64(x);
 #endif
--- ./hotspot/src/os_cpu/bsd_amd64/vm/os_bsd_amd64.cpp  2007-11-27 
21:07:59.000000000 +0200
+++ ../jdk16/hotspot/src/os_cpu/bsd_amd64/vm/os_bsd_amd64.cpp   2007-11-27 
21:03:12.000000000 +0200
@@ -21,7 +21,9 @@
 #include <unistd.h>
 #include <sys/resource.h>
 #include <pthread.h>
+#ifndef        __NetBSD__
 #include <pthread_np.h>
+#endif
 #include <sys/stat.h>
 #include <sys/time.h>
 #include <sys/utsname.h>
@@ -76,6 +78,30 @@
 #  define context_err sc_err
 # endif
 
+# ifdef __NetBSD__
+#  define context_rip uc_mcontext.__gregs[_REG_RIP]
+#  define context_rsp uc_mcontext.__gregs[_REG_URSP]
+#  define context_rax uc_mcontext.__gregs[_REG_RAX]
+#  define context_rbx uc_mcontext.__gregs[_REG_RBX]
+#  define context_rcx uc_mcontext.__gregs[_REG_RCX]
+#  define context_rdx uc_mcontext.__gregs[_REG_RDX]
+#  define context_rbp uc_mcontext.__gregs[_REG_RBP]
+#  define context_rsi uc_mcontext.__gregs[_REG_RSI]
+#  define context_rdi uc_mcontext.__gregs[_REG_RDI]
+#  define context_r8  uc_mcontext.__gregs[_REG_R8]
+#  define context_r9  uc_mcontext.__gregs[_REG_R9]
+#  define context_r10 uc_mcontext.__gregs[_REG_R10]
+#  define context_r11 uc_mcontext.__gregs[_REG_R11]
+#  define context_r12 uc_mcontext.__gregs[_REG_R12]
+#  define context_r13 uc_mcontext.__gregs[_REG_R13]
+#  define context_r14 uc_mcontext.__gregs[_REG_R14]
+#  define context_r15 uc_mcontext.__gregs[_REG_R15]
+#  define context_flags uc_mcontext.__gregs[_REG_RFL]
+#  define context_trapno uc_mcontext.__gregs[_REG_TRAPNO]
+#  define context_err uc_mcontext.__gregs[_REG_ERR]
+typedef __greg_t __register_t;
+# endif
+
 address os::current_stack_pointer()
 {
   register void *rsp __asm__ ("rsp");
--- ./j2se/make/com/sun/java/pack/Makefile      2007-11-27 21:07:59.000000000 
+0200
+++ ../jdk16/j2se/make/com/sun/java/pack/Makefile       2007-11-28 
02:05:34.000000000 +0200
@@ -114,9 +114,21 @@
        $(ECHO) "Resource files not required for Unix"
 endif
 
+# Avoid $ORIGIN in rpath for the executable on NetBSD
+# This is the only Makefile to build lib and executable, and the executable
+# in a funny way?
+ifeq ($(PLATFORM), bsd)
+  ifeq ($(OS_VENDOR), NetBSD)
+    EXELINKER=$(subst -Xlinker -rpath -Xlinker \$$ORIGIN,,$(LINKER))
+  endif
+else
+EXELINKER=$(LINKER)
+endif
+
 $(UNPACK_EXE): $(UNPACK_EXE_FILES_o) winres 
        $(prep-target)
-       $(LINKER)  $(LDDFLAGS) $(UNPACK_EXE_FILES_o) $(RES) $(LIBCXX) 
$(LDOUTPUT)$(TEMPDIR)/unpack200$(EXE_SUFFIX)
+       echo unpack200 $(LINKER)
+       $(EXELINKER)  $(LDDFLAGS) $(UNPACK_EXE_FILES_o) $(RES) $(LIBCXX) 
$(LDOUTPUT)$(TEMPDIR)/unpack200$(EXE_SUFFIX)
        $(CP) $(TEMPDIR)/unpack200$(EXE_SUFFIX) $(UNPACK_EXE)
 
 
--- ./j2se/make/common/Defs-bsd.gmk     2007-11-27 21:07:59.000000000 +0200
+++ ../jdk16/j2se/make/common/Defs-bsd.gmk      2007-11-28 01:09:58.000000000 
+0200
@@ -213,7 +213,9 @@
 #
 LDFLAGS_OPT     =
 LDFLAGS_COMMON += -L$(LIBDIR)/$(LIBARCH)
+ifdef LIBRARY
 LDFLAGS_COMMON += -Wl,-soname=$(LIB_PREFIX)$(LIBRARY).$(LIBRARY_SUFFIX)
+endif
 LDFLAGS_DBG     =
 
 #
@@ -298,7 +300,7 @@
 override LIBTHREAD               =
 override MOOT_PRIORITIES         = true
 override NO_INTERRUPTIBLE_IO     = false
-override OPENWIN_HOME            = /usr/X11R6
+override OPENWIN_HOME            = /usr/pkg
 override OPENWIN_LIB             = $(OPENWIN_HOME)/lib
 override OTHER_M4FLAGS           = -D__GLIBC__ -DGNU_ASSEMBLER
 override SUN_CMM_SUBDIR          =
--- ./j2se/make/common/Release.gmk      2007-11-27 21:07:59.000000000 +0200
+++ ../jdk16/j2se/make/common/Release.gmk       2007-11-27 23:29:58.000000000 
+0200
@@ -783,8 +783,7 @@
        $(RM) -r $(JDK_IMAGE_DIR)
        $(MKDIR) -p $(JDK_IMAGE_DIR)/jre
        @# Copy in jre directory
-       $(CD) $(JRE_IMAGE_DIR) ; $(FIND) . -depth -print \
-             | $(CPIO) -pdum $(JDK_IMAGE_DIR)/jre
+       $(CD) $(JRE_IMAGE_DIR) ; pax -rw -pe . $(JDK_IMAGE_DIR)/jre
        @# Make sure all directories are read/execute for everyone
        $(CHMOD) a+rx `$(FIND) $(JDK_IMAGE_DIR) -type d`
        $(RM) -rf $(JDK_IMAGE_DIR)/jre/man
--- ./j2se/make/common/shared/Defs-utils.gmk    2007-11-27 21:07:59.000000000 
+0200
+++ ../jdk16/j2se/make/common/shared/Defs-utils.gmk     2007-11-27 
20:30:45.000000000 +0200
@@ -173,4 +173,5 @@
 # BSD specific
 ifeq ($(SYSTEM_UNAME),NetBSD)
   ECHO = echo -e
+  NAWK           = $(USRBIN_PATH)awk
 endif
--- ./j2se/make/java/instrument/Makefile        2007-11-27 21:07:59.000000000 
+0200
+++ ../jdk16/j2se/make/java/instrument/Makefile 2007-11-27 21:16:55.000000000 
+0200
@@ -106,13 +106,11 @@
 endif # PLATFORM
 
 ifeq ($(PLATFORM), bsd)
-  ifeq ($(OS_VENDOR), NetBSD)
-    ICONV_DIR = /usr/pkg
-  else
+  ifneq ($(OS_VENDOR), NetBSD)
     ICONV_DIR = /usr/local
+    CPPFLAGS += -I$(ICONV_DIR)/include
+    OTHER_LDLIBS += -L$(ICONV_DIR)/lib -liconv
   endif
-  CPPFLAGS += -I$(ICONV_DIR)/include
-  OTHER_LDLIBS += -L$(ICONV_DIR)/lib -liconv
 endif
 
 #
--- ./j2se/make/java/npt/Makefile       2007-11-27 21:07:59.000000000 +0200
+++ ../jdk16/j2se/make/java/npt/Makefile        2007-11-27 21:13:19.000000000 
+0200
@@ -69,13 +69,11 @@
 
 # Add location of iconv headers
 ifeq ($(PLATFORM), bsd)
-  ifeq ($(OS_VENDOR), NetBSD)
-    ICONV_DIR = /usr/pkg
-  else
+  ifneq ($(OS_VENDOR), NetBSD)
     ICONV_DIR = /usr/local
+    CPPFLAGS += -I$(ICONV_DIR)/include
+    OTHER_LDLIBS += -L$(ICONV_DIR)/lib -liconv
   endif
-  CPPFLAGS += -I$(ICONV_DIR)/include
-  OTHER_LDLIBS += -L$(ICONV_DIR)/lib -liconv
 endif
 
 #
--- ./j2se/make/sun/awt/mawt.gmk        2007-11-27 21:07:59.000000000 +0200
+++ ../jdk16/j2se/make/sun/awt/mawt.gmk 2007-11-27 21:58:25.000000000 +0200
@@ -227,8 +227,8 @@
 endif
 
 ifeq ($(PLATFORM), bsd)
-  CPPFLAGS += -I/usr/X11R6/include/X11/extensions \
-              -I/usr/X11R6/include
+  CPPFLAGS += -I/usr/pkg/include/X11/extensions \
+              -I/usr/pkg/include
 endif
 
 LDFLAGS += -L$(LIBDIR)/$(LIBARCH)/$(TSOBJDIR) \
--- ./j2se/make/sun/font/Makefile       2007-11-27 21:07:59.000000000 +0200
+++ ../jdk16/j2se/make/sun/font/Makefile        2007-11-27 20:22:30.000000000 
+0200
@@ -123,7 +123,7 @@
 
 # setup the list of libraries to link in...
 ifeq ($(PLATFORM), bsd)
-OTHER_INCLUDES += -I/usr/X11R6/include
+OTHER_INCLUDES += -I/usr/pkg/include
 OTHER_LDLIBS  += -lawt $(LIBM) $(LIBCXX)
 else
 ifeq ($(PLATFORM), linux)
--- ./j2se/make/sun/splashscreen/Makefile       2007-11-27 21:07:59.000000000 
+0200
+++ ../jdk16/j2se/make/sun/splashscreen/Makefile        2007-11-27 
21:16:11.000000000 +0200
@@ -46,15 +46,17 @@
 ifneq ($(PLATFORM), windows)
   CFLAGS += -DWITH_X11
   ifeq ($(PLATFORM), bsd)
-    ifeq ($(OS_VENDOR), NetBSD)
-      ICONV_DIR = /usr/pkg
-    else
-      ICONV_DIR = /usr/local
-    endif
     CPPFLAGS += -I$(OPENWIN_HOME)/include \
                 -I$(OPENWIN_HOME)/include/X11/extensions \
                -I$(ICONV_DIR)/include
-    OTHER_LDLIBS += -L$(OPENWIN_LIB) -lX11 -lXext -L$(ICONV_DIR)/lib -liconv 
$(LIBM) -pthread
+    OTHER_LDLIBS += -L$(OPENWIN_LIB) -lX11 -lXext
+    ifneq ($(OS_VENDOR), NetBSD)
+      ICONV_DIR = /usr/local
+      OTHER_LDLIBS += -L$(ICONV_DIR)/lib -liconv
+    else
+      OTHER_LDLIBS += -Wl,-R$(OPENWIN_LIB)
+    endif
+    OTHER_LDLIBS += $(LIBM) -pthread
   else
     CPPFLAGS += -I$(OPENWIN_HOME)/include 
-I$(OPENWIN_HOME)/include/X11/extensions
     OTHER_LDLIBS += -L$(OPENWIN_LIB) -lX11 -lXext $(LIBM) -lpthread


Home | Main Index | Thread Index | Old Index