Environment: openjdk-8 with L5.4.24-2.1.0 and GCC-9
1. Clone meta-java with dedicated branch name:
git clone git://git.yoctoproject.org/meta-java -b zeus
2. Update .bb file for compile error in meta-java:
diff --git a/recipes-core/icedtea/icedtea7-native.inc b/recipes-core/icedtea/icedtea7-native.inc
index 8d0dc71..153a604 100644
--- a/recipes-core/icedtea/icedtea7-native.inc
+++ b/recipes-core/icedtea/icedtea7-native.inc
@@ -26,7 +26,7 @@ CXXFLAGS_append = " -fno-tree-dse"
CXX_append = " -std=gnu++98"
# WORKAROUND: ignore errors from new compilers
-CFLAGS_append = " -Wno-error=stringop-overflow -Wno-error=return-type"
+CFLAGS_append = " -Wno-error=stringop-overflow -Wno-error=return-type -Wno-error=format-overflow"
inherit native java autotools pkgconfig
inherit openjdk-build-helper
3. Add meta-java layer into bblayers.conf:
BBLAYERS += "${BSPDIR}/sources/meta-java"
4. Edit the conf/local.conf to add openjdk variables
# Possible provider: cacao-initial-native and jamvm-initial-native
PREFERRED_PROVIDER_virtual/java-initial-native = "cacao-initial-native"
# Possible provider: cacao-native and jamvm-native
PREFERRED_PROVIDER_virtual/java-native = "jamvm-native"
# Optional since there is only one provider for now
PREFERRED_PROVIDER_virtual/javac-native = "ecj-bootstrap-native"
PREFERRED_PROVIDER_java2-runtime = " openjdk-7-jre"
IMAGE_INSTALL_append = " openjdk-7-jdk "
diff --git a/recipes-core/openjdk/openjdk-8-common.inc b/recipes-core/openjdk/openjdk-8-common.inc
index d8b30b8..ed03d60 100644
--- a/recipes-core/openjdk/openjdk-8-common.inc
+++ b/recipes-core/openjdk/openjdk-8-common.inc
@@ -181,5 +181,5 @@ FLAGS_GCC9 = "-fno-lifetime-dse -fno-delete-null-pointer-checks"
BUILD_CFLAGS_append = " ${@openjdk_build_helper_get_build_cflags(d)}"
BUILD_CXXFLAGS_append = " ${@openjdk_build_helper_get_build_cflags(d)}"
# flags for -cross
-TARGET_CFLAGS_append = " ${@openjdk_build_helper_get_target_cflags(d)}"
+TARGET_CFLAGS_append = " ${@openjdk_build_helper_get_target_cflags(d)} -Wno-error=format-overflow"
TARGET_CXXFLAGS_append = " ${@openjdk_build_helper_get_target_cflags(d)}"
diff --git a/recipes-core/openjdk/openjdk-8-native.inc b/recipes-core/openjdk/openjdk-8-native.inc
index 321a43d..97ff03f 100644
5. Switch the host GCC to gcc-8 and g++-8:
sudo apt-get install gcc-8 g++-8
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-8 --slave /usr/bin/g++ g++ /usr/bin/g++-8 --slave /usr/bin/gcov gcov /usr/bin/gcov-8 --slave /usr/bin/gcov-tool gcov-tool /usr/bin/gcov-tool-8 --slave /usr/bin/gcc-ar gcc-ar /usr/bin/gcc-ar-8 --slave /usr/bin/gcc-nm gcc-nm /usr/bin/gcc-nm-8 --slave /usr/bin/gcc-ranlib gcc-ranlib /usr/bin/gcc-ranlib-8
sudo update-alternatives --config gcc
6. And change the conf/local.conf from openjdk-7 -> openjdk-8:
PREFERRED_PROVIDER_java2-runtime = " openjdk-8-jre"
IMAGE_INSTALL_append = " openjdk-8 "