[oi-dev] Building openjdk-8-162 with gcc-6 on SPARC

Jean-Pierre André jean-pierre.andre at wanadoo.fr
Mon Jan 13 07:25:25 UTC 2020


Gary Mills wrote:
> I'm attempting to build openjdk-8-162 with gcc-6 on SPARC hardware.  I
> finally got a successful gmake build, but a failure with gmake
> install.  The error was this one:
> 
>      Error occurred during initialization of VM
>      java.lang.StackOverflowError
>              at java.lang.Object.<clinit>(Object.java:41)
> 
> All newly-build java applications produce the same error.  With a
> search on the web, I found exactly the same error for linux.  The bug
> apparently affected all architectures except x86.  It appeared because
> of increased optimization in later versions of gcc.  This is the linux
> patch:
> 
> diff --git a/src/os_cpu/linux_zero/vm/os_linux_zero.cpp b/src/os_cpu/linux_zero/vm/os_linux_zero.cpp
> --- jdk8/hotspot/src/os_cpu/linux_zero/vm/os_linux_zero.cpp
> +++ jdk8/hotspot/src/os_cpu/linux_zero/vm/os_linux_zero.cpp
> @@ -55,8 +55,8 @@
>   #include "utilities/vmError.hpp"
>   
>   address os::current_stack_pointer() {
> -  address dummy = (address) &dummy;
> -  return dummy;
> +  // return the address of the current function
> +  return (address)__builtin_frame_address(0);
>   }
>   
>   frame os::get_sender_for_C_frame(frame* fr) {
> 
> This, of course, has no effect on OI.  During the build, OI is
> detected as solaris.  The equivalent function for solaris-sparc, in
> openjdk/hotspot/src/os_cpu/solaris_sparc/vm/os_solaris_sparc.cpp,
> has this code:
> 
>      address os::current_stack_pointer() {
>        volatile int dummy;
>        address sp = (address)&dummy + 8;     // %%%% need to confirm if this is right
>        return sp;
>      }
> 
> I assume that it's also compiled incorrectly because of the increased
> optimization, but I don't know how to correct it.  I'm also concerned
> about the comment.  Is it right?

A simple way to avoid this kind of optimization, is to put the
function in its own file, so that the compiler cannot know it
can be inlined. Compiling the function itself may however cause
an error for returning a pointer to a freed location.

Jean-Pierre

> 
> Has anybody else built openjdk for SPARC with gcc?  How did you fix
> this bug?
> 
> 






More information about the oi-dev mailing list