[oe] [meta-java] openjdk "IndexError: string index out of range" with ccache

Mike Crowe mac at mcrowe.com
Wed May 1 13:19:09 UTC 2019


For a long time, we've been seeing errors when building openjdk-8:

WARNING: .../meta-java/recipes-core/openjdk/openjdk-8_172b11.bb: Unable to export ${CXXFLAGS_FOR_BUILD}: Failure expanding variableBUILD_CFLAGS, expression was -isystem/.../openjdk-8/172b11-r0/recipe-sysroot-native/usr/include -O2 -pipe -Wno-error=deprecated-declarations ${@openjdk_build_helper_get_build_cflags(d)} which triggered exception IndexError: string index out of range

I finally managed to work out what was causing them. When using ccache
(built as ccache-native during the build), BUILD_CC contains "ccache gcc".
Unfortunately, with recipe-specific sysroots ccache is not always available
in the PATH for every task (in particular, for do_prepare_sysroot of
course, but there are plenty of others.) Yet, because CXXFLAGS_FOR_BUILD is
exported it must be expanded for every task.

The confusing error message is because
openjdk-build-helper.bbclass:openjdk_build_helper_get_build_cflags does
cc.communicate()[0].decode('utf-8')[0] on the empty string it received on
from stdout when ccache cannot be executed.

(I also notice that this will break with GCC 10, which is currently in
development.)

I've worked around the problem with the horrendous:

    if build_cc.startswith("ccache "):
            build_cc = build_cc[7:]

What would be a better solution to this problem? The only one I could come
up with is only export CXXFLAGS_FOR_BUILD in a prepend for do_configure and
do_compile.

Thanks.

Mike.


More information about the Openembedded-devel mailing list