blob: 1099b9576994f1786ef5e6ede51eabab32e9b994 [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 Bishopc342db32019-05-15 21:57:59 -04006HOST_GOARM = "${@go_map_arm(d.getVar('HOST_ARCH'), 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)}"
Andrew Geissler82c905d2020-04-13 13:39:40 -05009HOST_GOARM_class-native = "7"
10HOST_GO386_class-native = "sse2"
11HOST_GOMIPS_class-native = "hardfloat"
Brad Bishop6e60e8b2018-02-01 10:27:11 -050012HOST_GOTUPLE = "${HOST_GOOS}_${HOST_GOARCH}"
Brad Bishopd7bf8c12018-02-25 22:55:05 -050013TARGET_GOOS = "${@go_map_os(d.getVar('TARGET_OS'), d)}"
14TARGET_GOARCH = "${@go_map_arch(d.getVar('TARGET_ARCH'), d)}"
Brad Bishopc342db32019-05-15 21:57:59 -040015TARGET_GOARM = "${@go_map_arm(d.getVar('TARGET_ARCH'), d)}"
Brad Bishopd7bf8c12018-02-25 22:55:05 -050016TARGET_GO386 = "${@go_map_386(d.getVar('TARGET_ARCH'), d.getVar('TUNE_FEATURES'), d)}"
Brad Bishop316dfdd2018-06-25 12:45:53 -040017TARGET_GOMIPS = "${@go_map_mips(d.getVar('TARGET_ARCH'), d.getVar('TUNE_FEATURES'), d)}"
Andrew Geissler82c905d2020-04-13 13:39:40 -050018TARGET_GOARM_class-native = "7"
19TARGET_GO386_class-native = "sse2"
20TARGET_GOMIPS_class-native = "hardfloat"
Brad Bishop6e60e8b2018-02-01 10:27:11 -050021TARGET_GOTUPLE = "${TARGET_GOOS}_${TARGET_GOARCH}"
Brad Bishopd7bf8c12018-02-25 22:55:05 -050022GO_BUILD_BINDIR = "${@['bin/${HOST_GOTUPLE}','bin'][d.getVar('BUILD_GOTUPLE') == d.getVar('HOST_GOTUPLE')]}"
23
Brad Bishopd89cb5f2019-04-10 09:02:41 -040024# 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
Brad Bishopd7bf8c12018-02-25 22:55:05 -050032# 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"
Andrew Geissler82c905d2020-04-13 13:39:40 -050040GO_DYNLINK_powerpc64le = "1"
Brad Bishopd7bf8c12018-02-25 22:55:05 -050041GO_DYNLINK_class-native = ""
Brad Bishop316dfdd2018-06-25 12:45:53 -040042GO_DYNLINK_class-nativesdk = ""
Brad Bishopd7bf8c12018-02-25 22:55:05 -050043
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"
Andrew Geissler82c905d2020-04-13 13:39:40 -050050COMPATIBLE_HOST_powerpc64le = "null"
Brad Bishopd7bf8c12018-02-25 22:55:05 -050051COMPATIBLE_HOST_mipsarchn32 = "null"
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080052
53ARM_INSTRUCTION_SET_armv4 = "arm"
54ARM_INSTRUCTION_SET_armv5 = "arm"
55ARM_INSTRUCTION_SET_armv6 = "arm"
56
Brad Bishopd7bf8c12018-02-25 22:55:05 -050057TUNE_CCARGS_remove = "-march=mips32r2"
Brad Bishop316dfdd2018-06-25 12:45:53 -040058SECURITY_NOPIE_CFLAGS ??= ""
Brad Bishop6e60e8b2018-02-01 10:27:11 -050059
Brad Bishop19323692019-04-05 15:28:33 -040060# go can't be built with ccache:
61# gcc: fatal error: no input files
62CCACHE_DISABLE ?= "1"
63
Brad Bishop6e60e8b2018-02-01 10:27:11 -050064def go_map_arch(a, d):
65 import re
66 if re.match('i.86', a):
67 return '386'
68 elif a == 'x86_64':
69 return 'amd64'
70 elif re.match('arm.*', a):
71 return 'arm'
72 elif re.match('aarch64.*', a):
73 return 'arm64'
Brad Bishopd7bf8c12018-02-25 22:55:05 -050074 elif re.match('mips64el.*', a):
Brad Bishop6e60e8b2018-02-01 10:27:11 -050075 return 'mips64le'
Brad Bishopd7bf8c12018-02-25 22:55:05 -050076 elif re.match('mips64.*', a):
Brad Bishop6e60e8b2018-02-01 10:27:11 -050077 return 'mips64'
Brad Bishopd7bf8c12018-02-25 22:55:05 -050078 elif a == 'mips':
Brad Bishop6e60e8b2018-02-01 10:27:11 -050079 return 'mips'
Brad Bishopd7bf8c12018-02-25 22:55:05 -050080 elif a == 'mipsel':
81 return 'mipsle'
Brad Bishop6e60e8b2018-02-01 10:27:11 -050082 elif re.match('p(pc|owerpc)(64)', a):
83 return 'ppc64'
84 elif re.match('p(pc|owerpc)(64el)', a):
85 return 'ppc64le'
Brad Bishop19323692019-04-05 15:28:33 -040086 elif a == 'riscv64':
87 return 'riscv64'
Brad Bishop6e60e8b2018-02-01 10:27:11 -050088 else:
Brad Bishop316dfdd2018-06-25 12:45:53 -040089 raise bb.parse.SkipRecipe("Unsupported CPU architecture: %s" % a)
Brad Bishop6e60e8b2018-02-01 10:27:11 -050090
Brad Bishopc342db32019-05-15 21:57:59 -040091def go_map_arm(a, d):
92 if a.startswith("arm"):
93 return d.getVar('BASE_GOARM')
Brad Bishopd7bf8c12018-02-25 22:55:05 -050094 return ''
95
96def go_map_386(a, f, d):
97 import re
98 if re.match('i.86', a):
99 if ('core2' in f) or ('corei7' in f):
100 return 'sse2'
101 else:
102 return '387'
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500103 return ''
104
Brad Bishop316dfdd2018-06-25 12:45:53 -0400105def go_map_mips(a, f, d):
106 import re
107 if a == 'mips' or a == 'mipsel':
108 if 'fpu-hard' in f:
109 return 'hardfloat'
110 else:
111 return 'softfloat'
112 return ''
113
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500114def go_map_os(o, d):
115 if o.startswith('linux'):
116 return 'linux'
117 return o
118
119