JAVA installation error on Yocto build

2019-07-12 20:12发布

问题:

I'm having a lot of trouble installing Java on my Poky Linux system. I'm building my system using Yocto with the following configuration:

local.conf

MACHINE ??= "intel-corei7-64"

DISTRO ?= "poky"

PACKAGE_CLASSES ?= "package_rpm"

SDKMACHINE ?= "x86_64"

EXTRA_IMAGE_FEATURES ?= "debug-tweaks"

USER_CLASSES ?= "buildstats image-mklibs image-prelink"

PATCHRESOLVE = "noop"

BB_DISKMON_DIRS = "\
    STOPTASKS,${TMPDIR},1G,100K \
    STOPTASKS,${DL_DIR},1G,100K \
    STOPTASKS,${SSTATE_DIR},1G,100K \
    STOPTASKS,/tmp,100M,100K \
    ABORT,${TMPDIR},100M,1K \
    ABORT,${DL_DIR},100M,1K \
    ABORT,${SSTATE_DIR},100M,1K \
    ABORT,/tmp,10M,1K"


PACKAGECONFIG_append_pn-qemu-native = " sdl"
PACKAGECONFIG_append_pn-nativesdk-qemu = " sdl"

CONF_VERSION = "1"

BB_NUMBER_THREADS = '12'
PARALLEL_MAKE = '-j 12'

# Java installation
CORE_IMAGE_EXTRA_INSTALL += "gtkperf libxslt" 
IMAGE_INSTALL_append = " openjdk-7-jre "

LICENSE_FLAGS_WHITELIST += "oracle_java" 
PREFERRED_PROVIDER_virtual/java-initial-native = "cacao-initial-native"
PREFERRED_PROVIDER_virtual/java-native = "jamvm-native"
PREFERRED_PROVIDER_virtual/javac-native = "ecj-bootstrap-native"

PREFERRED_VERSION_xserver-nodm-init = "1.0"

# OpenCV installation
CORE_IMAGE_EXTRA_INSTALL += "opencv opencv-samples libopencv-core-dev libopencv-highgui-dev libopencv-imgproc-dev libopencv-objdetect-dev libopencv-ml-dev"

bblayers.conf

# POKY_BBLAYERS_CONF_VERSION is increased each time build/conf/bblayers.conf
# changes incompatibly
POKY_BBLAYERS_CONF_VERSION = "2"

BBPATH = "${TOPDIR}"
BBFILES ?= ""

BBLAYERS ?= " \
  $HOME/poky/meta \
  $HOME/poky/meta-poky \
  $HOME/poky/meta-yocto-bsp \
  $HOME/poky/meta-intel \
  $HOME/poky/meta-openembedded/meta-oe \
  $HOME/poky/meta-intel-realsense \
  $HOME/poky/meta-java \
  $HOME/poky/meta-oracle-java \
  "

I need to use morty branch since I'm using Intel Realsense layer which is only compatible with 4.8 kernel

Build Configuration:
BB_VERSION        = "1.32.0"
BUILD_SYS         = "x86_64-linux"
NATIVELSBSTRING   = "CentOSLinux-7.3.1611"
TARGET_SYS        = "x86_64-poky-linux"
MACHINE           = "intel-corei7-64"
DISTRO            = "poky"
DISTRO_VERSION    = "2.2.1"
TUNE_FEATURES     = "m64 corei7"
TARGET_FPU        = ""
meta              
meta-poky         
meta-yocto-bsp    = "morty:924e576b8930fd2268d85f0b151e5f68a3c2afce"
meta-intel        = "morty:6add41510412ca196efb3e4f949d403a8b6f35d7"
meta-oe           = "morty:fe5c83312de11e80b85680ef237f8acb04b4b26e"
meta-intel-realsense = "morty:2c0dfe9690d2871214fba9c1c32980a5eb89a421"
meta-java         = "master:67e48693501bddb80745b9735b7b3d4d28dce9a1"
meta-oracle-java  = "morty:f44365f02b283c3fb362dc99e2e996d3f11e356e"

I get the following error:

