Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 1 | # |
| 2 | # Copyright OpenEmbedded Contributors |
| 3 | # |
| 4 | # SPDX-License-Identifier: MIT |
| 5 | # |
| 6 | |
| 7 | BUILD_GOOS = "${@go_map_os(d.getVar('BUILD_OS'), d)}" |
| 8 | BUILD_GOARCH = "${@go_map_arch(d.getVar('BUILD_ARCH'), d)}" |
| 9 | BUILD_GOTUPLE = "${BUILD_GOOS}_${BUILD_GOARCH}" |
| 10 | HOST_GOOS = "${@go_map_os(d.getVar('HOST_OS'), d)}" |
| 11 | HOST_GOARCH = "${@go_map_arch(d.getVar('HOST_ARCH'), d)}" |
| 12 | HOST_GOARM = "${@go_map_arm(d.getVar('HOST_ARCH'), d)}" |
| 13 | HOST_GO386 = "${@go_map_386(d.getVar('HOST_ARCH'), d.getVar('TUNE_FEATURES'), d)}" |
| 14 | HOST_GOMIPS = "${@go_map_mips(d.getVar('HOST_ARCH'), d.getVar('TUNE_FEATURES'), d)}" |
| 15 | HOST_GOARM:class-native = "7" |
| 16 | HOST_GO386:class-native = "sse2" |
| 17 | HOST_GOMIPS:class-native = "hardfloat" |
| 18 | HOST_GOTUPLE = "${HOST_GOOS}_${HOST_GOARCH}" |
| 19 | TARGET_GOOS = "${@go_map_os(d.getVar('TARGET_OS'), d)}" |
| 20 | TARGET_GOARCH = "${@go_map_arch(d.getVar('TARGET_ARCH'), d)}" |
| 21 | TARGET_GOARM = "${@go_map_arm(d.getVar('TARGET_ARCH'), d)}" |
| 22 | TARGET_GO386 = "${@go_map_386(d.getVar('TARGET_ARCH'), d.getVar('TUNE_FEATURES'), d)}" |
| 23 | TARGET_GOMIPS = "${@go_map_mips(d.getVar('TARGET_ARCH'), d.getVar('TUNE_FEATURES'), d)}" |
| 24 | TARGET_GOARM:class-native = "7" |
| 25 | TARGET_GO386:class-native = "sse2" |
| 26 | TARGET_GOMIPS:class-native = "hardfloat" |
| 27 | TARGET_GOTUPLE = "${TARGET_GOOS}_${TARGET_GOARCH}" |
| 28 | GO_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. |
| 32 | BASE_GOARM = '' |
| 33 | BASE_GOARM:armv7ve = '7' |
| 34 | BASE_GOARM:armv7a = '7' |
| 35 | BASE_GOARM:armv6 = '6' |
| 36 | BASE_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 |
| 40 | GO_DYNLINK = "" |
Patrick Williams | b58112e | 2024-03-07 11:16:36 -0600 | [diff] [blame] | 41 | GO_DYNLINK:arm = "" |
| 42 | GO_DYNLINK:aarch64 = "" |
| 43 | GO_DYNLINK:x86 = "" |
| 44 | GO_DYNLINK:x86-64 = "" |
| 45 | GO_DYNLINK:powerpc64 = "" |
| 46 | GO_DYNLINK:powerpc64le = "" |
| 47 | GO_DYNLINK:class-native = "" |
Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 48 | GO_DYNLINK:class-nativesdk = "" |
| 49 | |
| 50 | # define here because everybody inherits this class |
| 51 | # |
| 52 | COMPATIBLE_HOST:linux-gnux32 = "null" |
| 53 | COMPATIBLE_HOST:linux-muslx32 = "null" |
| 54 | COMPATIBLE_HOST:powerpc = "null" |
| 55 | COMPATIBLE_HOST:powerpc64 = "null" |
| 56 | COMPATIBLE_HOST:mipsarchn32 = "null" |
Andrew Geissler | 220dafd | 2023-10-04 10:18:08 -0500 | [diff] [blame] | 57 | COMPATIBLE_HOST:riscv32 = "null" |
Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 58 | |
| 59 | ARM_INSTRUCTION_SET:armv4 = "arm" |
| 60 | ARM_INSTRUCTION_SET:armv5 = "arm" |
| 61 | ARM_INSTRUCTION_SET:armv6 = "arm" |
| 62 | |
| 63 | TUNE_CCARGS:remove = "-march=mips32r2" |
| 64 | SECURITY_NOPIE_CFLAGS ??= "" |
| 65 | |
| 66 | # go can't be built with ccache: |
| 67 | # gcc: fatal error: no input files |
| 68 | CCACHE_DISABLE ?= "1" |
| 69 | |
| 70 | def go_map_arch(a, d): |
Patrick Williams | ac13d5f | 2023-11-24 18:59:46 -0600 | [diff] [blame] | 71 | arch = oe.go.map_arch(a) |
| 72 | if not arch: |
Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 73 | raise bb.parse.SkipRecipe("Unsupported CPU architecture: %s" % a) |
Patrick Williams | ac13d5f | 2023-11-24 18:59:46 -0600 | [diff] [blame] | 74 | return arch |
Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 75 | |
| 76 | def go_map_arm(a, d): |
| 77 | if a.startswith("arm"): |
| 78 | return d.getVar('BASE_GOARM') |
| 79 | return '' |
| 80 | |
| 81 | def 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 | |
| 90 | def 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 | |
| 99 | def go_map_os(o, d): |
| 100 | if o.startswith('linux'): |
| 101 | return 'linux' |
| 102 | return o |