Openembedded Devel Discussions
 help / color / mirror / Atom feed
* [meta-java] prepare for openjdk-8 build infra re-use
@ 2018-08-13 15:09 André Draszik
  2018-08-13 15:09 ` [meta-java][PATCH v2 1/2] java.bbclass: move openjdk/icedtea specific code into new class André Draszik
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: André Draszik @ 2018-08-13 15:09 UTC (permalink / raw)
  To: openembedded-devel

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.




^ permalink raw reply	[flat|nested] 4+ messages in thread

* [meta-java][PATCH v2 1/2] java.bbclass: move openjdk/icedtea specific code into new class
  2018-08-13 15:09 [meta-java] prepare for openjdk-8 build infra re-use André Draszik
@ 2018-08-13 15:09 ` André Draszik
  2018-08-13 15:09 ` [meta-java][PATCH v2 2/2] openjdk-build-helper: move c compiler flags retrieval to here (from openjdk-8) André Draszik
  2018-08-13 20:57 ` [meta-java] prepare for openjdk-8 build infra re-use Richard Leitner
  2 siblings, 0 replies; 4+ messages in thread
From: André Draszik @ 2018-08-13 15:09 UTC (permalink / raw)
  To: openembedded-devel

From: André Draszik <andre.draszik@jci.com>

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

Signed-off-by: André Draszik <andre.draszik@jci.com>
---
 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

diff --git a/classes/java.bbclass b/classes/java.bbclass
index aa012ab..fc97295 100644
--- a/classes/java.bbclass
+++ b/classes/java.bbclass
@@ -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:
diff --git a/classes/openjdk-build-helper.bbclass b/classes/openjdk-build-helper.bbclass
new file mode 100644
index 0000000..785ddf0
--- /dev/null
+++ b/classes/openjdk-build-helper.bbclass
@@ -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]
diff --git a/recipes-core/icedtea/icedtea7-native.inc b/recipes-core/icedtea/icedtea7-native.inc
index 93463be..30fb24a 100644
--- a/recipes-core/icedtea/icedtea7-native.inc
+++ b/recipes-core/icedtea/icedtea7-native.inc
@@ -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 \
diff --git a/recipes-core/openjdk/openjdk-7-common.inc b/recipes-core/openjdk/openjdk-7-common.inc
index 1ac3154..0ef6758 100644
--- a/recipes-core/openjdk/openjdk-7-common.inc
+++ b/recipes-core/openjdk/openjdk-7-common.inc
@@ -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} \
diff --git a/recipes-core/openjdk/openjdk-8-common.inc b/recipes-core/openjdk/openjdk-8-common.inc
index aaa4483..97bf6e1 100644
--- a/recipes-core/openjdk/openjdk-8-common.inc
+++ b/recipes-core/openjdk/openjdk-8-common.inc
@@ -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}"
diff --git a/recipes-core/openjdk/openjdk-8-cross.inc b/recipes-core/openjdk/openjdk-8-cross.inc
index d0b2ec8..939155b 100644
--- a/recipes-core/openjdk/openjdk-8-cross.inc
+++ b/recipes-core/openjdk/openjdk-8-cross.inc
@@ -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} \
diff --git a/recipes-core/openjdk/openjdk-8-native.inc b/recipes-core/openjdk/openjdk-8-native.inc
index b782c32..e6f7933 100644
--- a/recipes-core/openjdk/openjdk-8-native.inc
+++ b/recipes-core/openjdk/openjdk-8-native.inc
@@ -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} \
diff --git a/recipes-core/openjdk/openjdk-common.inc b/recipes-core/openjdk/openjdk-common.inc
index 816b463..8aa04f5 100644
--- a/recipes-core/openjdk/openjdk-common.inc
+++ b/recipes-core/openjdk/openjdk-common.inc
@@ -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"
 
