diff options
author | Ayke van Laethem <[email protected]> | 2024-08-06 12:44:01 +0200 |
---|---|---|
committer | Ayke <[email protected]> | 2024-08-07 14:41:21 +0200 |
commit | fb3d98ce6e6786f7133facbe131374102a6aa375 (patch) | |
tree | 2cf4791961d6b96e3ef2b0af7aca5909e9f3561a /compiler | |
parent | 020664591ab3a995d6d0aab5097c6fab838a925c (diff) | |
download | tinygo-fb3d98ce6e6786f7133facbe131374102a6aa375.tar.gz tinygo-fb3d98ce6e6786f7133facbe131374102a6aa375.zip |
compileopts: add CanonicalArchName to centralize arch detection
It's possible to detect the architecture from the target triple, but
there are a number of exceptions that make it unpleasant to use for this
purpose. There are just too many weird exceptions (like mips vs mipsel,
and armv6m vs thumv6m vs arm64 vs aarch64) so it's better to centralize
these to canonical architecture names.
I picked the architecture names that happen to match the musl
architecture names, because those seem the most natural to me.
Diffstat (limited to 'compiler')
-rw-r--r-- | compiler/llvm.go | 13 |
1 files changed, 2 insertions, 11 deletions
diff --git a/compiler/llvm.go b/compiler/llvm.go index 9e3a95d4f..bdbf0ece1 100644 --- a/compiler/llvm.go +++ b/compiler/llvm.go @@ -7,6 +7,7 @@ import ( "math/big" "strings" + "github.com/tinygo-org/tinygo/compileopts" "github.com/tinygo-org/tinygo/compiler/llvmutil" "tinygo.org/x/go-llvm" ) @@ -422,17 +423,7 @@ func (c *compilerContext) getPointerBitmap(typ llvm.Type, pos token.Pos) *big.In // architecture names ("armv6", "thumbv7m", etc) merged into a single // architecture name ("arm"). func (c *compilerContext) archFamily() string { - arch := strings.Split(c.Triple, "-")[0] - if strings.HasPrefix(arch, "arm64") { - return "aarch64" - } - if strings.HasPrefix(arch, "arm") || strings.HasPrefix(arch, "thumb") { - return "arm" - } - if arch == "mipsel" { - return "mips" - } - return arch + return compileopts.CanonicalArchName(c.Triple) } // isThumb returns whether we're in ARM or in Thumb mode. It panics if the |