prepare for openjdk-8 build infra re-use
Icedtea 7 and OpenJDK 7 will need to apply new compiler flags for certain compiler version without breaking support for older (host) compilers.
Move to a common class so that the same code can be re-used.
This series sits on top of my earlier patchset from today.
PATCH v2 1/2 java.bbclass: move openjdk/icedtea specific code into new class
From: André Draszik <[email protected]>
The code moved is not relevant to anything using java, just for compiling java itself. It doesn't make sense to have here.
Move it into openjdk-build-helper
--- classes/java.bbclass | 17 ----------------- classes/openjdk-build-helper.bbclass | 16 ++++++++++++++++ recipes-core/icedtea/icedtea7-native.inc | 3 ++- recipes-core/openjdk/openjdk-7-common.inc | 2 +- recipes-core/openjdk/openjdk-8-common.inc | 1 + recipes-core/openjdk/openjdk-8-cross.inc | 2 +- recipes-core/openjdk/openjdk-8-native.inc | 2 +- recipes-core/openjdk/openjdk-common.inc | 1 + 8 files changed, 23 insertions(+), 21 deletions(-) create mode 100644 classes/openjdk-build-helper.bbclass
classes/java.bbclass +0 -17
@@ -21,23 +21,6 @@ STAGING_DATADIR_JAVA_NATIVE ?= "${STAGING_DATADIR_NATIVE}/java" STAGING_LIBDIR_JNI_NATIVE ?= "${STAGING_LIBDIR_NATIVE}/jni" STAGING_LIBDIR_JVM_NATIVE ?= "${STAGING_LIBDIR_NATIVE}/jvm" -# Icedtea's makefile is not compatible to parallelization so we cannot allow -# passing a valid ${PARALLEL_MAKE} to it. OTOH OpenJDK's makefiles are -# parallelizable and we need ${PARALLEL_MAKE} to derive the proper value. -# The base for this quirk is that GNU Make only considers the last "-j" option. -EXTRA_OEMAKE_remove_task-compile = "${PARALLEL_MAKE}" -EXTRA_OEMAKE_remove_task-install = "${PARALLEL_MAKEINST}" - -# OpenJDK supports parallel compilation but uses a plain number for this. -# In OE we have PARALLEL_MAKE which is the actual option passed to make, -# e.g. "-j 4". -def java_get_parallel_make(d): - pm = d.getVar('PARALLEL_MAKE', True); - if not pm or '-j' not in pm: - return 1 - - return pm.partition('-j')[2].strip().split(' ')[0] - oe_jarinstall() { # Purpose: Install a jar file and create all the given symlinks to it. # Example:
classes/openjdk-build-helper.bbclass new file +16 -0
@@ -0,0 +1,16 @@ +# Icedtea's makefile is not compatible to parallelization so we cannot allow +# passing a valid ${PARALLEL_MAKE} to it. OTOH OpenJDK's makefiles are +# parallelizable and we need ${PARALLEL_MAKE} to derive the proper value. +# The base for this quirk is that GNU Make only considers the last "-j" option. +EXTRA_OEMAKE_remove_task-compile = "${PARALLEL_MAKE}" +EXTRA_OEMAKE_remove_task-install = "${PARALLEL_MAKEINST}" + +# OpenJDK supports parallel compilation but uses a plain number for this. +# In OE we have PARALLEL_MAKE which is the actual option passed to make, +# e.g. "-j 4". +def openjdk_build_helper_get_parallel_make(d): + pm = d.getVar('PARALLEL_MAKE', True); + if not pm or '-j' not in pm: + return 1 + + return pm.partition('-j')[2].strip().split(' ')[0]
recipes-core/icedtea/icedtea7-native.inc +2 -1
@@ -25,6 +25,7 @@ CXXFLAGS_append = " -fno-tree-dse" CXX_append = " -std=gnu++98" inherit native java autotools pkgconfig +inherit openjdk-build-helper JAVA_HOME[unexport] = "1"
@@ -58,7 +59,7 @@ export ALT_FREETYPE_LIB_PATH = "${STAGING_LIBDIR}" INSANE_SKIP_${PN} = "already-stripped" EXTRA_OECONF = "\ - --with-parallel-jobs=${@java_get_parallel_make(d)} \ + --with-parallel-jobs=${@openjdk_build_helper_get_parallel_make(d)} \ \ --disable-tests \ --disable-hotspot-tests \
recipes-core/openjdk/openjdk-7-common.inc +1 -1
@@ -84,7 +84,7 @@ EXTRA_OECONF = " \ --with-jdk-src-zip=${WORKDIR}/${JDK_FILE} \ --with-langtools-src-zip=${WORKDIR}/${LANGTOOLS_FILE} \ \ - --with-parallel-jobs=${@java_get_parallel_make(d)} \ + --with-parallel-jobs=${@openjdk_build_helper_get_parallel_make(d)} \ \ --with-pkgversion=${PV} \ --with-cc-for-build=${BUILD_CC} \
recipes-core/openjdk/openjdk-8-common.inc +1 -0
@@ -5,6 +5,7 @@ LICENSE = "GPL-2.0-with-classpath-exception" LIC_FILES_CHKSUM = "file://LICENSE;md5=3e0b59f8fac05c3c03d4a26bbda13f8f" inherit java autotools gettext qemu pkgconfig +inherit openjdk-build-helper AUTOTOOLS_SCRIPT_PATH = "${S}/common/autoconf/" export AUTOCONF_DIR="${AUTOTOOLS_SCRIPT_PATH}"
recipes-core/openjdk/openjdk-8-cross.inc +1 -1
@@ -52,7 +52,7 @@ SRC_URI_append = "\ " EXTRA_OECONF_append = "\ - --with-jobs=${@java_get_parallel_make(d)} \ + --with-jobs=${@openjdk_build_helper_get_parallel_make(d)} \ \ --with-sys-root=${STAGING_DIR_HOST} \ --with-tools-dir=${STAGING_DIR_NATIVE} \
recipes-core/openjdk/openjdk-8-native.inc +1 -1
@@ -20,7 +20,7 @@ PACKAGECONFIG[png] = "--with-libpng=system,--with-libpng=bundled,libpng-native" PACKAGECONFIG[zlib] = "--with-zlib=system,--with-zlib=bundled,zlib-native" EXTRA_OECONF_append = "\ - --with-jobs=${@java_get_parallel_make(d)} \ + --with-jobs=${@openjdk_build_helper_get_parallel_make(d)} \ \ --with-sys-root=${STAGING_DIR_NATIVE} \ --with-tools-dir=${STAGING_DIR_NATIVE} \
recipes-core/openjdk/openjdk-common.inc +1 -0
@@ -17,6 +17,7 @@ DEPENDS_append_libc-uclibc = " virtual/libiconv " DEPENDS_append = " qemu-native " inherit java autotools gettext qemu pkgconfig +inherit openjdk-build-helper B = "${S}/build"
Signature · 1 line
2.18.0
PATCH v2 2/2 openjdk-build-helper: move c compiler flags retrieval to here (from openjdk-8)
In reply to André DraszikFrom: André Draszik <[email protected]>
Icedtea 7 and OpenJDK 7 will need to apply new compiler flags for certain compiler version without breaking support for older (host) compilers.
Move here so that the same code can be re-used.
--- classes/openjdk-build-helper.bbclass | 35 ++++++++++++++++++ recipes-core/openjdk/openjdk-8-common.inc | 45 ++--------------------- 2 files changed, 39 insertions(+), 41 deletions(-)
classes/openjdk-build-helper.bbclass +35 -0
@@ -14,3 +14,38 @@ def openjdk_build_helper_get_parallel_make(d): return 1 return pm.partition('-j')[2].strip().split(' ')[0] + +# All supported cross compilers support the compiler flags that were +# added to make compilation with gcc6 work. But the host compiler for +# native compilation is a different story: it may be too old (for example, +# gcc 4.9.2 on Debian Wheezy). In that case we need to check what the +# version is and only add the flags that are appropriate for that GCC +# version. +def openjdk_build_helper_get_cflags_by_cc_version(d, version): + if version.isdigit(): + return d.getVar('FLAGS_GCC%d' % int(version)) or '' + return '' + +def openjdk_build_helper_get_build_cflags(d): + def get_build_cc_version(build_cc): + from subprocess import Popen, PIPE + cmd = d.expand('%s -dumpversion' % build_cc).split() + cc = Popen(cmd, stdout=PIPE, stderr=PIPE) + return cc.communicate()[0].decode('utf-8')[0] + + build_cc = d.getVar('BUILD_CC') + version = get_build_cc_version(build_cc) + return openjdk_build_helper_get_cflags_by_cc_version(d, version) + +def openjdk_build_helper_get_target_cflags(d): + import re + + # in the cross case, trust that GCCVERSION is correct. This won't + # work if the native toolchain is Clang, but as of this writing that + # doesn't work anyway. + version = d.getVar('GCCVERSION')[0] + # skip non digit characters at the beginning, e.g. from "linaro-6.2%" + match = re.search("\d", version) + if match: + version = version[match.start():] + return openjdk_build_helper_get_cflags_by_cc_version(d, version)
recipes-core/openjdk/openjdk-8-common.inc +4 -41
50 lines not on this page · raw message
Signature · 1 line
2.18.0
Hi,
this is a note to let you know that I've just added this patch series to the master-next branch of the meta-java repository at
git://git.yoctoproject.org/meta-java
As soon as it has gone through some more testing it will likely be merged to the master branch.
If you have any questions, please let me know.
regards;Richard.L
Quoted 8 lines · André Draszik
Icedtea 7 and OpenJDK 7 will need to apply new compiler flags for certain compiler version without breaking support for older (host) compilers.
Move to a common class so that the same code can be re-used.
This series sits on top of my earlier patchset from today.