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)}" |
| 6 | HOST_GOARM = "${@go_map_arm(d.getVar('HOST_ARCH'), d.getVar('TUNE_FEATURES'), d)}" |
| 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)}" |
| 12 | TARGET_GOARM = "${@go_map_arm(d.getVar('TARGET_ARCH'), d.getVar('TUNE_FEATURES'), d)}" |
| 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 | |
| 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 |
| 20 | GO_DYNLINK = "" |
| 21 | GO_DYNLINK_arm = "1" |
| 22 | GO_DYNLINK_aarch64 = "1" |
| 23 | GO_DYNLINK_x86 = "1" |
| 24 | GO_DYNLINK_x86-64 = "1" |
| 25 | GO_DYNLINK_powerpc64 = "1" |
| 26 | GO_DYNLINK_class-native = "" |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 27 | GO_DYNLINK_class-nativesdk = "" |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 28 | |
| 29 | # define here because everybody inherits this class |
| 30 | # |
| 31 | COMPATIBLE_HOST_linux-gnux32 = "null" |
| 32 | COMPATIBLE_HOST_linux-muslx32 = "null" |
| 33 | COMPATIBLE_HOST_powerpc = "null" |
| 34 | COMPATIBLE_HOST_powerpc64 = "null" |
| 35 | COMPATIBLE_HOST_mipsarchn32 = "null" |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 36 | |
| 37 | ARM_INSTRUCTION_SET_armv4 = "arm" |
| 38 | ARM_INSTRUCTION_SET_armv5 = "arm" |
| 39 | ARM_INSTRUCTION_SET_armv6 = "arm" |
| 40 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 41 | TUNE_CCARGS_remove = "-march=mips32r2" |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 42 | SECURITY_CFLAGS_mipsarch = "${SECURITY_NOPIE_CFLAGS}" |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 43 | SECURITY_NOPIE_CFLAGS ??= "" |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 44 | |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame^] | 45 | # go can't be built with ccache: |
| 46 | # gcc: fatal error: no input files |
| 47 | CCACHE_DISABLE ?= "1" |
| 48 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 49 | def go_map_arch(a, d): |
| 50 | import re |
| 51 | if re.match('i.86', a): |
| 52 | return '386' |
| 53 | elif a == 'x86_64': |
| 54 | return 'amd64' |
| 55 | elif re.match('arm.*', a): |
| 56 | return 'arm' |
| 57 | elif re.match('aarch64.*', a): |
| 58 | return 'arm64' |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 59 | elif re.match('mips64el.*', a): |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 60 | return 'mips64le' |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 61 | elif re.match('mips64.*', a): |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 62 | return 'mips64' |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 63 | elif a == 'mips': |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 64 | return 'mips' |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 65 | elif a == 'mipsel': |
| 66 | return 'mipsle' |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 67 | elif re.match('p(pc|owerpc)(64)', a): |
| 68 | return 'ppc64' |
| 69 | elif re.match('p(pc|owerpc)(64el)', a): |
| 70 | return 'ppc64le' |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame^] | 71 | elif a == 'riscv64': |
| 72 | return 'riscv64' |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 73 | else: |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 74 | raise bb.parse.SkipRecipe("Unsupported CPU architecture: %s" % a) |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 75 | |
| 76 | def go_map_arm(a, f, d): |
| 77 | import re |
| 78 | if re.match('arm.*', a): |
| 79 | if 'armv7' in f: |
| 80 | return '7' |
| 81 | elif 'armv6' in f: |
| 82 | return '6' |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 83 | elif 'armv5' in f: |
| 84 | return '5' |
| 85 | return '' |
| 86 | |
| 87 | def go_map_386(a, f, d): |
| 88 | import re |
| 89 | if re.match('i.86', a): |
| 90 | if ('core2' in f) or ('corei7' in f): |
| 91 | return 'sse2' |
| 92 | else: |
| 93 | return '387' |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 94 | return '' |
| 95 | |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 96 | def go_map_mips(a, f, d): |
| 97 | import re |
| 98 | if a == 'mips' or a == 'mipsel': |
| 99 | if 'fpu-hard' in f: |
| 100 | return 'hardfloat' |
| 101 | else: |
| 102 | return 'softfloat' |
| 103 | return '' |
| 104 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 105 | def go_map_os(o, d): |
| 106 | if o.startswith('linux'): |
| 107 | return 'linux' |
| 108 | return o |
| 109 | |
| 110 | |