blob: b2c94faddb7e0eadf09d718dd0bb2cfd4e0791b5 [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)}"
6HOST_GOARM = "${@go_map_arm(d.getVar('HOST_ARCH'), d.getVar('TUNE_FEATURES'), d)}"
7HOST_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)}"
12TARGET_GOARM = "${@go_map_arm(d.getVar('TARGET_ARCH'), d.getVar('TUNE_FEATURES'), d)}"
13TARGET_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
18# Go supports dynamic linking on a limited set of architectures.
19# See the supportsDynlink function in go/src/cmd/compile/internal/gc/main.go
20GO_DYNLINK = ""
21GO_DYNLINK_arm = "1"
22GO_DYNLINK_aarch64 = "1"
23GO_DYNLINK_x86 = "1"
24GO_DYNLINK_x86-64 = "1"
25GO_DYNLINK_powerpc64 = "1"
26GO_DYNLINK_class-native = ""
Brad Bishop316dfdd2018-06-25 12:45:53 -040027GO_DYNLINK_class-nativesdk = ""
Brad Bishopd7bf8c12018-02-25 22:55:05 -050028
29# define here because everybody inherits this class
30#
31COMPATIBLE_HOST_linux-gnux32 = "null"
32COMPATIBLE_HOST_linux-muslx32 = "null"
33COMPATIBLE_HOST_powerpc = "null"
34COMPATIBLE_HOST_powerpc64 = "null"
35COMPATIBLE_HOST_mipsarchn32 = "null"
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080036
37ARM_INSTRUCTION_SET_armv4 = "arm"
38ARM_INSTRUCTION_SET_armv5 = "arm"
39ARM_INSTRUCTION_SET_armv6 = "arm"
40
Brad Bishopd7bf8c12018-02-25 22:55:05 -050041TUNE_CCARGS_remove = "-march=mips32r2"
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080042SECURITY_CFLAGS_mipsarch = "${SECURITY_NOPIE_CFLAGS}"
Brad Bishop316dfdd2018-06-25 12:45:53 -040043SECURITY_NOPIE_CFLAGS ??= ""
Brad Bishop6e60e8b2018-02-01 10:27:11 -050044
45def go_map_arch(a, d):
46 import re
47 if re.match('i.86', a):
48 return '386'
49 elif a == 'x86_64':
50 return 'amd64'
51 elif re.match('arm.*', a):
52 return 'arm'
53 elif re.match('aarch64.*', a):
54 return 'arm64'
Brad Bishopd7bf8c12018-02-25 22:55:05 -050055 elif re.match('mips64el.*', a):
Brad Bishop6e60e8b2018-02-01 10:27:11 -050056 return 'mips64le'
Brad Bishopd7bf8c12018-02-25 22:55:05 -050057 elif re.match('mips64.*', a):
Brad Bishop6e60e8b2018-02-01 10:27:11 -050058 return 'mips64'
Brad Bishopd7bf8c12018-02-25 22:55:05 -050059 elif a == 'mips':
Brad Bishop6e60e8b2018-02-01 10:27:11 -050060 return 'mips'
Brad Bishopd7bf8c12018-02-25 22:55:05 -050061 elif a == 'mipsel':
62 return 'mipsle'
Brad Bishop6e60e8b2018-02-01 10:27:11 -050063 elif re.match('p(pc|owerpc)(64)', a):
64 return 'ppc64'
65 elif re.match('p(pc|owerpc)(64el)', a):
66 return 'ppc64le'
67 else:
Brad Bishop316dfdd2018-06-25 12:45:53 -040068 raise bb.parse.SkipRecipe("Unsupported CPU architecture: %s" % a)
Brad Bishop6e60e8b2018-02-01 10:27:11 -050069
70def go_map_arm(a, f, d):
71 import re
72 if re.match('arm.*', a):
73 if 'armv7' in f:
74 return '7'
75 elif 'armv6' in f:
76 return '6'
Brad Bishopd7bf8c12018-02-25 22:55:05 -050077 elif 'armv5' in f:
78 return '5'
79 return ''
80
81def go_map_386(a, f, d):
82 import re
83 if re.match('i.86', a):
84 if ('core2' in f) or ('corei7' in f):
85 return 'sse2'
86 else:
87 return '387'
Brad Bishop6e60e8b2018-02-01 10:27:11 -050088 return ''
89
Brad Bishop316dfdd2018-06-25 12:45:53 -040090def go_map_mips(a, f, d):
91 import re
92 if a == 'mips' or a == 'mipsel':
93 if 'fpu-hard' in f:
94 return 'hardfloat'
95 else:
96 return 'softfloat'
97 return ''
98
Brad Bishop6e60e8b2018-02-01 10:27:11 -050099def go_map_os(o, d):
100 if o.startswith('linux'):
101 return 'linux'
102 return o
103
104