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

Re: Porting src:openjdk-6 to m68k (II)



Dixi quod…

>after my thread from June or so, I’ve started another attempt at
>building src:openjdk-6 on m68k. Below is my preliminary patch;

OK, the patch below changes atomics to use GCC’s, but the problem
with OpenJDK is not the same as with Qt: even today, with the fixed
kernel/eglibc, I get the same result: busy-spin with assembly atomics,
idle-spin (better!) with GCC atomics.

Considering GHC also wasn’t fixed by the kernel/eglibc changes, my
guess is that both (GHC and OpenJDK) have their own code generation
code somewhere, not using GCC as backend (not really unlikely). I’ve
got no idea what to say to the fact that openjdk-ecj works, but the
non-ecj one built from that doesn’t.

Any ideas how to go on from this? I have access to that chroot, can
play gdb remote hands or do other tests. Full build log attached.

diff -u openjdk-6-6b24-1.11.5/debian/changelog openjdk-6-6b24-1.11.5/debian/changelog
--- openjdk-6-6b24-1.11.5/debian/changelog
+++ openjdk-6-6b24-1.11.5/debian/changelog
@@ -1,3 +1,13 @@
+openjdk-6 (6b24-1.11.5-1+m68k.2) unreleased; urgency=low
+
+  * patches/text-relocations.patch: build with -fPIC on m68k
+  * debian/rules: fix gcj-$V-jdk B-D for 4.6 architectures
+    (was s390; add m68k as one)
+  * debian/control: regenerate
+  * debian/patches/m68k-use-gcc-atomic-builtins.patch: new
+
+ -- Thorsten Glaser <tg@mirbsd.de>  Thu, 29 Nov 2012 16:05:30 +0100
+
 openjdk-6 (6b24-1.11.5-1) unstable; urgency=low
 
   * Upload to unstable.
diff -u openjdk-6-6b24-1.11.5/debian/control openjdk-6-6b24-1.11.5/debian/control
--- openjdk-6-6b24-1.11.5/debian/control
+++ openjdk-6-6b24-1.11.5/debian/control
@@ -3,7 +3,7 @@
 Priority: optional
 Maintainer: OpenJDK Team <openjdk@lists.launchpad.net>
 Uploaders: Torsten Werner <twerner@debian.org>, Matthias Klose <doko@ubuntu.com>, Damien Raude-Morvan <drazzib@debian.org>
-Build-Depends: debhelper (>= 5), binutils-dev [armel armhf], m4, lsb-release, wget, zip, unzip, sharutils, gawk, cpio, pkg-config, procps, time, fastjar (>= 2:0.96-0ubuntu2),  autoconf, automake, autotools-dev, ant, ant-optional, libtool [alpha amd64 armel armhf i386 lpia m68k mips mipsel powerpc s390], g++-4.7,  ecj-gcj [alpha amd64 armel armhf hppa i386 ia64 lpia powerpc powerpcspe ppc64 m68k mips mipsel sh4 sparc sparc64 s390 s390x], gcj-4.7-jdk [alpha amd64 armel armhf hppa i386 ia64 lpia powerpc powerpcspe ppc64 m68k mips mipsel sh4 sparc sparc64 s390 s390x], gcj-jdk [alpha amd64 armel armhf hppa i386 ia64 lpia powerpc powerpcspe ppc64 m68k mips mipsel sh4 sparc sparc64 s390 s390x], g++-4.4 [mips mipsel], gcj-4.6-jdk [s390], libxtst-dev, libxi-dev, libxt-dev, libxaw7-dev, libxrender-dev, libcups2-dev, libasound2-dev, libfreetype6-dev (>= 2.2.1), libgtk2.0-dev, libxinerama-dev, xsltproc, rhino, fonts-ipafont-mincho, libffi-dev,  zlib1g-dev, libpng-dev, libjpeg8-dev, libgif-dev, libpulse-dev (>= 0.9.12), libnss3-dev (>= 3.12.3),  mauve, xvfb, xauth, xfonts-base, libgl1-mesa-dri, twm | metacity, twm | dbus-x11, x11-xkb-utils,
+Build-Depends: debhelper (>= 5), binutils-dev [armel armhf], m4, lsb-release, wget, zip, unzip, sharutils, gawk, cpio, pkg-config, procps, time, fastjar (>= 2:0.96-0ubuntu2),  autoconf, automake, autotools-dev, ant, ant-optional, libtool [alpha amd64 armel armhf i386 lpia m68k mips mipsel powerpc s390], g++-4.7,  ecj-gcj [alpha amd64 armel armhf hppa i386 ia64 lpia powerpc powerpcspe ppc64 m68k mips mipsel sh4 sparc sparc64 s390 s390x], gcj-4.6-jdk [m68k s390], gcj-4.7-jdk [alpha amd64 armel armhf hppa i386 ia64 lpia powerpc powerpcspe ppc64 mips mipsel sh4 sparc sparc64 s390x], gcj-jdk [alpha amd64 armel armhf hppa i386 ia64 lpia powerpc powerpcspe ppc64 m68k mips mipsel sh4 sparc sparc64 s390 s390x], g++-4.4 [mips mipsel], libxtst-dev, libxi-dev, libxt-dev, libxaw7-dev, libxrender-dev, libcups2-dev, libasound2-dev, libfreetype6-dev (>= 2.2.1), libgtk2.0-dev, libxinerama-dev, xsltproc, rhino, fonts-ipafont-mincho, libffi-dev,  zlib1g-dev, libpng-dev, libjpeg8-dev, libgif-dev, libpulse-dev (>= 0.9.12), libnss3-dev (>= 3.12.3),  mauve, xvfb, xauth, xfonts-base, libgl1-mesa-dri, twm | metacity, twm | dbus-x11, x11-xkb-utils,
 Standards-Version: 3.9.3
 Homepage: http://openjdk.java.net/
 Vcs-Bzr: http://bazaar.launchpad.net/~openjdk/openjdk/openjdk6
