diff options
author | Richard Purdie <richard.purdie@linuxfoundation.org> | 2022-08-10 14:35:29 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2022-08-12 15:27:17 +0100 |
commit | fd1517e2b51a170f2427122c6b95396db251d827 (patch) | |
tree | dabfe3e631339c2fc99a9ee7febb0f9c128e325e /meta/classes-recipe/goarch.bbclass | |
parent | 10317912ee319ccf7f83605d438b5cbf9663f296 (diff) | |
download | poky-fd1517e2b51a170f2427122c6b95396db251d827.tar.gz |
classes: Update classes to match new bitbake class scope functionality
Move classes to classes-global or classes-recipe as appropriate to take
advantage of new bitbake functionality to check class scope/usage.
(From OE-Core rev: f5c128008365e141082c129417eb72d2751e8045)
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/classes-recipe/goarch.bbclass')
-rw-r--r-- | meta/classes-recipe/goarch.bbclass | 122 |
1 files changed, 122 insertions, 0 deletions
diff --git a/meta/classes-recipe/goarch.bbclass b/meta/classes-recipe/goarch.bbclass new file mode 100644 index 0000000000..61ead30a63 --- /dev/null +++ b/meta/classes-recipe/goarch.bbclass | |||
@@ -0,0 +1,122 @@ | |||
1 | # | ||
2 | # Copyright OpenEmbedded Contributors | ||
3 | # | ||
4 | # SPDX-License-Identifier: MIT | ||
5 | # | ||
6 | |||
7 | BUILD_GOOS = "${@go_map_os(d.getVar('BUILD_OS'), d)}" | ||
8 | BUILD_GOARCH = "${@go_map_arch(d.getVar('BUILD_ARCH'), d)}" | ||
9 | BUILD_GOTUPLE = "${BUILD_GOOS}_${BUILD_GOARCH}" | ||
10 | HOST_GOOS = "${@go_map_os(d.getVar('HOST_OS'), d)}" | ||
11 | HOST_GOARCH = "${@go_map_arch(d.getVar('HOST_ARCH'), d)}" | ||
12 | HOST_GOARM = "${@go_map_arm(d.getVar('HOST_ARCH'), d)}" | ||
13 | HOST_GO386 = "${@go_map_386(d.getVar('HOST_ARCH'), d.getVar('TUNE_FEATURES'), d)}" | ||
14 | HOST_GOMIPS = "${@go_map_mips(d.getVar('HOST_ARCH'), d.getVar('TUNE_FEATURES'), d)}" | ||
15 | HOST_GOARM:class-native = "7" | ||
16 | HOST_GO386:class-native = "sse2" | ||
17 | HOST_GOMIPS:class-native = "hardfloat" | ||
18 | HOST_GOTUPLE = "${HOST_GOOS}_${HOST_GOARCH}" | ||
19 | TARGET_GOOS = "${@go_map_os(d.getVar('TARGET_OS'), d)}" | ||
20 | TARGET_GOARCH = "${@go_map_arch(d.getVar('TARGET_ARCH'), d)}" | ||
21 | TARGET_GOARM = "${@go_map_arm(d.getVar('TARGET_ARCH'), d)}" | ||
22 | TARGET_GO386 = "${@go_map_386(d.getVar('TARGET_ARCH'), d.getVar('TUNE_FEATURES'), d)}" | ||
23 | TARGET_GOMIPS = "${@go_map_mips(d.getVar('TARGET_ARCH'), d.getVar('TUNE_FEATURES'), d)}" | ||
24 | TARGET_GOARM:class-native = "7" | ||
25 | TARGET_GO386:class-native = "sse2" | ||
26 | TARGET_GOMIPS:class-native = "hardfloat" | ||
27 | TARGET_GOTUPLE = "${TARGET_GOOS}_${TARGET_GOARCH}" | ||
28 | GO_BUILD_BINDIR = "${@['bin/${HOST_GOTUPLE}','bin'][d.getVar('BUILD_GOTUPLE') == d.getVar('HOST_GOTUPLE')]}" | ||
29 | |||
30 | # Use the MACHINEOVERRIDES to map ARM CPU architecture passed to GO via GOARM. | ||
31 | # This is combined with *_ARCH to set HOST_GOARM and TARGET_GOARM. | ||
32 | BASE_GOARM = '' | ||
33 | BASE_GOARM:armv7ve = '7' | ||
34 | BASE_GOARM:armv7a = '7' | ||
35 | BASE_GOARM:armv6 = '6' | ||
36 | BASE_GOARM:armv5 = '5' | ||
37 | |||
38 | # Go supports dynamic linking on a limited set of architectures. | ||
39 | # See the supportsDynlink function in go/src/cmd/compile/internal/gc/main.go | ||
40 | GO_DYNLINK = "" | ||
41 | GO_DYNLINK:arm ?= "1" | ||
42 | GO_DYNLINK:aarch64 ?= "1" | ||
43 | GO_DYNLINK:x86 ?= "1" | ||
44 | GO_DYNLINK:x86-64 ?= "1" | ||
45 | GO_DYNLINK:powerpc64 ?= "1" | ||
46 | GO_DYNLINK:powerpc64le ?= "1" | ||
47 | GO_DYNLINK:class-native ?= "" | ||
48 | GO_DYNLINK:class-nativesdk = "" | ||
49 | |||
50 | # define here because everybody inherits this class | ||
51 | # | ||
52 | COMPATIBLE_HOST:linux-gnux32 = "null" | ||
53 | COMPATIBLE_HOST:linux-muslx32 = "null" | ||
54 | COMPATIBLE_HOST:powerpc = "null" | ||
55 | COMPATIBLE_HOST:powerpc64 = "null" | ||
56 | COMPATIBLE_HOST:mipsarchn32 = "null" | ||
57 | |||
58 | ARM_INSTRUCTION_SET:armv4 = "arm" | ||
59 | ARM_INSTRUCTION_SET:armv5 = "arm" | ||
60 | ARM_INSTRUCTION_SET:armv6 = "arm" | ||
61 | |||
62 | TUNE_CCARGS:remove = "-march=mips32r2" | ||
63 | SECURITY_NOPIE_CFLAGS ??= "" | ||
64 | |||
65 | # go can't be built with ccache: | ||
66 | # gcc: fatal error: no input files | ||
67 | CCACHE_DISABLE ?= "1" | ||
68 | |||
69 | def go_map_arch(a, d): | ||
70 | import re | ||
71 | if re.match('i.86', a): | ||
72 | return '386' | ||
73 | elif a == 'x86_64': | ||
74 | return 'amd64' | ||
75 | elif re.match('arm.*', a): | ||
76 | return 'arm' | ||
77 | elif re.match('aarch64.*', a): | ||
78 | return 'arm64' | ||
79 | elif re.match('mips64el.*', a): | ||
80 | return 'mips64le' | ||
81 | elif re.match('mips64.*', a): | ||
82 | return 'mips64' | ||
83 | elif a == 'mips': | ||
84 | return 'mips' | ||
85 | elif a == 'mipsel': | ||
86 | return 'mipsle' | ||
87 | elif re.match('p(pc|owerpc)(64le)', a): | ||
88 | return 'ppc64le' | ||
89 | elif re.match('p(pc|owerpc)(64)', a): | ||
90 | return 'ppc64' | ||
91 | elif a == 'riscv64': | ||
92 | return 'riscv64' | ||
93 | else: | ||
94 | raise bb.parse.SkipRecipe("Unsupported CPU architecture: %s" % a) | ||
95 | |||
96 | def go_map_arm(a, d): | ||
97 | if a.startswith("arm"): | ||
98 | return d.getVar('BASE_GOARM') | ||
99 | return '' | ||
100 | |||
101 | def go_map_386(a, f, d): | ||
102 | import re | ||
103 | if re.match('i.86', a): | ||
104 | if ('core2' in f) or ('corei7' in f): | ||
105 | return 'sse2' | ||
106 | else: | ||
107 | return 'softfloat' | ||
108 | return '' | ||
109 | |||
110 | def go_map_mips(a, f, d): | ||
111 | import re | ||
112 | if a == 'mips' or a == 'mipsel': | ||
113 | if 'fpu-hard' in f: | ||
114 | return 'hardfloat' | ||
115 | else: | ||
116 | return 'softfloat' | ||
117 | return '' | ||
118 | |||
119 | def go_map_os(o, d): | ||
120 | if o.startswith('linux'): | ||
121 | return 'linux' | ||
122 | return o | ||