From 1ef1aa78628070f618b732bb68136049511ede4c Mon Sep 17 00:00:00 2001 From: Ayke van Laethem Date: Thu, 22 Aug 2024 15:16:15 +0200 Subject: [PATCH] mips: fix big-endian (GOARCH=mips) support I made an awkward mistake, mixing up GOOS and GOARCH. So here is a fix, with an associated test. --- compileopts/target.go | 2 +- main_test.go | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/compileopts/target.go b/compileopts/target.go index 501d99f119..26a91086b9 100644 --- a/compileopts/target.go +++ b/compileopts/target.go @@ -338,7 +338,7 @@ func defaultTarget(options *Options) (*TargetSpec, error) { case "mips", "mipsle": spec.CPU = "mips32r2" spec.CFlags = append(spec.CFlags, "-fno-pic") - if options.GOOS == "mips" { + if options.GOARCH == "mips" { llvmarch = "mips" // big endian } else { llvmarch = "mipsel" // little endian diff --git a/main_test.go b/main_test.go index 836a4b1730..40002ee871 100644 --- a/main_test.go +++ b/main_test.go @@ -177,6 +177,14 @@ func TestBuild(t *testing.T) { }) } } + t.Run("MIPS big-endian", func(t *testing.T) { + // Run a single test for GOARCH=mips to see whether it works at all. + // Big-endian MIPS isn't fully supported yet, but simple examples + // should work. + t.Parallel() + options := optionsFromOSARCH("linux/mips/softfloat", sema) + runTest("alias.go", options, t, nil, nil) + }) t.Run("WebAssembly", func(t *testing.T) { t.Parallel() runPlatTests(optionsFromTarget("wasm", sema), tests, t)