@@ -31,7 +31,7 @@
 Pre-Depends: ${dpkg:Depends}, ${multiarch:Depends}
 Depends: openjdk-6-jre-lib (= ${source:Version}), ${jredefault:Depends}, ${cacert:Depends}, ${tzdata:Depends}, ${jcommon:Depends}, ${dlopenhl:Depends}, ${shlibs:Depends}, ${misc:Depends}
 Recommends: ${dlopenjl:Recommends}, ${cacao:Recommends}, ${jamvm:Recommends}
-Suggests: libnss-mdns, sun-java6-fonts, ttf-dejavu-extra, fonts-ipafont-gothic, fonts-ipafont-mincho, ttf-wqy-microhei | ttf-wqy-zenhei, ttf-indic-fonts,
+Suggests: libnss-mdns, sun-java6-fonts, ttf-dejavu-extra, fonts-ipafont-gothic, fonts-ipafont-mincho, ttf-wqy-microhei | ttf-wqy-zenhei, ttf-indic-fonts-core, ttf-telugu-fonts, ttf-oriya-fonts, ttf-kannada-fonts, ttf-bengali-fonts,
 Provides: java-runtime-headless, java2-runtime-headless, java5-runtime-headless, java6-runtime-headless, ${defaultvm:Provides}, ${jvm:Provides}
 Replaces: openjdk-6-jre-lib (<< 6b23~pre10), openjdk-6-jre (<< 6b23~pre1), openjdk-6-jdk (<< 6b20-1.9.1-0ubuntu2)
 Conflicts: ${multiarch:Conflicts}, openjdk-6-jre-lib (<< 6b17~pre3-1), openjdk-6-jre (<< 6b17~pre3-1), openjdk-6-jdk (<< 6b17~pre3-1), openjdk-6-demo (<< 6b17~pre3-1), openjdk-6-source (<< 6b17~pre3-1), openjdk-6-doc (<< 6b17~pre3-1), openjdk-6-dbg (<< 6b17~pre3-1), openjdk-6-jre-zero (<< 6b17~pre3-1)
diff -u openjdk-6-6b24-1.11.5/debian/rules openjdk-6-6b24-1.11.5/debian/rules
--- openjdk-6-6b24-1.11.5/debian/rules
+++ openjdk-6-6b24-1.11.5/debian/rules
@@ -230,7 +230,7 @@
   ifneq (,$(filter $(DEB_HOST_ARCH), mips mipsel))
     export GCC_SUFFIX = -4.4
   endif
-  ifneq (,$(filter $(DEB_HOST_ARCH), s390))
+  ifneq (,$(filter $(DEB_HOST_ARCH), m68k s390))
     export GCJ_SUFFIX = -4.6
   endif
 else ifneq (,$(filter $(distrel),oneiric))
@@ -419,6 +419,8 @@
 	debian/patches/alpha-float-const.diff
 endif
 
