blob: 909646b8d476ae1a15d0bbe1b8089650a6a3bf2d [file] [log] [blame]
Brad Bishopd7bf8c12018-02-25 22:55:05 -05001BUILD_GOOS = "${@go_map_os(d.getVar('BUILD_OS'), d)}"
2BUILD_GOARCH = "${@go_map_arch(d.getVar('BUILD_ARCH'), d)}"
Brad Bishop6e60e8b2018-02-01 10:27:11 -05003BUILD_GOTUPLE = "${BUILD_GOOS}_${BUILD_GOARCH}"
Brad Bishopd7bf8c12018-02-25 22:55:05 -05004HOST_GOOS = "${@go_map_os(d.getVar('HOST_OS'), d)}"
5HOST_GOARCH = "${@go_map_arch(d.getVar('HOST_ARCH'), d)}"
Brad Bishopd89cb5f2019-04-10 09:02:41 -04006HOST_GOARM = "${@go_map_arm(d.getVar('HOST_ARCH'), d.getVar('BASE_GOARM'), d)}"
Brad Bishopd7bf8c12018-02-25 22:55:05 -05007HOST_GO386 = "${@go_map_386(d.getVar('HOST_ARCH'), d.getVar('TUNE_FEATURES'), d)}"
Brad Bishop316dfdd2018-06-25 12:45:53 -04008HOST_GOMIPS = "${@go_map_mips(d.getVar('HOST_ARCH'), d.getVar('TUNE_FEATURES'), d)}"
Brad Bishop6e60e8b2018-02-01 10:27:11 -05009HOST_GOTUPLE = "${HOST_GOOS}_${HOST_GOARCH}"
Brad Bishopd7bf8c12018-02-25 22:55:05 -050010TARGET_GOOS = "${@go_map_os(d.getVar('TARGET_OS'), d)}"
11TARGET_GOARCH = "${@go_map_arch(d.getVar('TARGET_ARCH'), d)}"
Brad Bishopd89cb5f2019-04-10 09:02:41 -040012TARGET_GOARM = "${@go_map_arm(d.getVar('TARGET_ARCH'), d.getVar('BASE_GOARM'), d)}"
Brad Bishopd7bf8c12018-02-25 22:55:05 -050013TARGET_GO386 = "${@go_map_386(d.getVar('TARGET_ARCH'), d.getVar('TUNE_FEATURES'), d)}"
Brad Bishop316dfdd2018-06-25 12:45:53 -040014TARGET_GOMIPS = "${@go_map_mips(d.getVar('TARGET_ARCH'), d.getVar('TUNE_FEATURES'), d)}"
Brad Bishop6e60e8b2018-02-01 10:27:11 -050015TARGET_GOTUPLE = "${TARGET_GOOS}_${TARGET_GOARCH}"
Brad Bishopd7bf8c12018-02-25 22:55:05 -050016GO_BUILD_BINDIR = "${@['bin/${HOST_GOTUPLE}','bin'][d.getVar('BUILD_GOTUPLE') == d.getVar('HOST_GOTUPLE')]}"
17
Brad Bishopd89cb5f2019-04-10 09:02:41 -040018# Use the MACHINEOVERRIDES to map ARM CPU architecture passed to GO via GOARM.
19# This is combined with *_ARCH to set HOST_GOARM and TARGET_GOARM.
20BASE_GOARM = ''
21BASE_GOARM_armv7ve = '7'
22BASE_GOARM_armv7a = '7'
23BASE_GOARM_armv6 = '6'
24BASE_GOARM_armv5 = '5'
25
Brad Bishopd7bf8c12018-02-25 22:55:05 -050026# Go supports dynamic linking on a limited set of architectures.
27# See the supportsDynlink function in go/src/cmd/compile/internal/gc/main.go
28GO_DYNLINK = ""
29GO_DYNLINK_arm = "1"
30GO_DYNLINK_aarch64 = "1"
31GO_DYNLINK_x86 = "1"
32GO_DYNLINK_x86-64 = "1"
33GO_DYNLINK_powerpc64 = "1"
34GO_DYNLINK_class-native = ""
Brad Bishop316dfdd2018-06-25 12:45:53 -040035GO_DYNLINK_class-nativesdk = ""
Brad Bishopd7bf8c12018-02-25 22:55:05 -050036
37# define here because everybody inherits this class
38#
39COMPATIBLE_HOST_linux-gnux32 = "null"
40COMPATIBLE_HOST_linux-muslx32 = "null"
41COMPATIBLE_HOST_powerpc = "null"
42COMPATIBLE_HOST_powerpc64 = "null"
43COMPATIBLE_HOST_mipsarchn32 = "null"
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080044
45ARM_INSTRUCTION_SET_armv4 = "arm"
46ARM_INSTRUCTION_SET_armv5 = "arm"
47ARM_INSTRUCTION_SET_armv6 = "arm"
48
Brad Bishopd7bf8c12018-02-25 22:55:05 -050049TUNE_CCARGS_remove = "-march=mips32r2"
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080050SECURITY_CFLAGS_mipsarch = "${SECURITY_NOPIE_CFLAGS}"
Brad Bishop316dfdd2018-06-25 12:45:53 -040051SECURITY_NOPIE_CFLAGS ??= ""
Brad Bishop6e60e8b2018-02-01 10:27:11 -050052
Brad Bishop19323692019-04-05 15:28:33 -040053# go can't be built with ccache:
54# gcc: fatal error: no input files
55CCACHE_DISABLE ?= "1"
56
Brad Bishop6e60e8b2018-02-01 10:27:11 -050057def go_map_arch(a, d):
58 import re
59 if re.match('i.86', a):
60 return '386'
61 elif a == 'x86_64':
62 return 'amd64'
63 elif re.match('arm.*', a):
64 return 'arm'
65 elif re.match('aarch64.*', a):
66 return 'arm64'
Brad Bishopd7bf8c12018-02-25 22:55:05 -050067 elif re.match('mips64el.*', a):
Brad Bishop6e60e8b2018-02-01 10:27:11 -050068 return 'mips64le'
Brad Bishopd7bf8c12018-02-25 22:55:05 -050069 elif re.match('mips64.*', a):
Brad Bishop6e60e8b2018-02-01 10:27:11 -050070 return 'mips64'
Brad Bishopd7bf8c12018-02-25 22:55:05 -050071 elif a == 'mips':
Brad Bishop6e60e8b2018-02-01 10:27:11 -050072 return 'mips'
Brad Bishopd7bf8c12018-02-25 22:55:05 -050073 elif a == 'mipsel':
74 return 'mipsle'
Brad Bishop6e60e8b2018-02-01 10:27:11 -050075 elif re.match('p(pc|owerpc)(64)', a):
76 return 'ppc64'
77 elif re.match('p(pc|owerpc)(64el)', a):
78 return 'ppc64le'
Brad Bishop19323692019-04-05 15:28:33 -040079 elif a == 'riscv64':
80 return 'riscv64'
Brad Bishop6e60e8b2018-02-01 10:27:11 -050081 else:
Brad Bishop316dfdd2018-06-25 12:45:53 -040082 raise bb.parse.SkipRecipe("Unsupported CPU architecture: %s" % a)
Brad Bishop6e60e8b2018-02-01 10:27:11 -050083
84def go_map_arm(a, f, d):
85 import re
86 if re.match('arm.*', a):
Brad Bishopd89cb5f2019-04-10 09:02:41 -040087 return f
Brad Bishopd7bf8c12018-02-25 22:55:05 -050088 return ''
89
90def go_map_386(a, f, d):
91 import re
92 if re.match('i.86', a):
93 if ('core2' in f) or ('corei7' in f):
94 return 'sse2'
95 else:
96 return '387'
Brad Bishop6e60e8b2018-02-01 10:27:11 -050097 return ''
98
Brad Bishop316dfdd2018-06-25 12:45:53 -040099def go_map_mips(a, f, d):
100 import re
101 if a == 'mips' or a == 'mipsel':
102 if 'fpu-hard' in f:
103 return 'hardfloat'
104 else:
105 return 'softfloat'
106 return ''
107
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500108def go_map_os(o, d):
109 if o.startswith('linux'):
110 return 'linux'
111 return o
112
113