xref: /OK3568_Linux_fs/yocto/poky/meta/classes/goarch.bbclass (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1BUILD_GOOS = "${@go_map_os(d.getVar('BUILD_OS'), d)}"
2BUILD_GOARCH = "${@go_map_arch(d.getVar('BUILD_ARCH'), d)}"
3BUILD_GOTUPLE = "${BUILD_GOOS}_${BUILD_GOARCH}"
4HOST_GOOS = "${@go_map_os(d.getVar('HOST_OS'), d)}"
5HOST_GOARCH = "${@go_map_arch(d.getVar('HOST_ARCH'), d)}"
6HOST_GOARM = "${@go_map_arm(d.getVar('HOST_ARCH'), d)}"
7HOST_GO386 = "${@go_map_386(d.getVar('HOST_ARCH'), d.getVar('TUNE_FEATURES'), d)}"
8HOST_GOMIPS = "${@go_map_mips(d.getVar('HOST_ARCH'), d.getVar('TUNE_FEATURES'), d)}"
9HOST_GOARM:class-native = "7"
10HOST_GO386:class-native = "sse2"
11HOST_GOMIPS:class-native = "hardfloat"
12HOST_GOTUPLE = "${HOST_GOOS}_${HOST_GOARCH}"
13TARGET_GOOS = "${@go_map_os(d.getVar('TARGET_OS'), d)}"
14TARGET_GOARCH = "${@go_map_arch(d.getVar('TARGET_ARCH'), d)}"
15TARGET_GOARM = "${@go_map_arm(d.getVar('TARGET_ARCH'), d)}"
16TARGET_GO386 = "${@go_map_386(d.getVar('TARGET_ARCH'), d.getVar('TUNE_FEATURES'), d)}"
17TARGET_GOMIPS = "${@go_map_mips(d.getVar('TARGET_ARCH'), d.getVar('TUNE_FEATURES'), d)}"
18TARGET_GOARM:class-native = "7"
19TARGET_GO386:class-native = "sse2"
20TARGET_GOMIPS:class-native = "hardfloat"
21TARGET_GOTUPLE = "${TARGET_GOOS}_${TARGET_GOARCH}"
22GO_BUILD_BINDIR = "${@['bin/${HOST_GOTUPLE}','bin'][d.getVar('BUILD_GOTUPLE') == d.getVar('HOST_GOTUPLE')]}"
23
24# Use the MACHINEOVERRIDES to map ARM CPU architecture passed to GO via GOARM.
25# This is combined with *_ARCH to set HOST_GOARM and TARGET_GOARM.
26BASE_GOARM = ''
27BASE_GOARM:armv7ve = '7'
28BASE_GOARM:armv7a = '7'
29BASE_GOARM:armv6 = '6'
30BASE_GOARM:armv5 = '5'
31
32# Go supports dynamic linking on a limited set of architectures.
33# See the supportsDynlink function in go/src/cmd/compile/internal/gc/main.go
34GO_DYNLINK = ""
35GO_DYNLINK:arm ?= "1"
36GO_DYNLINK:aarch64 ?= "1"
37GO_DYNLINK:x86 ?= "1"
38GO_DYNLINK:x86-64 ?= "1"
39GO_DYNLINK:powerpc64 ?= "1"
40GO_DYNLINK:powerpc64le ?= "1"
41GO_DYNLINK:class-native ?= ""
42GO_DYNLINK:class-nativesdk = ""
43
44# define here because everybody inherits this class
45#
46COMPATIBLE_HOST:linux-gnux32 = "null"
47COMPATIBLE_HOST:linux-muslx32 = "null"
48COMPATIBLE_HOST:powerpc = "null"
49COMPATIBLE_HOST:powerpc64 = "null"
50COMPATIBLE_HOST:mipsarchn32 = "null"
51
52ARM_INSTRUCTION_SET:armv4 = "arm"
53ARM_INSTRUCTION_SET:armv5 = "arm"
54ARM_INSTRUCTION_SET:armv6 = "arm"
55
56TUNE_CCARGS:remove = "-march=mips32r2"
57SECURITY_NOPIE_CFLAGS ??= ""
58
59# go can't be built with ccache:
60# gcc: fatal error: no input files
61CCACHE_DISABLE ?= "1"
62
63def go_map_arch(a, d):
64    import re
65    if re.match('i.86', a):
66        return '386'
67    elif a == 'x86_64':
68        return 'amd64'
69    elif re.match('arm.*', a):
70        return 'arm'
71    elif re.match('aarch64.*', a):
72        return 'arm64'
73    elif re.match('mips64el.*', a):
74        return 'mips64le'
75    elif re.match('mips64.*', a):
76        return 'mips64'
77    elif a == 'mips':
78        return 'mips'
79    elif a == 'mipsel':
80        return 'mipsle'
81    elif re.match('p(pc|owerpc)(64le)', a):
82        return 'ppc64le'
83    elif re.match('p(pc|owerpc)(64)', a):
84        return 'ppc64'
85    elif a == 'riscv64':
86        return 'riscv64'
87    else:
88        raise bb.parse.SkipRecipe("Unsupported CPU architecture: %s" % a)
89
90def go_map_arm(a, d):
91    if a.startswith("arm"):
92        return d.getVar('BASE_GOARM')
93    return ''
94
95def go_map_386(a, f, d):
96    import re
97    if re.match('i.86', a):
98        if ('core2' in f) or ('corei7' in f):
99            return 'sse2'
100        else:
101            return 'softfloat'
102    return ''
103
104def go_map_mips(a, f, d):
105    import re
106    if a == 'mips' or a == 'mipsel':
107        if 'fpu-hard' in f:
108            return 'hardfloat'
109        else:
110            return 'softfloat'
111    return ''
112
113def go_map_os(o, d):
114    if o.startswith('linux'):
115        return 'linux'
116    return o
117