+DISTRIBUTION_PATCHES += debian/patches/m68k-use-gcc-atomic-builtins.patch
+
 export DISTRIBUTION_PATCHES DISTRIBUTION_ECJ_PATCHES
 
 ifeq ($(STAGE1_JAVA),gcj)
@@ -582,11 +584,14 @@
     bd_bootstrap += gcc-snapshot (>= 20100403-1~dapper3),
     #bd_bootstrap += gcj-4.4-jdk,
   else ifneq (,$(filter $(distrel),wheezy sid))
+    stage1_gcj46_archs = m68k s390
+    stage1_gcj47_archs = $(filter-out $(stage1_gcj46_archs), $(stage1_gcj_archs))
     bd_bootstrap += \
 	ecj-gcj [$(strip $(foreach a,$(stage1_gcj_archs), $(a)))], \
-	gcj-4.7-jdk [$(strip $(foreach a,$(stage1_gcj_archs), $(a)))], \
+	gcj-4.6-jdk [$(strip $(foreach a,$(stage1_gcj46_archs), $(a)))], \
+	gcj-4.7-jdk [$(strip $(foreach a,$(stage1_gcj47_archs), $(a)))], \
 	gcj-jdk [$(strip $(foreach a,$(stage1_gcj_archs), $(a)))],
-    bd_bootstrap += g++-4.4 [mips mipsel], gcj-4.6-jdk [s390],
+    bd_bootstrap += g++-4.4 [mips mipsel],
   else ifeq (,$(filter $(distrel),lenny jaunty intrepid hardy gutsy feisty edgy))
     bd_bootstrap += \
 	ecj-gcj [$(strip $(foreach a,$(stage1_gcj_archs), $(a)))], \
