Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 1 | BUILD_GOOS = "${@go_map_os(d.getVar('BUILD_OS'), d)}" |
| 2 | BUILD_GOARCH = "${@go_map_arch(d.getVar('BUILD_ARCH'), d)}" |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 3 | BUILD_GOTUPLE = "${BUILD_GOOS}_${BUILD_GOARCH}" |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 4 | HOST_GOOS = "${@go_map_os(d.getVar('HOST_OS'), d)}" |
| 5 | HOST_GOARCH = "${@go_map_arch(d.getVar('HOST_ARCH'), d)}" |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 6 | HOST_GOARM = "${@go_map_arm(d.getVar('HOST_ARCH'), d)}" |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 7 | HOST_GO386 = "${@go_map_386(d.getVar('HOST_ARCH'), d.getVar('TUNE_FEATURES'), d)}" |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 8 | HOST_GOMIPS = "${@go_map_mips(d.getVar('HOST_ARCH'), d.getVar('TUNE_FEATURES'), d)}" |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 9 | HOST_GOARM:class-native = "7" |
| 10 | HOST_GO386:class-native = "sse2" |
| 11 | HOST_GOMIPS:class-native = "hardfloat" |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 12 | HOST_GOTUPLE = "${HOST_GOOS}_${HOST_GOARCH}" |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 13 | TARGET_GOOS = "${@go_map_os(d.getVar('TARGET_OS'), d)}" |
| 14 | TARGET_GOARCH = "${@go_map_arch(d.getVar('TARGET_ARCH'), d)}" |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 15 | TARGET_GOARM = "${@go_map_arm(d.getVar('TARGET_ARCH'), d)}" |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 16 | TARGET_GO386 = "${@go_map_386(d.getVar('TARGET_ARCH'), d.getVar('TUNE_FEATURES'), d)}" |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 17 | TARGET_GOMIPS = "${@go_map_mips(d.getVar('TARGET_ARCH'), d.getVar('TUNE_FEATURES'), d)}" |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 18 | TARGET_GOARM:class-native = "7" |
| 19 | TARGET_GO386:class-native = "sse2" |
| 20 | TARGET_GOMIPS:class-native = "hardfloat" |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 21 | TARGET_GOTUPLE = "${TARGET_GOOS}_${TARGET_GOARCH}" |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 22 | GO_BUILD_BINDIR = "${@['bin/${HOST_GOTUPLE}','bin'][d.getVar('BUILD_GOTUPLE') == d.getVar('HOST_GOTUPLE')]}" |
| 23 | |
Brad Bishop | d89cb5f | 2019-04-10 09:02:41 -0400 | [diff] [blame] | 24 | # 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. |
| 26 | BASE_GOARM = '' |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 27 | BASE_GOARM:armv7ve = '7' |
| 28 | BASE_GOARM:armv7a = '7' |
| 29 | BASE_GOARM:armv6 = '6' |
| 30 | BASE_GOARM:armv5 = '5' |
Brad Bishop | d89cb5f | 2019-04-10 09:02:41 -0400 | [diff] [blame] | 31 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 32 | # Go supports dynamic linking on a limited set of architectures. |
| 33 | # See the supportsDynlink function in go/src/cmd/compile/internal/gc/main.go |
| 34 | GO_DYNLINK = "" |
Andrew Geissler | d159c7f | 2021-09-02 21:05:58 -0500 | [diff] [blame] | 35 | GO_DYNLINK:arm ?= "1" |
| 36 | GO_DYNLINK:aarch64 ?= "1" |
| 37 | GO_DYNLINK:x86 ?= "1" |
| 38 | GO_DYNLINK:x86-64 ?= "1" |
| 39 | GO_DYNLINK:powerpc64 ?= "1" |
| 40 | GO_DYNLINK:powerpc64le ?= "1" |
| 41 | GO_DYNLINK:class-native ?= "" |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 42 | GO_DYNLINK:class-nativesdk = "" |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 43 | |
| 44 | # define here because everybody inherits this class |
| 45 | # |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 46 | COMPATIBLE_HOST:linux-gnux32 = "null" |
| 47 | COMPATIBLE_HOST:linux-muslx32 = "null" |
| 48 | COMPATIBLE_HOST:powerpc = "null" |
| 49 | COMPATIBLE_HOST:powerpc64 = "null" |
| 50 | COMPATIBLE_HOST:mipsarchn32 = "null" |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 51 | |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 52 | ARM_INSTRUCTION_SET:armv4 = "arm" |
| 53 | ARM_INSTRUCTION_SET:armv5 = "arm" |
| 54 | ARM_INSTRUCTION_SET:armv6 = "arm" |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 55 | |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 56 | TUNE_CCARGS:remove = "-march=mips32r2" |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 57 | SECURITY_NOPIE_CFLAGS ??= "" |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 58 | |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 59 | # go can't be built with ccache: |
| 60 | # gcc: fatal error: no input files |
| 61 | CCACHE_DISABLE ?= "1" |
| 62 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 63 | def 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 Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 73 | elif re.match('mips64el.*', a): |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 74 | return 'mips64le' |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 75 | elif re.match('mips64.*', a): |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 76 | return 'mips64' |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 77 | elif a == 'mips': |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 78 | return 'mips' |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 79 | elif a == 'mipsel': |
| 80 | return 'mipsle' |
Andrew Geissler | 90fd73c | 2021-03-05 15:25:55 -0600 | [diff] [blame] | 81 | elif re.match('p(pc|owerpc)(64le)', a): |
| 82 | return 'ppc64le' |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 83 | elif re.match('p(pc|owerpc)(64)', a): |
| 84 | return 'ppc64' |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 85 | elif a == 'riscv64': |
| 86 | return 'riscv64' |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 87 | else: |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 88 | raise bb.parse.SkipRecipe("Unsupported CPU architecture: %s" % a) |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 89 | |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 90 | def go_map_arm(a, d): |
| 91 | if a.startswith("arm"): |
| 92 | return d.getVar('BASE_GOARM') |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 93 | return '' |
| 94 | |
| 95 | def 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 Geissler | 90fd73c | 2021-03-05 15:25:55 -0600 | [diff] [blame] | 101 | return 'softfloat' |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 102 | return '' |
| 103 | |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 104 | def 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 Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 113 | def go_map_os(o, d): |
| 114 | if o.startswith('linux'): |
| 115 | return 'linux' |
| 116 | return o |