diff options
| -rw-r--r-- | classes/openjdk-build-helper.bbclass | 35 | ||||
| -rw-r--r-- | 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): | |||
| 14 | return 1 | 14 | return 1 |
| 15 | 15 | ||
| 16 | return pm.partition('-j')[2].strip().split(' ')[0] | 16 | return pm.partition('-j')[2].strip().split(' ')[0] |
| 17 | |||
| 18 | # All supported cross compilers support the compiler flags that were | ||
| 19 | # added to make compilation with gcc6 work. But the host compiler for | ||
| 20 | # native compilation is a different story: it may be too old (for example, | ||
| 21 | # gcc 4.9.2 on Debian Wheezy). In that case we need to check what the | ||
| 22 | # version is and only add the flags that are appropriate for that GCC | ||
| 23 | # version. | ||
| 24 | def openjdk_build_helper_get_cflags_by_cc_version(d, version): | ||
| 25 | if version.isdigit(): | ||
| 26 | return d.getVar('FLAGS_GCC%d' % int(version)) or '' | ||
| 27 | return '' | ||
| 28 | |||
| 29 | def openjdk_build_helper_get_build_cflags(d): | ||
| 30 | def get_build_cc_version(build_cc): | ||
| 31 | from subprocess import Popen, PIPE | ||
| 32 | cmd = d.expand('%s -dumpversion' % build_cc).split() | ||
| 33 | cc = Popen(cmd, stdout=PIPE, stderr=PIPE) | ||
| 34 | return cc.communicate()[0].decode('utf-8')[0] | ||
| 35 | |||
| 36 | build_cc = d.getVar('BUILD_CC') | ||
| 37 | version = get_build_cc_version(build_cc) | ||
| 38 | return openjdk_build_helper_get_cflags_by_cc_version(d, version) | ||
| 39 | |||
| 40 | def openjdk_build_helper_get_target_cflags(d): | ||
| 41 | import re | ||
| 42 | |||
| 43 | # in the cross case, trust that GCCVERSION is correct. This won't | ||
| 44 | # work if the native toolchain is Clang, but as of this writing that | ||
| 45 | # doesn't work anyway. | ||
| 46 | version = d.getVar('GCCVERSION')[0] | ||
| 47 | # skip non digit characters at the beginning, e.g. from "linaro-6.2%" | ||
| 48 | match = re.search("\d", version) | ||
| 49 | if match: | ||
| 50 | version = version[match.start():] | ||
| 51 | 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 0c77d7c..1c33a3b 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" | |||
| 219 | FLAGS_GCC7 = "-fno-lifetime-dse -fno-delete-null-pointer-checks" | 219 | FLAGS_GCC7 = "-fno-lifetime-dse -fno-delete-null-pointer-checks" |
| 220 | FLAGS_GCC8 = "-fno-lifetime-dse -fno-delete-null-pointer-checks -Wno-error=return-type" | 220 | FLAGS_GCC8 = "-fno-lifetime-dse -fno-delete-null-pointer-checks -Wno-error=return-type" |
| 221 | 221 | ||
| 222 | # All supported cross compilers support the compiler flags that were | ||
| 223 | # added to make compilation with gcc6 work. But the host compiler for | ||
| 224 | # native compilation is a different story: it may be too old (for example, | ||
| 225 | # gcc 4.9.2 on Debian Wheezy). In that case we need to check what the | ||
| 226 | # version is and only add the flags that are appropriate for that GCC | ||
| 227 | # version. | ||
| 228 | |||
| 229 | def get_cflags_by_cc_version(d, version): | ||
| 230 | if version.isdigit(): | ||
| 231 | return d.getVar('FLAGS_GCC%d' % int(version)) or '' | ||
| 232 | return '' | ||
| 233 | |||
| 234 | def get_build_cflags(d): | ||
| 235 | def get_build_cc_version(build_cc): | ||
| 236 | from subprocess import Popen, PIPE | ||
| 237 | cmd = d.expand('%s -dumpversion' % build_cc).split() | ||
| 238 | cc = Popen(cmd, stdout=PIPE, stderr=PIPE) | ||
| 239 | return cc.communicate()[0].decode('utf-8')[0] | ||
| 240 | |||
| 241 | build_cc = d.getVar('BUILD_CC') | ||
| 242 | version = get_build_cc_version(build_cc) | ||
| 243 | return get_cflags_by_cc_version(d, version) | ||
| 244 | |||
| 245 | def get_target_cflags(d): | ||
| 246 | import re | ||
| 247 | |||
| 248 | # in the cross case, trust that GCCVERSION is correct. This won't | ||
| 249 | # work if the native toolchain is Clang, but as of this writing that | ||
| 250 | # doesn't work anyway. | ||
| 251 | version = d.getVar('GCCVERSION')[0] | ||
| 252 | # skip non digit characters at the beginning, e.g. from "linaro-6.2%" | ||
| 253 | match = re.search("\d", version) | ||
| 254 | if match: | ||
| 255 | version = version[match.start():] | ||
| 256 | return get_cflags_by_cc_version(d, version) | ||
| 257 | |||
| 258 | |||
| 259 | # flags for -native, and for bits that need a host-tool during -cross | 222 | # flags for -native, and for bits that need a host-tool during -cross |
| 260 | BUILD_CFLAGS_append = " ${@get_build_cflags(d)}" | 223 | BUILD_CFLAGS_append = " ${@openjdk_build_helper_get_build_cflags(d)}" |
| 261 | BUILD_CXXFLAGS_append = " ${@get_build_cflags(d)}" | 224 | BUILD_CXXFLAGS_append = " ${@openjdk_build_helper_get_build_cflags(d)}" |
| 262 | # flags for -cross | 225 | # flags for -cross |
| 263 | TARGET_CFLAGS_append = " ${@get_target_cflags(d)}" | 226 | TARGET_CFLAGS_append = " ${@openjdk_build_helper_get_target_cflags(d)}" |
| 264 | TARGET_CXXFLAGS_append = " ${@get_target_cflags(d)}" | 227 | TARGET_CXXFLAGS_append = " ${@openjdk_build_helper_get_target_cflags(d)}" |
