* [meta-java][PATCH] openjdk-8: Detect compiler version
@ 2016-07-15 21:08 Dan McGregor
2016-07-19 9:42 ` Patrick Ohly
0 siblings, 1 reply; 4+ messages in thread
From: Dan McGregor @ 2016-07-15 21:08 UTC (permalink / raw)
To: openembedded-devel
From: Daniel McGregor <daniel.mcgregor@vecima.com>
Some supported hosts still use GCC 4.X. These don't support the flags
needed to make GCC 6 work, so check the GCC version and add appropriate
compiler flags.
This implementation will append flags for any gcc version, but it's only
used for GCC 6 right now.
Signed-off-by: Daniel McGregor <daniel.mcgregor@vecima.com>
---
recipes-core/openjdk/openjdk-8-common.inc | 41 +++++++++++++++++++++++++++++--
1 file changed, 39 insertions(+), 2 deletions(-)
diff --git a/recipes-core/openjdk/openjdk-8-common.inc b/recipes-core/openjdk/openjdk-8-common.inc
index dd3d397..acc5481 100644
--- a/recipes-core/openjdk/openjdk-8-common.inc
+++ b/recipes-core/openjdk/openjdk-8-common.inc
@@ -237,6 +237,43 @@ EXTRA_OECONF_append = "\
--with-update-version=${OPENJDK_UPDATE_VERSION} \
"
-CFLAGS_append = " -fno-lifetime-dse -fno-delete-null-pointer-checks"
-CXXFLAGS_append = " -fno-lifetime-dse -fno-delete-null-pointer-checks"
+# GCC 6 sets the default C++ standard to C++14 and introduces dead store
+# elimination by default. OpenJDK 8 is not ready for either of these
+# changes.
+FLAGS_GCC6 = "-fno-lifetime-dse -fno-delete-null-pointer-checks"
+
+# 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 version_specific_cflags(d):
+ extraflags = None
+ version = None
+
+ if bb.data.inherits_class('native', d):
+ from subprocess import Popen, PIPE
+
+ cmd = d.expand('${CPP} -P -').split()
+ cc = Popen(cmd, stdin=PIPE, stdout=PIPE, stderr=PIPE)
+ # This check is GCC specific. Clang always returns 4. For Clang
+ # __clang_major__ and __clang_minor__ need to be checked. Ideally
+ # __GNUC_MINOR__ would be checked as well, but for this recipe
+ # GCC major is all we care about.
+ version = cc.communicate(b'__GNUC__')[0].decode('utf-8')[0]
+ else:
+ # 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', expand=True)[0]
+
+ if int(version) >= 4:
+ extraflags = d.getVar('FLAGS_GCC%d' % int(version), True)
+
+ return ''.join(extraflags)
+
+CFLAGS_append = " ${@version_specific_cflags(d)}"
+CXXFLAGS_append = " ${@version_specific_cflags(d)}"
CXX_append = " -std=gnu++98"
--
2.9.1
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [meta-java][PATCH] openjdk-8: Detect compiler version
2016-07-15 21:08 [meta-java][PATCH] openjdk-8: Detect compiler version Dan McGregor
@ 2016-07-19 9:42 ` Patrick Ohly
2016-07-20 9:48 ` [meta-java][PATCH] openjdk-8: fix compiler detection Patrick Ohly
0 siblings, 1 reply; 4+ messages in thread
From: Patrick Ohly @ 2016-07-19 9:42 UTC (permalink / raw)
To: openembedded-devel
Dan McGregor <danismostlikely <at> gmail.com> writes:
> From: Daniel McGregor <daniel.mcgregor <at> vecima.com>
>
> Some supported hosts still use GCC 4.X. These don't support the flags
> needed to make GCC 6 work, so check the GCC version and add appropriate
> compiler flags.
>
> This implementation will append flags for any gcc version, but it's only
> used for GCC 6 right now.
Now I am getting an error directly when bitbake parses the updated
recipes in meta-java:
ERROR: ExpansionError during parsing
.../ostro-os/meta-java/recipes-core/openjdk/openjdk-8_72b05.bb
...
bb.data_smart.ExpansionError: Failure expanding variable CFLAGS,
expression was -O2 -pipe -g -feliminate-unused-debug-types
-fdebug-prefix-map=.../ostro-os/build/tmp-glibc/work/corei7-64-ostro-
linux/openjdk-8/72b05-r0=/usr/src/debug/openjdk-8/72b05-r0
-fdebug-prefix-map=.../ostro-os/build/tmp-glibc/sysroots/x86_64-linux=
-fdebug-prefix-map=.../ostro-os/build/tmp-glibc/sysroots/intel-corei7-64=
-fstack-protector-strong -D_FORTIFY_SOURCE=2
${@version_specific_cflags(d)} -Wno-error=deprecated-declarations which
triggered exception TypeError: can only join an iterable
> +def version_specific_cflags(d):
> + extraflags = None
> + version = None
> +
> + if bb.data.inherits_class('native', d):
> + from subprocess import Popen, PIPE
> +
> + cmd = d.expand('${CPP} -P -').split()
> + cc = Popen(cmd, stdin=PIPE, stdout=PIPE, stderr=PIPE)
> + # This check is GCC specific. Clang always returns 4. For Clang
> + # __clang_major__ and __clang_minor__ need to be checked. Ideally
> + # __GNUC_MINOR__ would be checked as well, but for this recipe
> + # GCC major is all we care about.
> + version = cc.communicate(b'__GNUC__')[0].decode('utf-8')[0]
> + else:
> + # 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', expand=True)[0]
> +
> + if int(version) >= 4:
> + extraflags = d.getVar('FLAGS_GCC%d' % int(version), True)
> +
> + return ''.join(extraflags)
The code above only works when FLAGS_GCC<version> is set. In Ostro OS, we
are using GCCVERSION ?= "5.%" because of these unsolveed build breakages
with gcc6, and thus extraflags becomes None, which then triggers the
exception.
The same problem should also appear when gcc on the host is older than v6.
Has the patch actually been tested on a system where the problem occurs?
As I said in the other mail thread, fixing flags for openjdk-native is one
part of the problem. The other part is distinguishing between flags for the
host compiler and and target compiler when building openjdk - that part is
unsolved, and thus I'd expect compilation to still fail when building on a
host with gcc 4.x and default target gcc.
Bye, Patrick
^ permalink raw reply [flat|nested] 4+ messages in thread* [meta-java][PATCH] openjdk-8: fix compiler detection
2016-07-19 9:42 ` Patrick Ohly
@ 2016-07-20 9:48 ` Patrick Ohly
2016-07-20 16:04 ` Dan McGregor
0 siblings, 1 reply; 4+ messages in thread
From: Patrick Ohly @ 2016-07-20 9:48 UTC (permalink / raw)
To: openembedded-devel; +Cc: Patrick Ohly
When GCC is at version 4 or 5, parsing the recipe fails with:
ERROR: ExpansionError during parsing
.../ostro-os/meta-java/recipes-core/openjdk/openjdk-8_72b05.bb
...
bb.data_smart.ExpansionError: Failure expanding variable CFLAGS,
expression was -O2 -pipe -g -feliminate-unused-debug-types
-fdebug-prefix-map=.../ostro-os/build/tmp-glibc/work/corei7-64-ostro-
linux/openjdk-8/72b05-r0=/usr/src/debug/openjdk-8/72b05-r0
-fdebug-prefix-map=.../ostro-os/build/tmp-glibc/sysroots/x86_64-linux=
-fdebug-prefix-map=.../ostro-os/build/tmp-glibc/sysroots/intel-corei7-64=
-fstack-protector-strong -D_FORTIFY_SOURCE=2
${ <at> version_specific_cflags(d)} -Wno-error=deprecated-declarations which
triggered exception TypeError: can only join an iterable
That's because FLAGS_GCC<version> may be unset, thus leading to
d.getVar() returning None and ''.join(extraflags) failing.
The join() is also redundant: extraflags already is a string. It
happened to work because Python treats a string as sequence of
single-character strings, and thus ''.join() re-created the original
string.
Signed-off-by: Patrick Ohly <patrick.ohly@intel.com>
---
recipes-core/openjdk/openjdk-8-common.inc | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/recipes-core/openjdk/openjdk-8-common.inc b/recipes-core/openjdk/openjdk-8-common.inc
index 089f907..7ad802a 100644
--- a/recipes-core/openjdk/openjdk-8-common.inc
+++ b/recipes-core/openjdk/openjdk-8-common.inc
@@ -271,10 +271,8 @@ def version_specific_cflags(d):
# doesn't work anyway.
version = d.getVar('GCCVERSION', expand=True)[0]
- if int(version) >= 4:
- extraflags = d.getVar('FLAGS_GCC%d' % int(version), True)
-
- return ''.join(extraflags)
+ extraflags = d.getVar('FLAGS_GCC%d' % int(version), True) or ''
+ return extraflags
CFLAGS_append = " ${@version_specific_cflags(d)}"
CXXFLAGS_append = " ${@version_specific_cflags(d)}"
--
2.1.4
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [meta-java][PATCH] openjdk-8: fix compiler detection
2016-07-20 9:48 ` [meta-java][PATCH] openjdk-8: fix compiler detection Patrick Ohly
@ 2016-07-20 16:04 ` Dan McGregor
0 siblings, 0 replies; 4+ messages in thread
From: Dan McGregor @ 2016-07-20 16:04 UTC (permalink / raw)
To: openembeded-devel; +Cc: Patrick Ohly
On 20 July 2016 at 03:48, Patrick Ohly <patrick.ohly@intel.com> wrote:
> When GCC is at version 4 or 5, parsing the recipe fails with:
>
> ERROR: ExpansionError during parsing
> .../ostro-os/meta-java/recipes-core/openjdk/openjdk-8_72b05.bb
> ...
> bb.data_smart.ExpansionError: Failure expanding variable CFLAGS,
> expression was -O2 -pipe -g -feliminate-unused-debug-types
> -fdebug-prefix-map=.../ostro-os/build/tmp-glibc/work/corei7-64-ostro-
> linux/openjdk-8/72b05-r0=/usr/src/debug/openjdk-8/72b05-r0
> -fdebug-prefix-map=.../ostro-os/build/tmp-glibc/sysroots/x86_64-linux=
> -fdebug-prefix-map=.../ostro-os/build/tmp-glibc/sysroots/intel-corei7-64=
> -fstack-protector-strong -D_FORTIFY_SOURCE=2
> ${ <at> version_specific_cflags(d)} -Wno-error=deprecated-declarations which
> triggered exception TypeError: can only join an iterable
>
> That's because FLAGS_GCC<version> may be unset, thus leading to
> d.getVar() returning None and ''.join(extraflags) failing.
>
> The join() is also redundant: extraflags already is a string. It
> happened to work because Python treats a string as sequence of
> single-character strings, and thus ''.join() re-created the original
> string.
>
> Signed-off-by: Patrick Ohly <patrick.ohly@intel.com>
> ---
> recipes-core/openjdk/openjdk-8-common.inc | 6 ++----
> 1 file changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/recipes-core/openjdk/openjdk-8-common.inc b/recipes-core/openjdk/openjdk-8-common.inc
> index 089f907..7ad802a 100644
> --- a/recipes-core/openjdk/openjdk-8-common.inc
> +++ b/recipes-core/openjdk/openjdk-8-common.inc
> @@ -271,10 +271,8 @@ def version_specific_cflags(d):
> # doesn't work anyway.
> version = d.getVar('GCCVERSION', expand=True)[0]
>
> - if int(version) >= 4:
> - extraflags = d.getVar('FLAGS_GCC%d' % int(version), True)
> -
> - return ''.join(extraflags)
> + extraflags = d.getVar('FLAGS_GCC%d' % int(version), True) or ''
> + return extraflags
>
> CFLAGS_append = " ${@version_specific_cflags(d)}"
> CXXFLAGS_append = " ${@version_specific_cflags(d)}"
> --
> 2.1.4
This looks good to me. I have a patch up that does substantially
similar, but this one beat me to it. It's also better python.
I'm still going to check out icedtea 3's OpenJDK. Their build system
does this automatically, but going from the past cross-compiling it
may be an issue.
>
> --
> _______________________________________________
> Openembedded-devel mailing list
> Openembedded-devel@lists.openembedded.org
> http://lists.openembedded.org/mailman/listinfo/openembedded-devel
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2016-07-20 16:04 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-07-15 21:08 [meta-java][PATCH] openjdk-8: Detect compiler version Dan McGregor
2016-07-19 9:42 ` Patrick Ohly
2016-07-20 9:48 ` [meta-java][PATCH] openjdk-8: fix compiler detection Patrick Ohly
2016-07-20 16:04 ` Dan McGregor
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox