From: Dan McGregor <danismostlikely@gmail.com>
To: openembedded-devel@lists.openembedded.org
Subject: [meta-java][PATCH] openjdk-8: Detect compiler version
Date: Fri, 15 Jul 2016 15:08:20 -0600 [thread overview]
Message-ID: <20160715210820.6801-1-danismostlikely@gmail.com> (raw)
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
next reply other threads:[~2016-07-15 21:08 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-07-15 21:08 Dan McGregor [this message]
2016-07-19 9:42 ` [meta-java][PATCH] openjdk-8: Detect compiler version Patrick Ohly
2016-07-20 9:48 ` [meta-java][PATCH] openjdk-8: fix compiler detection Patrick Ohly
2016-07-20 16:04 ` Dan McGregor
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20160715210820.6801-1-danismostlikely@gmail.com \
--to=danismostlikely@gmail.com \
--cc=openembedded-devel@lists.openembedded.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox