rustc_to_go_target/lib.rs
1pub fn convert(rustc_target: &str) -> Option<&'static str> {
2 match rustc_target {
3 "x86_64-linux-android" => Some("android/amd64"),
4 "aarch64-linux-android" => Some("android/arm64"),
5 "x86_64-apple-darwin" => Some("darwin/amd64"),
6 "aarch64-apple-darwin" => Some("darwin/arm64"),
7 "x86_64-unknown-dragonfly" => Some("dragonfly/amd64"),
8 "x86_64-unknown-freebsd" => Some("freebsd/amd64"),
9 "aarch64-unknown-freebsd" => Some("freebsd/arm64"),
10 "x86_64-unknown-illumos" => Some("illumos/amd64"),
11 // TODO: consider replacing with the following:
12 // "x86_64-apple-ios" | "x86_64-apple-ios-macabi" => Some("ios/amd64"),
13 "x86_64-apple-ios" => Some("ios/amd64"),
14 // TODO: consider replacing with the following:
15 // "aarch64-apple-ios" | "aarch64-apple-ios-macabi" | "aarch64-apple-ios-sim" => Some("ios/arm64")
16 "aarch64-apple-ios" => Some("ios/arm64"),
17 // According to this Go uses dynamic linking against C library (unless Cgo is used) :
18 // https://www.reddit.com/r/golang/comments/8m4xrh/do_linux_golang_binaries_depend_on_libc/
19 // I may be terribly wrong but I think that it's safe to assume that this should work fine:
20 "x86_64-unknown-linux-gnu" | "x86_64-unknown-linux-gnux32" | "x86_64-unknown-linux-musl" => Some("linux/amd64"),
21 // TODO: consider whether the following can be supported as well:
22 // "armeb-unknown-linux-gnueabi" | "armv4t-unknown-linux-gnueabi" | "armv5te-unknown-linux-gnueabi" | "armv5te-unknown-linux-musleabi" | "armv5te-unknown-linux-uclibceabi"
23 "arm-unknown-linux-gnueabi" | "arm-unknown-linux-gnueabihf" | "arm-unknown-linux-musleabi" | "arm-unknown-linux-musleabihf" => Some("linux/arm"),
24 "aarch64-unknown-linux-gnu" | "aarch64-unknown-linux-gnu_ilp32" | "aarch64-unknown-linux-musl" => Some("linux/arm64"),
25 "mips-unknown-linux-gnu" | "mips-unknown-linux-musl" | "mips-unknown-linux-uclibc" => Some("linux/mips"),
26 // TODO: double-check that "mips64-openwrt-linux-musl" is indeed supported
27 "mips64-openwrt-linux-musl" | "mips64-unknown-linux-gnuabi64" | "mips64-unknown-linux-muslabi64" => Some("linux/mips64"),
28 "mips64el-unknown-linux-gnuabi64" | "mips64el-unknown-linux-muslabi64" => Some("linux/mips64le"),
29 "mipsel-unknown-linux-gnu" | "mipsel-unknown-linux-musl" | "mipsel-unknown-linux-uclibc" => Some("linux/mipsle"),
30 "powerpc64-unknown-linux-gnu" | "powerpc64-unknown-linux-musl" => Some("linux/ppc64"),
31 "powerpc64le-unknown-linux-gnu" | "powerpc64le-unknown-linux-musl" => Some("linux/ppc64le"),
32 "s390x-unknown-linux-gnu" | "s390x-unknown-linux-musl" => Some("linux/s390x"),
33 "x86_64-unknown-netbsd" => Some("netbsd/amd64"),
34 "aarch64-unknown-netbsd" => Some("netbsd/arm64"),
35 "x86_64-unknown-openbsd" => Some("openbsd/amd64"),
36 "aarch64-unknown-openbsd" => Some("openbsd/arm64"),
37
38 _ => None,
39
40 // https://github.com/rust-lang/libc/pull/2278
41 // todo!() => Some("aix/ppc64")
42 //
43 // At the time of writing, Rustc supports `i386-apple-ios` and `i686-linux-andorid`
44 // but not the outdated `i386-linux-android`
45 // todo!() => Some("android/386")
46 //
47 // TODO: consult with experts whether this is correct
48 // "arm-linux-androideabi" | "armv7-linux-androideabi" => Some("android/arm"),
49 //
50 // TODO: learn more about `arm`, `arm64`, `armeb`, `armebv7r`, `armv4t`, `armv5te`, `armv6`,
51 // `armv6k`, `armv7`, `armv7a`, `armv7k`, `armv7r`, `armv7s`.
52 //
53 // todo!() => Some("freebsd/386"),
54 //
55 // TODO: consult with experts whether this is correct
56 // "armv6-unknown-freebsd" | "arm7-unknown-freebsd" => Some("freebsd/arm"),
57 //
58 // TODO: consult with experts whether this is correct
59 // "riscv64gc-unknown-freebsd" => Some("freebsd/riscv64"),
60 //
61 // TODO: consult with experts whether this is correct
62 // "wasm32-unknown-unknown" => Some("js/wasm"),
63 //
64 // todo!() => Some("linux/386"),
65 //
66 // At the moment of writing, `loongarch64` is not supported by Rustc:
67 // https://github.com/rust-lang/rust/pull/96971
68 // "loongarch64_unknown_linux_gnuf64" => Some("linux/loongarch64"),
69 //
70 // TODO: learn more about riscv64
71 // todo!() => Some("linux/riscv64"),
72 //
73 // todo!() => Some("netbsd/386"),
74 //
75 // todo!() => Some("openbsd/386"),
76 //
77 // todo!() => Some("openbsd/arm"),
78 //
79 // todo!() => Some("openbsd/mips64"),
80 //
81 // todo!() => Some("plan9/386"),
82 // todo!() => Some("plan9/amd64"),
83 // todo!() => Some("plan9/arm"),
84 //
85 // TODO: consult with experts whether this is correct
86 // "x86_64-pc-solaris" | "x86_64-sun-solaris" => Some("solaris/amd64"),
87 //
88 // todo!() => Some("windows/386"),
89 //
90 // TODO: consult with experts whether this is correct
91 // "x86_64-pc-windows-gnu" | "x86_64-pc-windows-gnullvm" | "x86_64-pc-windows-msvc" | "x86_64-uwp-windows-gnu" | "x86_64-uwp-windows-msvc" => Some("windows/amd64"),
92 //
93 // todo!() => Some("windows/arm"),
94 //
95 // "aarch64-pc-windows-gnullvm" | "aarch64-pc-windows-msvc" => Some("windows/arm64"),
96 }
97}