reflect: support big-endian systems

The reflect package needs to know the endianness of the system in a few
places. Before this patch, it assumed little-endian systems. But with
GOARCH=mips we now have a big-endian system which also needs to be
supported. So this patch fixes the reflect package to work on big-endian
systems.

Also, I've updated the tests for MIPS: instead of running the
little-endian tests, I've changed it to run the big-endian tests
instead. The two are very similar except for endianness so this should
be fine. To be sure we won't accidentally break little-endian support,
I've kept a single MIPS little-endian test (the CGo test, which doesn't
yet work on big-endian systems anyway).
This commit is contained in:
Ayke van Laethem
2024-08-23 16:08:43 +02:00
committed by Ron Evans
parent 73f519b589
commit 4f1b69827d
4 changed files with 90 additions and 38 deletions
+15 -11
View File
@@ -36,7 +36,7 @@ var supportedLinuxArches = map[string]string{
"X86Linux": "linux/386",
"ARMLinux": "linux/arm/6",
"ARM64Linux": "linux/arm64",
"MIPSLinux": "linux/mipsle/hardfloat",
"MIPSLinux": "linux/mips/hardfloat",
"WASIp1": "wasip1/wasm",
}
@@ -177,17 +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.
// Once big-endian is fully supported, we can probably flip this
// around and do full testing of MIPS big-endian support and only do
// limited testing of MIPS little-endian (because the two are some
// similar).
t.Run("MIPS little-endian", func(t *testing.T) {
// Run a single test for GOARCH=mipsle to see whether it works at
// all. It is already mostly tested because GOARCH=mips and
// GOARCH=mipsle are so similar, but it's good to have an extra test
// to be sure.
t.Parallel()
options := optionsFromOSARCH("linux/mips/softfloat", sema)
runTest("map.go", options, t, nil, nil)
options := optionsFromOSARCH("linux/mipsle/softfloat", sema)
runTest("cgo/", options, t, nil, nil)
})
t.Run("WebAssembly", func(t *testing.T) {
t.Parallel()
@@ -232,6 +229,13 @@ func runPlatTests(options compileopts.Options, tests []string, t *testing.T) {
continue
}
}
if options.GOOS == "linux" && options.GOARCH == "mips" {
if name == "cgo/" {
// CGo isn't supported yet on big-endian systems (needs updates
// to bitfield access methods).
continue
}
}
if options.Target == "simavr" {
// Not all tests are currently supported on AVR.
// Skip the ones that aren't.