Skip to content

Commit

Permalink
mips: fix big-endian (GOARCH=mips) support
Browse files Browse the repository at this point in the history
I made an awkward mistake, mixing up GOOS and GOARCH. So here is a fix,
with an associated test.
  • Loading branch information
aykevl authored and deadprogram committed Aug 22, 2024
1 parent 83c98a2 commit 1ef1aa7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion compileopts/target.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 1ef1aa7

Please sign in to comment.