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 | d89cb5f | 2019-04-10 09:02:41 -0400 | [diff] [blame] | 6 | HOST_GOARM = "${@go_map_arm(d.getVar('HOST_ARCH'), d.getVar('BASE_GOARM'), 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)}" |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 9 | HOST_GOTUPLE = "${HOST_GOOS}_${HOST_GOARCH}" |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 10 | TARGET_GOOS = "${@go_map_os(d.getVar('TARGET_OS'), d)}" |
| 11 | TARGET_GOARCH = "${@go_map_arch(d.getVar('TARGET_ARCH'), d)}" |
Brad Bishop | d89cb5f | 2019-04-10 09:02:41 -0400 | [diff] [blame] | 12 | TARGET_GOARM = "${@go_map_arm(d.getVar('TARGET_ARCH'), d.getVar('BASE_GOARM'), d)}" |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 13 | 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] | 14 | TARGET_GOMIPS = "${@go_map_mips(d.getVar('TARGET_ARCH'), d.getVar('TUNE_FEATURES'), d)}" |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 15 | TARGET_GOTUPLE = "${TARGET_GOOS}_${TARGET_GOARCH}" |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 16 | GO_BUILD_BINDIR = "${@['bin/${HOST_GOTUPLE}','bin'][d.getVar('BUILD_GOTUPLE') == d.getVar('HOST_GOTUPLE')]}" |
| 17 | |
Brad Bishop | d89cb5f | 2019-04-10 09:02:41 -0400 | [diff] [blame] | 18 | # Use the MACHINEOVERRIDES to map ARM CPU architecture passed to GO via GOARM. |
| 19 | # This is combined with *_ARCH to set HOST_GOARM and TARGET_GOARM. |
| 20 | BASE_GOARM = '' |
| 21 | BASE_GOARM_armv7ve = '7' |
| 22 | BASE_GOARM_armv7a = '7' |
| 23 | BASE_GOARM_armv6 = '6' |
| 24 | BASE_GOARM_armv5 = '5' |
| 25 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 26 | # Go supports dynamic linking on a limited set of architectures. |
| 27 | # See the supportsDynlink function in go/src/cmd/compile/internal/gc/main.go |
| 28 | GO_DYNLINK = "" |
| 29 | GO_DYNLINK_arm = "1" |
| 30 | GO_DYNLINK_aarch64 = "1" |
| 31 | GO_DYNLINK_x86 = "1" |
| 32 | GO_DYNLINK_x86-64 = "1" |
| 33 | GO_DYNLINK_powerpc64 = "1" |
| 34 | GO_DYNLINK_class-native = "" |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 35 | GO_DYNLINK_class-nativesdk = "" |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 36 | |
| 37 | # define here because everybody inherits this class |
| 38 | # |
| 39 | COMPATIBLE_HOST_linux-gnux32 = "null" |
| 40 | COMPATIBLE_HOST_linux-muslx32 = "null" |
| 41 | COMPATIBLE_HOST_powerpc = "null" |
| 42 | COMPATIBLE_HOST_powerpc64 = "null" |
| 43 | COMPATIBLE_HOST_mipsarchn32 = "null" |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 44 | |
| 45 | ARM_INSTRUCTION_SET_armv4 = "arm" |
| 46 | ARM_INSTRUCTION_SET_armv5 = "arm" |
| 47 | ARM_INSTRUCTION_SET_armv6 = "arm" |
| 48 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 49 | TUNE_CCARGS_remove = "-march=mips32r2" |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 50 | SECURITY_CFLAGS_mipsarch = "${SECURITY_NOPIE_CFLAGS}" |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 51 | SECURITY_NOPIE_CFLAGS ??= "" |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 52 | |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 53 | # go can't be built with ccache: |
| 54 | # gcc: fatal error: no input files |
| 55 | CCACHE_DISABLE ?= "1" |
| 56 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 57 | def go_map_arch(a, d): |
| 58 | import re |
| 59 | if re.match('i.86', a): |
| 60 | return '386' |
| 61 | elif a == 'x86_64': |
| 62 | return 'amd64' |
| 63 | elif re.match('arm.*', a): |
| 64 | return 'arm' |
| 65 | elif re.match('aarch64.*', a): |
| 66 | return 'arm64' |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 67 | elif re.match('mips64el.*', a): |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 68 | return 'mips64le' |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 69 | elif re.match('mips64.*', a): |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 70 | return 'mips64' |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 71 | elif a == 'mips': |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 72 | return 'mips' |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 73 | elif a == 'mipsel': |
| 74 | return 'mipsle' |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 75 | elif re.match('p(pc|owerpc)(64)', a): |
| 76 | return 'ppc64' |
| 77 | elif re.match('p(pc|owerpc)(64el)', a): |
| 78 | return 'ppc64le' |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 79 | elif a == 'riscv64': |
| 80 | return 'riscv64' |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 81 | else: |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 82 | raise bb.parse.SkipRecipe("Unsupported CPU architecture: %s" % a) |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 83 | |
| 84 | def go_map_arm(a, f, d): |
| 85 | import re |
| 86 | if re.match('arm.*', a): |
Brad Bishop | d89cb5f | 2019-04-10 09:02:41 -0400 | [diff] [blame] | 87 | return f |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 88 | return '' |
| 89 | |
| 90 | def go_map_386(a, f, d): |
| 91 | import re |
| 92 | if re.match('i.86', a): |
| 93 | if ('core2' in f) or ('corei7' in f): |
| 94 | return 'sse2' |
| 95 | else: |
| 96 | return '387' |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 97 | return '' |
| 98 | |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 99 | def go_map_mips(a, f, d): |
| 100 | import re |
| 101 | if a == 'mips' or a == 'mipsel': |
| 102 | if 'fpu-hard' in f: |
| 103 | return 'hardfloat' |
| 104 | else: |
| 105 | return 'softfloat' |
| 106 | return '' |
| 107 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 108 | def go_map_os(o, d): |
| 109 | if o.startswith('linux'): |
| 110 | return 'linux' |
| 111 | return o |
| 112 | |
| 113 | |