summaryrefslogtreecommitdiffstats
path: root/classes
diff options
context:
space:
mode:
authorAndré Draszik <andre.draszik@jci.com>2018-08-13 16:09:18 +0100
committerRichard Leitner <dev@g0hl1n.net>2018-08-13 22:55:05 +0200
commitbb3dcf4228fb457939680dc9df3df2bda681abfb (patch)
treeb282afae242e3d8c4b4ea988f783aee6010fc383 /classes
parent3c710bf3a90fde0cf6d590ffefc349bfb9a1c677 (diff)
downloadmeta-java-bb3dcf4228fb457939680dc9df3df2bda681abfb.tar.gz
openjdk-build-helper: move c compiler flags retrieval to here (from openjdk-8)
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> Signed-off-by: Richard Leitner <richard.leitner@skidata.com>
Diffstat (limited to 'classes')
-rw-r--r--classes/openjdk-build-helper.bbclass35
1 files changed, 35 insertions, 0 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.
24def 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
29def 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
40def 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)