-- 
2.18.0



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [meta-java][PATCH v2 2/2] openjdk-build-helper: move c compiler flags retrieval to here (from openjdk-8)
  2018-08-13 15:09 [meta-java] prepare for openjdk-8 build infra re-use André Draszik
  2018-08-13 15:09 ` [meta-java][PATCH v2 1/2] java.bbclass: move openjdk/icedtea specific code into new class André Draszik
@ 2018-08-13 15:09 ` André Draszik
  2018-08-13 20:57 ` [meta-java] prepare for openjdk-8 build infra re-use Richard Leitner
  2 siblings, 0 replies; 4+ messages in thread
From: André Draszik @ 2018-08-13 15:09 UTC (permalink / raw)
  To: openembedded-devel

From: André Draszik <andre.draszik@jci.com>

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.

Signed-off-by: André Draszik <andre.draszik@jci.com>
---
 classes/openjdk-build-helper.bbclass      | 35 ++++++++++++++++++
 recipes-core/openjdk/openjdk-8-common.inc | 45 ++---------------------
 2 files changed, 39 insertions(+), 41 deletions(-)

diff --git a/classes/openjdk-build-helper.bbclass b/classes/openjdk-build-helper.bbclass
index 785ddf0..78906b0 100644
--- a/classes/openjdk-build-helper.bbclass
+++ b/classes/openjdk-build-helper.bbclass
@@ -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)
diff --git a/recipes-core/openjdk/openjdk-8-common.inc b/recipes-core/openjdk/openjdk-8-common.inc
index 97bf6e1..d0f7540 100644
--- a/recipes-core/openjdk/openjdk-8-common.inc
+++ b/recipes-core/openjdk/openjdk-8-common.inc
@@ -219,46 +219,9 @@ FLAGS_GCC6 = "-fno-lifetime-dse -fno-delete-null-pointer-checks"
 FLAGS_GCC7 = "-fno-lifetime-dse -fno-delete-null-pointer-checks"
 FLAGS_GCC8 = "-fno-lifetime-dse -fno-delete-null-pointer-checks -Wno-error=return-type"
 
-# 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 get_cflags_by_cc_version(d, version):
-    if version.isdigit():
-        return d.getVar('FLAGS_GCC%d' % int(version)) or ''
-    return ''
-
-def 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 get_cflags_by_cc_version(d, version)
-
-def 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 get_cflags_by_cc_version(d, version)
-
-
 # flags for -native, and for bits that need a host-tool during -cross
-BUILD_CFLAGS_append = " ${@get_build_cflags(d)}"
-BUILD_CXXFLAGS_append = " ${@get_build_cflags(d)}"
+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 = " ${@get_target_cflags(d)}"
-TARGET_CXXFLAGS_append = " ${@get_target_cflags(d)}"
+TARGET_CFLAGS_append = " ${@openjdk_build_helper_get_target_cflags(d)}"
+TARGET_CXXFLAGS_append = " ${@openjdk_build_helper_get_target_cflags(d)}"
-- 
2.18.0



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [meta-java] prepare for openjdk-8 build infra re-use
  2018-08-13 15:09 [meta-java] prepare for openjdk-8 build infra re-use André Draszik
  2018-08-13 15:09 ` [meta-java][PATCH v2 1/2] java.bbclass: move openjdk/icedtea specific code into new class André Draszik
  2018-08-13 15:09 ` [meta-java][PATCH v2 2/2] openjdk-build-helper: move c compiler flags retrieval to here (from openjdk-8) André Draszik
@ 2018-08-13 20:57 ` Richard Leitner
  2 siblings, 0 replies; 4+ messages in thread
From: Richard Leitner @ 2018-08-13 20:57 UTC (permalink / raw)
  To: André Draszik, openembedded-devel

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

On 08/13/2018 05:09 PM, André Draszik wrote:
> 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.
> 
> 


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-08-13 20:57 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-08-13 15:09 [meta-java] prepare for openjdk-8 build infra re-use André Draszik
2018-08-13 15:09 ` [meta-java][PATCH v2 1/2] java.bbclass: move openjdk/icedtea specific code into new class André Draszik
2018-08-13 15:09 ` [meta-java][PATCH v2 2/2] openjdk-build-helper: move c compiler flags retrieval to here (from openjdk-8) André Draszik
2018-08-13 20:57 ` [meta-java] prepare for openjdk-8 build infra re-use Richard Leitner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox