ibmruntimes / openj9-openjdk-jdk

Extensions for OpenJDK for Eclipse OpenJ9
GNU General Public License v2.0
17 stars 74 forks source link

Enabling CMake by default for cross-compiles #422

Open dnakamura opened 2 years ago

dnakamura commented 2 years ago

The CMake code should now be able to handle cross compile builds. This issue is to track any problems / objections anybody has before making cross-compile builds use cmake by default. CMake builds can currently be tested by passing --with-cmake when calling configure. In addition, where CMake is used by default, uma can still be used by passing --without-cmake.

pshipton commented 2 years ago

@janvrany @ChengJin01 fyi, since this primarily affects RISCV builds.

janvrany commented 2 years ago

Just FYI: I just enabled --with-cmake on my RISC-V CI and the cross-compilation job failed:

[  2%] Generating ut_gptest.c, ut_gptest.h, ut_gptest.pdat
gmake[6]: *** [runtime/tests/gp/CMakeFiles/trc_gptest.dir/build.make:81: runtime/tests/gp/ut_gptest.c] Killed
gmake[6]: Leaving directory '/var/lib/jenkins/workspace/eclipse_j9/j9_eclipse_riscv64_linux_cross@2/openj9-openjdk-jdk11/build/linux-riscv64-normal-server-release/vm'
gmake[5]: *** [CMakeFiles/Makefile2:7957: runtime/tests/gp/CMakeFiles/trc_gptest.dir/all] Error 2

The problem was that QEMU exhausted all system memory leading to system slowly swapping itself to death before OOM killer killed the QEMU:

[1313076.582208] qemu-riscv64 invoked oom-killer: gfp_mask=0x100cca(GFP_HIGHUSER_MOVABLE), order=0, oom_score_adj=0

Yesterday's cross-build without --with-cmake succeeded.

Note, that my JIT development cross-builds are using my own quick-and-dirtty hacked CMake but do not suffer from this problem.

I'll have a closer look the week after next as right now I'm away from home with limited access to my systems.

ChengJin01 commented 2 years ago

@janvrany, I suspect the integrated cmake changes might involve more memory than expected in QEMU which is pretty much restricted in terms of system memory. Is that possible to expand your memory on the command line when before launching QEMU? I recall there should be options for the memory setting.

janvrany commented 2 years ago

This is process-level QEMU so it has all the memory host has. I can try to increase host memory but I'd like to know why my home-baked CMake cross-build does not suffer from this problem.

We had similar problem with OMR tests and in the end we just increased the memory on Eclipse CI. Interestingly, on my system tests run just fine...

dnakamura commented 2 years ago

Its odd that it dies during tracegen. Memory requirements there should be fairly minimal. @janvrany Are the sources for your hacked cmake support available ?

janvrany commented 2 years ago

Sorry, finally back home. Sure, my changes are here:

Note that these are quick and dirty hacks I did just to allow me to build JIT component for RISC-V JIT development - my hacks may not run tracegen at all...

As for the memory requirements, I think it is QEMU that leaks the memory, not the tracegen itself. I'll investigate.

janvrany commented 2 years ago

Ah, this is embarrassing! It turned out that CMake picked up an ancient QEMU that was installed on my build node which suffered from some memory leak. With QEMU 6.2 or 7.0 it works just fine.

I'm very sorry about the noise!

pshipton commented 2 years ago

https://github.com/ibmruntimes/openj9-openjdk-jdk/pull/454 enables cmake for cross compiling, for jdk19+.

pshipton commented 2 years ago

https://github.com/ibmruntimes/openj9-openjdk-jdk/pull/454 only modifies the standard list of platforms. @knn-k I can't recall if you use cross compiling for aarch64.

knn-k commented 2 years ago

I sometimes use cross compilation in my environment for a specific AArch64 Linux target. I am OK about making CMake by default. I guess --with-cmake=no still works in case of unexpected failures with cross builds.

keithc-ca commented 2 years ago

This appears to have been applied to all jdk versions: Should we close this, or is there more to do?

pshipton commented 2 years ago

This appears to have been applied to all jdk versions: Should we close this, or is there more to do?

Afaik https://github.com/ibmruntimes/openj9-openjdk-jdk/pull/454 was applied to head but no other version got this change.

Also I had added a question to that PR after merging. Now that we support cross compilation, should we be compiling every build with cmake (by default) instead of just the hard coded list of platform?

keithc-ca commented 2 years ago

You're right: Perhaps I didn't look closely enough (or in the wrong places). 8, 11, 17 and 18 all still default to UMA for cross-compiles.

I can't think of a reason why the default behavior should depend upon the platform any more: it can be cmake.

pshipton commented 2 years ago

@dnakamura Summary of changes to date: jdk8: https://github.com/ibmruntimes/openj9-openjdk-jdk8/pull/583 jdk11: https://github.com/ibmruntimes/openj9-openjdk-jdk11/pull/545 jdk17: missing jdk18: https://github.com/ibmruntimes/openj9-openjdk-jdk18/pull/70 jdk19: https://github.com/ibmruntimes/openj9-openjdk-jdk19/pull/17 jdk: https://github.com/ibmruntimes/openj9-openjdk-jdk/pull/454 - needs to be updated