summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndré Draszik <andre.draszik@jci.com>2018-08-13 11:09:31 +0100
committerRichard Leitner <richard.leitner@skidata.com>2018-08-13 14:57:45 +0200
commit050229916257fdc57d887a67a57c2ab330051717 (patch)
tree045081c6a62497851ed8fead0ef39a4d2a9213c2
parent8ffbe8755cfa7b2088c415e2d649c64af8ee5167 (diff)
downloadmeta-java-050229916257fdc57d887a67a57c2ab330051717.tar.gz
openjdk-8: fix infrastructure for version host gcc != cross gcc (again)
Building OpenJDK-8 (target) with an older host compiler (gcc < 6) does not work as the build errors with error messages regarding unrecognized gcc command line options. As part of the (cross) build particularly, OpenJDK-8 builds a host tool (adlc) using the host gcc. We have a patch, openjdk8-fix-adlc-flags.patch, that tries to make the adlc build use the correct / intended compiler flags. This doesn't work right now, as that build still sees compiler flags intended for / understood by the gcc version used for the actual cross compile only. The reason is that while we have infrastructure in place to add compiler flags based on the compiler version, we add all of them unconditionally to CFLAGS / CXXFLAGS directly but above patch uses TARGET_CFLAGS / TARGET_CXXFLAGS to filter out unwanted BUILD_CFLAGS / BUILD_CXXFLAGS from CFLAGS / CXXFLAGS, In other words above patch cannot do what it intends to do and all compiler version specific flags (-fno-lifetime-dse & -fno-delete-null-pointer-checks) end up in CFLAGS / CXXFLAGS. So far, this was only affecting people using host gcc < 6, but upcoming patches adding support for gcc >= 8 will add even more compiler flags that even gcc < 7 don't support - it's time to finally address this. We fix the issue by adding the compiler version specific flags to BUILD_CFLAGS / BUILD_CXXFLAGS and TARGET_CFLAGS / TARGET_CXXFLAGS as necessary, so that above patch can work as intended. We now support all necessary combinations: * -native builds * -target builds * host tools built using the native compiler during the -target build A similar but different patch existed here before as commit 6801f6d4e19c ("openjdk-8-common: Fix the issue of building failed adlc on host with gcc < 6") but was reverted subsequently due to reportedly still(?) having (new?) issues with older compilers. This patch here is different from the older patch in that it *doesn't* set the cflags during a python_anonymous() function, and thus it guarantees deterministic execution order. This change here was tested to work using host gcc versions 4.8.4 and 6.3.0 and 7.3.0 Signed-off-by: André Draszik <andre.draszik@jci.com> Signed-off-by: Richard Leitner <richard.leitner@skidata.com>
-rw-r--r--recipes-core/openjdk/openjdk-8-common.inc55
-rw-r--r--recipes-core/openjdk/openjdk-8-release-16xbyy.inc3
2 files changed, 33 insertions, 25 deletions
diff --git a/recipes-core/openjdk/openjdk-8-common.inc b/recipes-core/openjdk/openjdk-8-common.inc
index ad39dee..744c062 100644
--- a/recipes-core/openjdk/openjdk-8-common.inc
+++ b/recipes-core/openjdk/openjdk-8-common.inc
@@ -224,32 +224,39 @@ FLAGS_GCC7 = "-fno-lifetime-dse -fno-delete-null-pointer-checks"
224# version is and only add the flags that are appropriate for that GCC 224# version is and only add the flags that are appropriate for that GCC
225# version. 225# version.
226 226
227def version_specific_cflags(d): 227def get_cflags_by_cc_version(d, version):
228 import re 228 if version.isdigit():
229 229 return d.getVar('FLAGS_GCC%d' % int(version)) or ''
230 extraflags = None 230 return ''
231 version = None
232 231
233 if bb.data.inherits_class('native', d): 232def get_build_cflags(d):
233 def get_build_cc_version(build_cc):
234 from subprocess import Popen, PIPE 234 from subprocess import Popen, PIPE
235 235 cmd = d.expand('%s -dumpversion' % build_cc).split()
236 cmd = d.expand('${CC} -dumpversion').split()
237 cc = Popen(cmd, stdout=PIPE, stderr=PIPE) 236 cc = Popen(cmd, stdout=PIPE, stderr=PIPE)
238 version = cc.communicate()[0].decode('utf-8')[0] 237 return cc.communicate()[0].decode('utf-8')[0]
239 else:
240 # in the cross case, trust that GCCVERSION is correct. This won't
241 # work if the native toolchain is Clang, but as of this writing that
242 # doesn't work anyway.
243 version = d.getVar('GCCVERSION', expand=True)[0]
244 # skip non digit characters at the beginning, e.g. from "linaro-6.2%"
245 match = re.search("\d", version)
246 if match:
247 version = version[match.start():]
248 238
249 if version.isdigit(): 239 build_cc = d.getVar('BUILD_CC')
250 extraflags = d.getVar('FLAGS_GCC%d' % int(version), True) or '' 240 version = get_build_cc_version(build_cc)
251 return extraflags 241 return get_cflags_by_cc_version(d, version)
252 return '' 242
243def get_target_cflags(d):
244 import re
253 245
254CFLAGS_append = " ${@version_specific_cflags(d)}" 246 # in the cross case, trust that GCCVERSION is correct. This won't
255CXXFLAGS_append = " ${@version_specific_cflags(d)}" 247 # work if the native toolchain is Clang, but as of this writing that
248 # doesn't work anyway.
249 version = d.getVar('GCCVERSION')[0]
250 # skip non digit characters at the beginning, e.g. from "linaro-6.2%"
251 match = re.search("\d", version)
252 if match:
253 version = version[match.start():]
254 return get_cflags_by_cc_version(d, version)
255
256
257# flags for -native, and for bits that need a host-tool during -cross
258BUILD_CFLAGS_append = " ${@get_build_cflags(d)}"
259BUILD_CXXFLAGS_append = " ${@get_build_cflags(d)}"
260# flags for -cross
261TARGET_CFLAGS_append = " ${@get_target_cflags(d)}"
262TARGET_CXXFLAGS_append = " ${@get_target_cflags(d)}"
diff --git a/recipes-core/openjdk/openjdk-8-release-16xbyy.inc b/recipes-core/openjdk/openjdk-8-release-16xbyy.inc
index fd95e95..36ce073 100644
--- a/recipes-core/openjdk/openjdk-8-release-16xbyy.inc
+++ b/recipes-core/openjdk/openjdk-8-release-16xbyy.inc
@@ -54,7 +54,8 @@ ARM_INSTRUCTION_SET_armv4t = "ARM"
54 54
55# readdir_r was deprecated in glibc-2.24. Ignore the error for now 55# readdir_r was deprecated in glibc-2.24. Ignore the error for now
56# NOTE: When updating the recipe, please check if this is still needed 56# NOTE: When updating the recipe, please check if this is still needed
57CFLAGS_append = " -Wno-error=deprecated-declarations" 57BUILD_CFLAGS_append = " -Wno-error=deprecated-declarations"
58TARGET_CFLAGS_append = " -Wno-error=deprecated-declarations"
58 59
59# Enable zero mode for arm based builds, as normal hotspot fails to build 60# Enable zero mode for arm based builds, as normal hotspot fails to build
60PACKAGECONFIG_append_arm = " zero" 61PACKAGECONFIG_append_arm = " zero"