ERROR: openjdk-7-jre-99b00-2.6.5-r6.1 do_compile: oe_runmake failed
ERROR: openjdk-7-jre-99b00-2.6.5-r6.1 do_compile: Function failed: do_compile (log file is located at /home/dalben/NewBuild/poky/filec/tmp/work/corei7-64-poky-linux/openjdk-7-jre/99b00-2.6.5-r6.1/temp/log.do_compile.3780)
ERROR: Logfile of failure stored in: /home/dalben/NewBuild/poky/filec/tmp/work/corei7-64-poky-linux/openjdk-7-jre/99b00-2.6.5-r6.1/temp/log.do_compile.3780
Log data follows:

and then several hundreds lines of error log. Any help is appreciated.

EDIT: From the log.do_compile file

ERROR: oe_runmake failed
In file included from /home/dalben/NewBuild/poky/filec/tmp/work/corei7-64-poky-linux/openjdk-7-jre/99b00-2.6.5-r6.1/icedtea-2.6.5/build/openjdk/hotspot/src/share/vm/oops/constantPoolOop.hpp:29:0,
                 from /home/dalben/NewBuild/poky/filec/tmp/work/corei7-64-poky-linux/openjdk-7-jre/99b00-2.6.5-r6.1/icedtea-2.6.5/build/openjdk/hotspot/src/share/vm/oops/methodOop.hpp:33,
                 from /home/dalben/NewBuild/poky/filec/tmp/work/corei7-64-poky-linux/openjdk-7-jre/99b00-2.6.5-r6.1/icedtea-2.6.5/build/openjdk/hotspot/src/share/vm/runtime/frame.hpp:29,
                 from /home/dalben/NewBuild/poky/filec/tmp/work/corei7-64-poky-linux/openjdk-7-jre/99b00-2.6.5-r6.1/icedtea-2.6.5/build/openjdk/hotspot/src/share/vm/prims/jvmtiExport.hpp:33,
                 from /home/dalben/NewBuild/poky/filec/tmp/work/corei7-64-poky-linux/openjdk-7-jre/99b00-2.6.5-r6.1/icedtea-2.6.5/build/openjdk/hotspot/src/share/vm/runtime/thread.hpp:32,
                 from /home/dalben/NewBuild/poky/filec/tmp/work/corei7-64-poky-linux/openjdk-7-jre/99b00-2.6.5-r6.1/icedtea-2.6.5/build/openjdk/hotspot/src/os/linux/vm/thread_linux.inline.hpp:30,
                 from /home/dalben/NewBuild/poky/filec/tmp/work/corei7-64-poky-linux/openjdk-7-jre/99b00-2.6.5-r6.1/icedtea-2.6.5/build/openjdk/hotspot/src/share/vm/memory/resourceArea.hpp:30,
                 from /home/dalben/NewBuild/poky/filec/tmp/work/corei7-64-poky-linux/openjdk-7-jre/99b00-2.6.5-r6.1/icedtea-2.6.5/build/openjdk/hotspot/src/share/vm/classfile/classFileParser.hpp:29,
                 from /home/dalben/NewBuild/poky/filec/tmp/work/corei7-64-poky-linux/openjdk-7-jre/99b00-2.6.5-r6.1/icedtea-2.6.5/build/openjdk/hotspot/src/share/vm/classfile/classLoader.hpp:28,
                 from /home/dalben/NewBuild/poky/filec/tmp/work/corei7-64-poky-linux/openjdk-7-jre/99b00-2.6.5-r6.1/icedtea-2.6.5/build/openjdk/hotspot/src/share/vm/classfile/systemDictionary.hpp:29,
                 from /home/dalben/NewBuild/poky/filec/tmp/work/corei7-64-poky-linux/openjdk-7-jre/99b00-2.6.5-r6.1/icedtea-2.6.5/build/openjdk/hotspot/src/share/vm/ci/ciEnv.hpp:30,
                 from /home/dalben/NewBuild/poky/filec/tmp/work/corei7-64-poky-linux/openjdk-7-jre/99b00-2.6.5-r6.1/icedtea-2.6.5/build/openjdk/hotspot/src/share/vm/ci/ciUtilities.hpp:28,
                 from /home/dalben/NewBuild/poky/filec/tmp/work/corei7-64-poky-linux/openjdk-7-jre/99b00-2.6.5-r6.1/icedtea-2.6.5/build/openjdk/hotspot/src/share/vm/ci/ciNullObject.hpp:30,
                 from /home/dalben/NewBuild/poky/filec/tmp/work/corei7-64-poky-linux/openjdk-7-jre/99b00-2.6.5-r6.1/icedtea-2.6.5/build/openjdk/hotspot/src/share/vm/ci/ciConstant.hpp:29,
                 from /home/dalben/NewBuild/poky/filec/tmp/work/corei7-64-poky-linux/openjdk-7-jre/99b00-2.6.5-r6.1/icedtea-2.6.5/build/openjdk/hotspot/src/share/vm/precompiled/precompiled.hpp:36:
