The attached patch adds support for building zero for the x86_64-linux-gnux32
target, having changes in the build system, hotspot and jdk.

 - the build system currently only derives the target from
   the cpu in PLATFORM_EXTRACT_VARS_FROM_CPU; that is not enough
   for the new target, which only differs by the ending of the
   triplet. However the $host macro should be available anywhere.

 - the hotspot part just handles the new "cpu"

 - GensrcX11Wrappers.gmk assumes that there is a black/white
   decision about -m32/-m64. The patch works around it.  However
   the real patch should be to get these flags from the build
   system, and not hardcode itself.

 - the sysctl system call is unsupported in the x32 kernel, and
   just the include leads to a build error.  From my point of view
   the header is not needed. I had successful builds on all other
   targets without including it. If you want to keep the include,
   then it should be guarded with
   #if !(defined(_ILP32) && defined(__x86_64__))

Matthias
Index: b/jdk/src/java.base/unix/native/libnet/PlainDatagramSocketImpl.c
===================================================================
--- a/jdk/src/java.base/unix/native/libnet/PlainDatagramSocketImpl.c
+++ b/jdk/src/java.base/unix/native/libnet/PlainDatagramSocketImpl.c
@@ -41,7 +41,6 @@
 #endif
 #ifdef __linux__
 #include <unistd.h>
-#include <sys/sysctl.h>
 #include <sys/utsname.h>
 #include <netinet/ip.h>
 
Index: b/jdk/src/java.base/unix/native/libnet/PlainSocketImpl.c
===================================================================
--- a/jdk/src/java.base/unix/native/libnet/PlainSocketImpl.c
+++ b/jdk/src/java.base/unix/native/libnet/PlainSocketImpl.c
@@ -43,7 +43,6 @@
 #endif
 #ifdef __linux__
 #include <unistd.h>
-#include <sys/sysctl.h>
 #endif
 
 #include "jvm.h"
Index: b/jdk/make/gensrc/GensrcX11Wrappers.gmk
===================================================================
--- a/jdk/make/gensrc/GensrcX11Wrappers.gmk
+++ b/jdk/make/gensrc/GensrcX11Wrappers.gmk
@@ -91,9 +91,11 @@ ifneq ($(COMPILE_TYPE), cross)
 	$(TOOL_WRAPPERGENERATOR) $(@D) $(GENSRC_SIZER_DIR)/xlibtypes.txt "sizer" $*
 
   # use -m32/-m64 only if the compiler supports it
+  ifneq ($(OPENJDK_TARGET_CPU),x32)
   ifeq ($(COMPILER_SUPPORTS_TARGET_BITS_FLAG), true)
     MEMORY_MODEL_FLAG="$(COMPILER_TARGET_BITS_FLAG)$*"
   endif
+  endif
 
   SIZER_CFLAGS := \
       -I$(JDK_TOPDIR)/src/java.base/share/native/include \
Index: b/hotspot/src/os/linux/vm/os_linux.cpp
===================================================================
--- a/hotspot/src/os/linux/vm/os_linux.cpp
+++ b/hotspot/src/os/linux/vm/os_linux.cpp
@@ -1782,7 +1782,7 @@ void * os::dll_load(const char *filename
 
 #if  (defined IA32)
   static  Elf32_Half running_arch_code=EM_386;
-#elif   (defined AMD64)
+#elif   (defined AMD64) || defined(X32)
   static  Elf32_Half running_arch_code=EM_X86_64;
 #elif  (defined IA64)
   static  Elf32_Half running_arch_code=EM_IA_64;
Index: b/common/autoconf/platform.m4
===================================================================
--- a/common/autoconf/platform.m4
+++ b/common/autoconf/platform.m4
@@ -35,6 +35,10 @@ AC_DEFUN([PLATFORM_EXTRACT_VARS_FROM_CPU
       VAR_CPU_ARCH=x86
       VAR_CPU_BITS=64
       VAR_CPU_ENDIAN=little
+      case "$host" in *x32)
+        VAR_CPU=x32
+        VAR_CPU_BITS=32
+      esac
       ;;
     i?86)
       VAR_CPU=x86
@@ -496,6 +500,8 @@ AC_DEFUN([PLATFORM_SETUP_LEGACY_VARS_HEL
     HOTSPOT_$1_CPU_DEFINE=IA32
   elif test "x$OPENJDK_$1_CPU" = xx86_64; then
     HOTSPOT_$1_CPU_DEFINE=AMD64
+  elif test "x$OPENJDK_$1_CPU" = xx32; then
+    HOTSPOT_$1_CPU_DEFINE=X32
   elif test "x$OPENJDK_$1_CPU" = xsparcv9; then
     HOTSPOT_$1_CPU_DEFINE=SPARC
   elif test "x$OPENJDK_$1_CPU" = xaarch64; then

Reply via email to