blob: 92fec16b82976a9c28556805850e89f3f2cf7621 [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)}"
Patrick Williams213cb262021-08-07 19:21:33 -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)}"
Patrick Williams213cb262021-08-07 19:21:33 -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 = ''
Patrick Williams213cb262021-08-07 19:21:33 -050027BASE_GOARM:armv7ve = '7'
28BASE_GOARM:armv7a = '7'
29BASE_GOARM:armv6 = '6'
30BASE_GOARM:armv5 = '5'
Brad Bishopd89cb5f2019-04-10 09:02:41 -040031
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 = ""
Andrew Geisslerd159c7f2021-09-02 21:05:58 -050035GO_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 ?= ""
Patrick Williams213cb262021-08-07 19:21:33 -050042GO_DYNLINK:class-nativesdk = ""
Brad Bishopd7bf8c12018-02-25 22:55:05 -050043
44# define here because everybody inherits this class
45#
Patrick Williams213cb262021-08-07 19:21:33 -050046COMPATIBLE_HOST:linux-gnux32 = "null"
47COMPATIBLE_HOST:linux-muslx32 = "null"
48COMPATIBLE_HOST:powerpc = "null"
49COMPATIBLE_HOST:powerpc64 = "null"
50COMPATIBLE_HOST:mipsarchn32 = "null"
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080051
Patrick Williams213cb262021-08-07 19:21:33 -050052ARM_INSTRUCTION_SET:armv4 = "arm"
53ARM_INSTRUCTION_SET:armv5 = "arm"
54ARM_INSTRUCTION_SET:armv6 = "arm"
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080055
Patrick Williams213cb262021-08-07 19:21:33 -050056TUNE_CCARGS:remove = "-march=mips32r2"
Brad Bishop316dfdd2018-06-25 12:45:53 -040057SECURITY_NOPIE_CFLAGS ??= ""
Brad Bishop6e60e8b2018-02-01 10:27:11 -050058
Brad Bishop19323692019-04-05 15:28:33 -040059# go can't be built with ccache:
60# gcc: fatal error: no input files
61CCACHE_DISABLE ?= "1"
62
Brad Bishop6e60e8b2018-02-01 10:27:11 -050063def 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'
Brad Bishopd7bf8c12018-02-25 22:55:05 -050073 elif re.match('mips64el.*', a):
Brad Bishop6e60e8b2018-02-01 10:27:11 -050074 return 'mips64le'
Brad Bishopd7bf8c12018-02-25 22:55:05 -050075 elif re.match('mips64.*', a):
Brad Bishop6e60e8b2018-02-01 10:27:11 -050076 return 'mips64'
Brad Bishopd7bf8c12018-02-25 22:55:05 -050077 elif a == 'mips':
Brad Bishop6e60e8b2018-02-01 10:27:11 -050078 return 'mips'
Brad Bishopd7bf8c12018-02-25 22:55:05 -050079 elif a == 'mipsel':
80 return 'mipsle'
Andrew Geissler90fd73c2021-03-05 15:25:55 -060081 elif re.match('p(pc|owerpc)(64le)', a):
82 return 'ppc64le'
Brad Bishop6e60e8b2018-02-01 10:27:11 -050083 elif re.match('p(pc|owerpc)(64)', a):
84 return 'ppc64'
Brad Bishop19323692019-04-05 15:28:33 -040085 elif a == 'riscv64':
86 return 'riscv64'
Brad Bishop6e60e8b2018-02-01 10:27:11 -050087 else:
Brad Bishop316dfdd2018-06-25 12:45:53 -040088 raise bb.parse.SkipRecipe("Unsupported CPU architecture: %s" % a)
Brad Bishop6e60e8b2018-02-01 10:27:11 -050089
Brad Bishopc342db32019-05-15 21:57:59 -040090def go_map_arm(a, d):
91 if a.startswith("arm"):
92 return d.getVar('BASE_GOARM')
Brad Bishopd7bf8c12018-02-25 22:55:05 -050093 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:
Andrew Geissler90fd73c2021-03-05 15:25:55 -0600101 return 'softfloat'
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500102 return ''
103
Brad Bishop316dfdd2018-06-25 12:45:53 -0400104def 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
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500113def go_map_os(o, d):
114 if o.startswith('linux'):
115 return 'linux'
116 return o