/home/dalben/NewBuild/poky/filec/tmp/work/corei7-64-poky-linux/openjdk-7-jre/99b00-2.6.5-r6.1/icedtea-2.6.5/build/openjdk/hotspot/src/share/vm/oops/cpCacheOop.hpp: At global scope:
/home/dalben/NewBuild/poky/filec/tmp/work/corei7-64-poky-linux/openjdk-7-jre/99b00-2.6.5-r6.1/icedtea-2.6.5/build/openjdk/hotspot/src/share/vm/oops/cpCacheOop.hpp:189:42: error: left operand of shift expression '(-1 << 28)' is negative [-fpermissive]
     option_bits_mask           = ~(((-1) << tos_state_shift) | (field_index_mask | parameter_size_mask))
                                    ~~~~~~^~~~~~~~~~~~~~~~~~~
/home/dalben/NewBuild/poky/filec/tmp/work/corei7-64-poky-linux/openjdk-7-jre/99b00-2.6.5-r6.1/icedtea-2.6.5/build/openjdk/hotspot/src/share/vm/oops/cpCacheOop.hpp:189:104: error: enumerator value for 'option_bits_mask' is not an integer constant
     option_bits_mask           = ~(((-1) << tos_state_shift) | (field_index_mask | parameter_size_mask))
                                                                                                        ^
In file included from /home/dalben/NewBuild/poky/filec/tmp/work/corei7-64-poky-linux/openjdk-7-jre/99b00-2.6.5-r6.1/icedtea-2.6.5/build/openjdk/hotspot/src/share/vm/ci/ciEnv.hpp:32:0,
                 from /home/dalben/NewBuild/poky/filec/tmp/work/corei7-64-poky-linux/openjdk-7-jre/99b00-2.6.5-r6.1/icedtea-2.6.5/build/openjdk/hotspot/src/share/vm/ci/ciUtilities.hpp:28,
                 from /home/dalben/NewBuild/poky/filec/tmp/work/corei7-64-poky-linux/openjdk-7-jre/99b00-2.6.5-r6.1/icedtea-2.6.5/build/openjdk/hotspot/src/share/vm/ci/ciNullObject.hpp:30,
                 from /home/dalben/NewBuild/poky/filec/tmp/work/corei7-64-poky-linux/openjdk-7-jre/99b00-2.6.5-r6.1/icedtea-2.6.5/build/openjdk/hotspot/src/share/vm/ci/ciConstant.hpp:29,
                 from /home/dalben/NewBuild/poky/filec/tmp/work/corei7-64-poky-linux/openjdk-7-jre/99b00-2.6.5-r6.1/icedtea-2.6.5/build/openjdk/hotspot/src/share/vm/precompiled/precompiled.hpp:36:
/home/dalben/NewBuild/poky/filec/tmp/work/corei7-64-poky-linux/openjdk-7-jre/99b00-2.6.5-r6.1/icedtea-2.6.5/build/openjdk/hotspot/src/share/vm/code/dependencies.hpp:169:59: error: left operand of shift expression '(-1 << 1)' is negative [-fpermissive]
     all_types           = ((1 << TYPE_LIMIT) - 1) & ((-1) << FIRST_TYPE),
                                                     ~~~~~~^~~~~~~~~~~~~~