only in patch2:
unchanged:
--- openjdk-6-6b24-1.11.5.orig/debian/patches/m68k-use-gcc-atomic-builtins.patch
+++ openjdk-6-6b24-1.11.5/debian/patches/m68k-use-gcc-atomic-builtins.patch
@@ -0,0 +1,156 @@
+# DP: Use GCC atomic builtins on m68k instead of rolling our own,
+# DP: since these use a kernel helper internally.
+
+--- openjdk/hotspot/src/os_cpu/linux_zero/vm/atomic_linux_zero.inline.hpp~	2011-11-14 22:07:32.000000000 +0000
++++ openjdk/hotspot/src/os_cpu/linux_zero/vm/atomic_linux_zero.inline.hpp	2012-11-29 15:02:31.000000000 +0000
+@@ -33,74 +33,6 @@
+ 
+ // Implementation of class atomic
+ 
+-#ifdef M68K
+-
+-/*
+- * __m68k_cmpxchg
+- *
+- * Atomically store newval in *ptr if *ptr is equal to oldval for user space.
+- * Returns newval on success and oldval if no exchange happened.
+- * This implementation is processor specific and works on
+- * 68020 68030 68040 and 68060.
+- *
+- * It will not work on ColdFire, 68000 and 68010 since they lack the CAS
+- * instruction.
+- * Using a kernelhelper would be better for arch complete implementation.
+- *
+- */
+-
+-static inline int __m68k_cmpxchg(int oldval, int newval, volatile int *ptr) {
+-  int ret;
+-  __asm __volatile ("cas%.l %0,%2,%1"
+-                   : "=d" (ret), "+m" (*(ptr))
+-                   : "d" (newval), "0" (oldval));
+-  return ret;
+-}
+-
+-/* Perform an atomic compare and swap: if the current value of `*PTR'
+-   is OLDVAL, then write NEWVAL into `*PTR'.  Return the contents of
+-   `*PTR' before the operation.*/
+-static inline int m68k_compare_and_swap(volatile int *ptr,
+-                                        int oldval,
+-                                        int newval) {
+-  for (;;) {
+-      int prev = *ptr;
+-      if (prev != oldval)
+-        return prev;
+-
+-      if (__m68k_cmpxchg (prev, newval, ptr) == newval)
+-        // Success.
+-        return prev;
+-
+-      // We failed even though prev == oldval.  Try again.
+-    }
+-}
+-
+-/* Atomically add an int to memory.  */
+-static inline int m68k_add_and_fetch(volatile int *ptr, int add_value) {
+-  for (;;) {
+-      // Loop until success.
+-
+-      int prev = *ptr;
+-
+-      if (__m68k_cmpxchg (prev, prev + add_value, ptr) == prev + add_value)
+-        return prev + add_value;
+-    }
+-}
+-
+-/* Atomically write VALUE into `*PTR' and returns the previous
+-   contents of `*PTR'.  */
+-static inline int m68k_lock_test_and_set(volatile int *ptr, int newval) {
+-  for (;;) {
+-      // Loop until success.
+-      int prev = *ptr;
+-
+-      if (__m68k_cmpxchg (prev, newval, ptr) == prev)
+-        return prev;
+-    }
+-}
+-#endif // M68K
+-
+ #ifdef ARM
+ 
+ /*
+@@ -174,11 +106,7 @@ inline jint Atomic::add(jint add_value,
+ #ifdef ARM
+   return arm_add_and_fetch(dest, add_value);
+ #else
+-#ifdef M68K
+-  return m68k_add_and_fetch(dest, add_value);
+-#else
+   return __sync_add_and_fetch(dest, add_value);
+-#endif // M68K
+ #endif // ARM
+ }
+ 
+@@ -186,11 +114,7 @@ inline intptr_t Atomic::add_ptr(intptr_t
+ #ifdef ARM
+   return arm_add_and_fetch(dest, add_value);
+ #else
+-#ifdef M68K
+-  return m68k_add_and_fetch(dest, add_value);
+-#else
+   return __sync_add_and_fetch(dest, add_value);
+-#endif // M68K
+ #endif // ARM
+ }
+ 
+@@ -226,15 +150,11 @@ inline jint Atomic::xchg(jint exchange_v
+ #ifdef ARM
+   return arm_lock_test_and_set(dest, exchange_value);
+ #else
+-#ifdef M68K
+-  return m68k_lock_test_and_set(dest, exchange_value);
+-#else
+   // __sync_lock_test_and_set is a bizarrely named atomic exchange
+   // operation.  Note that some platforms only support this with the
+   // limitation that the only valid value to store is the immediate
+   // constant 1.  There is a test for this in JNI_CreateJavaVM().
+   return __sync_lock_test_and_set (dest, exchange_value);
+-#endif // M68K
+ #endif // ARM
+ }
+ 
+@@ -243,11 +163,7 @@ inline intptr_t Atomic::xchg_ptr(intptr_
+ #ifdef ARM
+   return arm_lock_test_and_set(dest, exchange_value);
+ #else
+-#ifdef M68K
+-  return m68k_lock_test_and_set(dest, exchange_value);
+-#else
+   return __sync_lock_test_and_set (dest, exchange_value);
+-#endif // M68K
+ #endif // ARM
+ }
+ 
+@@ -262,11 +178,7 @@ inline jint Atomic::cmpxchg(jint exchang
+ #ifdef ARM
+   return arm_compare_and_swap(dest, compare_value, exchange_value);
+ #else
+-#ifdef M68K
+-  return m68k_compare_and_swap(dest, compare_value, exchange_value);
+-#else
+   return __sync_val_compare_and_swap(dest, compare_value, exchange_value);
+-#endif // M68K
+ #endif // ARM
+ }
+ 
+@@ -283,11 +195,7 @@ inline intptr_t Atomic::cmpxchg_ptr(intp
+ #ifdef ARM
+   return arm_compare_and_swap(dest, compare_value, exchange_value);
+ #else
+-#ifdef M68K
+-  return m68k_compare_and_swap(dest, compare_value, exchange_value);
+-#else
+   return __sync_val_compare_and_swap(dest, compare_value, exchange_value);
+-#endif // M68K
+ #endif // ARM
+ }
+ 
only in patch2:
unchanged:
--- openjdk-6-6b24-1.11.5.orig/patches/text-relocations.patch
+++ openjdk-6-6b24-1.11.5/patches/text-relocations.patch
@@ -5,7 +5,7 @@
  # Compiler flags
  
  # position-independent code
-+ifneq ($(filter alpha parisc ppc ppc64 s390 s390x sparc sparc64 sparcv9,$(ZERO_LIBARCH)),)
++ifneq ($(filter alpha m68k parisc ppc ppc64 s390 s390x sparc sparc64 sparcv9,$(ZERO_LIBARCH)),)
  PICFLAG = -fPIC
 +else
 +PICFLAG = -fpic

bye,
//mirabilos
-- 
“It is inappropriate to require that a time represented as
 seconds since the Epoch precisely represent the number of
 seconds between the referenced time and the Epoch.”
	-- IEEE Std 1003.1b-1993 (POSIX) Section B.2.2.2

Attachment: openjdk-6_6b24-1.11.5-1+m68k.1_m68k.build.xz
Description: Binary data


Reply to: