Different macro definition between make and make images when cross compiling

wangyadong (E) yadonn.wang at huawei.com
Thu Mar 31 09:52:00 UTC 2022


Hi, Dingli,

Obviously, make install or make images did more work than make.

In make/Main.gmk, you will see comments below:

  # Jmods cannot be created until we have the jmod tool ready to run. During
  # a normal build we run it from the exploded image, but when cross compiling
  # it's run from the buildjdk, which is either created at build time or user
  # supplied.

If you did not indicate the build jdk by configuring with --with-build-jdk, a new one will be created at the build time, targeting on the platform where the building work happened.

With your example, make install met a compilation error when you creating a build jdk on the host platform.
  
Best regards,
Yadong

-----Original Message-----
From: riscv-port-dev [mailto:riscv-port-dev-retn at openjdk.java.net] On Behalf Of Dingli Zhang
Sent: Thursday, March 31, 2022 2:37 PM
To: riscv-port-dev at openjdk.java.net
Subject: Different macro definition between make and make images when cross compiling 

Hi, thanks everyone for upstreaming!
I built jdk with cross compiling follow the guide here: 
http://cr.openjdk.java.net/~fyang/openjdk-riscv-port/BuildRISCVJDK.md


It works and is very convenient but I have a small question, is there any different macro definition when buid jdk between make and make images?
I use https://github.com/openjdk/jdk/tree/eeca3a31559c2e334958c6d929cff8eb350c32a3 and apply this patch:
diff --git a/src/hotspot/share/runtime/thread.inline.hpp b/src/hotspot/share/runtime/thread.inline.hpp
index 92dfdfa3dbe..b9e50eeb597 100644
--- a/src/hotspot/share/runtime/thread.inline.hpp
+++ b/src/hotspot/share/runtime/thread.inline.hpp
@@ -155,6 +155,7 @@ inline JavaThreadState JavaThread::thread_state() const    {
   // Threads::create_vm() for size checks.
   return (JavaThreadState) Atomic::load_acquire((volatile jint*)&_thread_state);  #else
+  throw "Should not reach here!";
   return _thread_state;
 #endif
 }


It can build and run java -version successfully with 'make' but will throw exception with 'make images':
In file included from src/hotspot/share/interpreter/bootstrapInfo.cpp:41:0:
src/hotspot/share/runtime/thread.inline.hpp: In member function 'JavaThreadState JavaThread::thread_state() const':
src/hotspot/share/runtime/thread.inline.hpp:158:9: error: exception handling disabled, use -fexceptions to enable
   throw "Should not reach here!";
         ^~~~~~~~~~~~~~~~~~~~~~~~
At global scope:
cc1plus: warning: unrecognized command line option '-Wno-cast-function-type'
gmake[4]: *** [/jdk/build/linux-riscv64-server-release/buildjdk/hotspot/variant-server/libjvm/objs/bootstrapInfo.o] Error 1
gmake[4]: *** Waiting for unfinished jobs....
lib/CompileJvm.gmk:146: recipe for target '/jdk/build/linux-riscv64-server-release/buildjdk/hotspot/variant-server/libjvm/objs/bootstrapInfo.o' failed [buildjdk] Compiling 186 files for BUILD_TOOLS_JDK [buildjdk] Compiling 2 files for COMPILE_DEPEND [buildjdk] Compiling 11 properties into resource bundles for java.logging [buildjdk] Compiling 5 properties into resource bundles for jdk.jlink [buildjdk] Compiling 3 properties into resource bundles for jdk.jlink [buildjdk] Compiling 1 properties into resource bundles for jdk.jlink [buildjdk] Compiling 2 files for BUILD_BREAKITERATOR_BASE [buildjdk] Compiling 2 files for BUILD_BREAKITERATOR_LD [buildjdk] Compiling 11 properties into resource bundles for java.base [buildjdk] Compiling 6 properties into resource bundles for java.base
Main.gmk:252: recipe for target 'hotspot-server-libs' failed
gmake[3]: *** [hotspot-server-libs] Error 1
gmake[3]: *** Waiting for unfinished jobs....
make/Main.gmk:554: recipe for target 'create-buildjdk-interim-image' failed
gmake[2]: *** [create-buildjdk-interim-image] Error 1

ERROR: Build failed for target 'images' in configuration 'linux-riscv64-server-release' (exit code 2) Stopping sjavac server

=== Output from failing command(s) repeated here ===
* For target buildjdk_hotspot_variant-server_libjvm_objs_bootstrapInfo.o:
In file included from src/hotspot/share/interpreter/bootstrapInfo.cpp:41:0:
src/hotspot/share/runtime/thread.inline.hpp: In member function 'JavaThreadState JavaThread::thread_state() const':
src/hotspot/share/runtime/thread.inline.hpp:158:9: error: exception handling disabled, use -fexceptions to enable
   throw "Should not reach here!";
         ^~~~~~~~~~~~~~~~~~~~~~~~
At global scope:
cc1plus: warning: unrecognized command line option '-Wno-cast-function-type'

* All command lines available in /jdk/build/linux-riscv64-server-release/make-support/failure-logs.
=== End of repeated output ===

=== Make failed targets repeated here ===
lib/CompileJvm.gmk:146: recipe for target '/jdk/build/linux-riscv64-server-release/buildjdk/hotspot/variant-server/libjvm/objs/bootstrapInfo.o' failed
Main.gmk:252: recipe for target 'hotspot-server-libs' failed
make/Main.gmk:554: recipe for target 'create-buildjdk-interim-image' failed === End of repeated output ===

Hint: Try searching the build log for the name of the first failed target.
Hint: See doc/building.html#troubleshooting for assistance.

/jdk/make/Init.gmk:310: recipe for target 'main' failed
make[1]: *** [main] Error 1
/jdk/make/Init.gmk:186: recipe for target 'images' failed
make: *** [images] Error 2


I think it caused by the undefined macro 'RISCV64'. While the origin code build works with make/make images, it's odd that a macro that should be defined isn't defined.
Is this problem normal, or is it caused by cross compiling or make images?

Thanks, Dingli


More information about the riscv-port-dev mailing list