/home/dalben/NewBuild/poky/filec/tmp/work/corei7-64-poky-linux/openjdk-7-jre/99b00-2.6.5-r6.1/icedtea-2.6.5/build/openjdk/hotspot/src/share/vm/code/dependencies.hpp:169:72: error: enumerator value for 'all_types' is not an integer constant
     all_types           = ((1 << TYPE_LIMIT) - 1) & ((-1) << FIRST_TYPE),
                                                                        ^
gmake[7]: *** [precompiled.hpp.gch] Error 1
gmake[7]: Leaving directory `/home/dalben/NewBuild/poky/filec/tmp/work/corei7-64-poky-linux/openjdk-7-jre/99b00-2.6.5-r6.1/icedtea-2.6.5/build/openjdk.build/hotspot/outputdir/linux_amd64_zero/product'
gmake[6]: *** [the_vm] Error 2
gmake[6]: Leaving directory `/home/dalben/NewBuild/poky/filec/tmp/work/corei7-64-poky-linux/openjdk-7-jre/99b00-2.6.5-r6.1/icedtea-2.6.5/build/openjdk.build/hotspot/outputdir/linux_amd64_zero/product'
gmake[5]: *** [productzero] Error 2
gmake[5]: Leaving directory `/home/dalben/NewBuild/poky/filec/tmp/work/corei7-64-poky-linux/openjdk-7-jre/99b00-2.6.5-r6.1/icedtea-2.6.5/build/openjdk.build/hotspot/outputdir'
gmake[4]: *** [generic_buildzero] Error 2
gmake[4]: Leaving directory `/home/dalben/NewBuild/poky/filec/tmp/work/corei7-64-poky-linux/openjdk-7-jre/99b00-2.6.5-r6.1/icedtea-2.6.5/build/openjdk/hotspot/make'
gmake[3]: *** [productzero] Error 2
gmake[3]: Leaving directory `/home/dalben/NewBuild/poky/filec/tmp/work/corei7-64-poky-linux/openjdk-7-jre/99b00-2.6.5-r6.1/icedtea-2.6.5/build/openjdk/hotspot/make'
gmake[2]: *** [hotspot-build] Error 2
gmake[2]: Leaving directory `/home/dalben/NewBuild/poky/filec/tmp/work/corei7-64-poky-linux/openjdk-7-jre/99b00-2.6.5-r6.1/icedtea-2.6.5/build/openjdk'
gmake[1]: *** [build_product_image] Error 2
gmake[1]: Leaving directory `/home/dalben/NewBuild/poky/filec/tmp/work/corei7-64-poky-linux/openjdk-7-jre/99b00-2.6.5-r6.1/icedtea-2.6.5/build/openjdk'
make: *** [Makefile:2451: stamps/icedtea.stamp] Error 2
ERROR: Function failed: do_compile (log file is located at /home/dalben/NewBuild/poky/filec/tmp/work/corei7-64-poky-linux/openjdk-7-jre/99b00-2.6.5-r6.1/temp/log.do_compile.3780)

回答1:

I manually patched the files generating those error and builded the image. It gave a new error but successfully wrote the image. Java in installed:

root@intel-corei7-64:~# java -version
java version "1.7.0_99"
OpenJDK Runtime Environment (IcedTea 2.6.5) (99b00-2.6.5)
OpenJDK 64-Bit Zero VM (build 24.95-b01, interpreted mode)

The solution is either:

  1. Manually patch openjdk following this

  2. Use a newer version of openjdk. This can be achived using a more recent commit for the meta-java repository or setting a newer preferred version in the local.conf.

EDIT: Added guide link.

Guide

Since I'm using this image in an OpenSource project I made a little guide on how to overcome the problems I had during the building process. The guide can be found here.

UPDATE: I upgraded the JRE and JDK version. The new guide can be found here. For the bravest among you there's also an installer script.