blob: 1ebe03864fe2ff214d62057d4f8bdb5196da6c46 [file] [log] [blame]
Patrick Williams92b42cb2022-09-03 06:53:57 -05001#
2# Copyright OpenEmbedded Contributors
3#
4# SPDX-License-Identifier: MIT
5#
6
7BUILD_GOOS = "${@go_map_os(d.getVar('BUILD_OS'), d)}"
8BUILD_GOARCH = "${@go_map_arch(d.getVar('BUILD_ARCH'), d)}"
9BUILD_GOTUPLE = "${BUILD_GOOS}_${BUILD_GOARCH}"
10HOST_GOOS = "${@go_map_os(d.getVar('HOST_OS'), d)}"
11HOST_GOARCH = "${@go_map_arch(d.getVar('HOST_ARCH'), d)}"
12HOST_GOARM = "${@go_map_arm(d.getVar('HOST_ARCH'), d)}"
13HOST_GO386 = "${@go_map_386(d.getVar('HOST_ARCH'), d.getVar('TUNE_FEATURES'), d)}"
14HOST_GOMIPS = "${@go_map_mips(d.getVar('HOST_ARCH'), d.getVar('TUNE_FEATURES'), d)}"
15HOST_GOARM:class-native = "7"
16HOST_GO386:class-native = "sse2"
17HOST_GOMIPS:class-native = "hardfloat"
18HOST_GOTUPLE = "${HOST_GOOS}_${HOST_GOARCH}"
19TARGET_GOOS = "${@go_map_os(d.getVar('TARGET_OS'), d)}"
20TARGET_GOARCH = "${@go_map_arch(d.getVar('TARGET_ARCH'), d)}"
21TARGET_GOARM = "${@go_map_arm(d.getVar('TARGET_ARCH'), d)}"
22TARGET_GO386 = "${@go_map_386(d.getVar('TARGET_ARCH'), d.getVar('TUNE_FEATURES'), d)}"
23TARGET_GOMIPS = "${@go_map_mips(d.getVar('TARGET_ARCH'), d.getVar('TUNE_FEATURES'), d)}"
24TARGET_GOARM:class-native = "7"
25TARGET_GO386:class-native = "sse2"
26TARGET_GOMIPS:class-native = "hardfloat"
27TARGET_GOTUPLE = "${TARGET_GOOS}_${TARGET_GOARCH}"
28GO_BUILD_BINDIR = "${@['bin/${HOST_GOTUPLE}','bin'][d.getVar('BUILD_GOTUPLE') == d.getVar('HOST_GOTUPLE')]}"
29
30# Use the MACHINEOVERRIDES to map ARM CPU architecture passed to GO via GOARM.
31# This is combined with *_ARCH to set HOST_GOARM and TARGET_GOARM.
32BASE_GOARM = ''
33BASE_GOARM:armv7ve = '7'
34BASE_GOARM:armv7a = '7'
35BASE_GOARM:armv6 = '6'
36BASE_GOARM:armv5 = '5'
37
38# Go supports dynamic linking on a limited set of architectures.
39# See the supportsDynlink function in go/src/cmd/compile/internal/gc/main.go
40GO_DYNLINK = ""
41GO_DYNLINK:arm ?= "1"
42GO_DYNLINK:aarch64 ?= "1"
43GO_DYNLINK:x86 ?= "1"
44GO_DYNLINK:x86-64 ?= "1"
45GO_DYNLINK:powerpc64 ?= "1"
46GO_DYNLINK:powerpc64le ?= "1"
47GO_DYNLINK:class-native ?= ""
48GO_DYNLINK:class-nativesdk = ""
49
50# define here because everybody inherits this class
51#
52COMPATIBLE_HOST:linux-gnux32 = "null"
53COMPATIBLE_HOST:linux-muslx32 = "null"
54COMPATIBLE_HOST:powerpc = "null"
55COMPATIBLE_HOST:powerpc64 = "null"
56COMPATIBLE_HOST:mipsarchn32 = "null"
Andrew Geissler220dafd2023-10-04 10:18:08 -050057COMPATIBLE_HOST:riscv32 = "null"
Patrick Williams92b42cb2022-09-03 06:53:57 -050058
59ARM_INSTRUCTION_SET:armv4 = "arm"
60ARM_INSTRUCTION_SET:armv5 = "arm"
61ARM_INSTRUCTION_SET:armv6 = "arm"
62
63TUNE_CCARGS:remove = "-march=mips32r2"
64SECURITY_NOPIE_CFLAGS ??= ""
65
66# go can't be built with ccache:
67# gcc: fatal error: no input files
68CCACHE_DISABLE ?= "1"
69
70def go_map_arch(a, d):
Patrick Williamsac13d5f2023-11-24 18:59:46 -060071 arch = oe.go.map_arch(a)
72 if not arch:
Patrick Williams92b42cb2022-09-03 06:53:57 -050073 raise bb.parse.SkipRecipe("Unsupported CPU architecture: %s" % a)
Patrick Williamsac13d5f2023-11-24 18:59:46 -060074 return arch
Patrick Williams92b42cb2022-09-03 06:53:57 -050075
76def go_map_arm(a, d):
77 if a.startswith("arm"):
78 return d.getVar('BASE_GOARM')
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 'softfloat'
88 return ''
89
90def 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
99def go_map_os(o, d):
100 if o.startswith('linux'):
101 return 'linux'
102 return o