tinygo icon indicating copy to clipboard operation
tinygo copied to clipboard

compileopts: adapt GOARM to follow new 1.22 scheme

Open MDr164 opened this issue 11 months ago • 3 comments

This ads the optional softfloat and hardfloat suffix to GOARM the same way it was introduced upstream with Go 1.22. By default armv5 is softfloat while v6 and v7 are hardfloat. Resolves #4177

TODO: Actually figure out the correct combination of LLVM arch flags.

MDr164 avatar Mar 13 '24 11:03 MDr164

It might be useful to try out combinations of flags using Godbolt: https://godbolt.org/z/9cGfzhG6x

aykevl avatar Mar 13 '24 13:03 aykevl

Looks like CI is failing for code I didn't even touch in this PR. Otherwise this looks fine now. Will have to run a few more tests to be certain all the flags and targets check out on my hardware here but I think it's ready to go.

MDr164 avatar Mar 27 '24 08:03 MDr164

If I read this PR correctly, it will now default to softfloat everywhere except when hardfloat is specified explicitly? Is that true? That seems like a bad idea. A better default would be to use softfloat on armv5 and hardfloat on armv6 and armv7 (or softfloat on armv5+armv6 and hardfloat on armv7).

Also, I don't think this affects musl, so you will likely still have some floating point instructions (or ABI incompatibilities). Try running this on an ARM system:

GOARM=5,softfloat tinygo run ./testdata/math.go
GOARM=5,hardfloat tinygo run ./testdata/math.go
GOARM=7,softfloat tinygo run ./testdata/math.go
GOARM=7,hardfloat tinygo run ./testdata/math.go

They should all produce identical output.

I'll have to run some more tests to make sure this works as expected on musl as well. And yes the idea was that v5 defaults to soft while v6 and v7 default to hard to match upstream behavior. I'll rework this if the musl tests turn out to be what you expect.

MDr164 avatar Jun 21 '24 13:06 MDr164

Closed in favor of #4374

MDr164 avatar Jul 31 '24 13:07 MDr164