DavidKinder / Inform6

The latest version of the Inform 6 compiler, used for generating interactive fiction games.
http://inform-fiction.org/
Other
204 stars 34 forks source link

Compiled game mismatch on ARM #225

Closed erkyrath closed 1 year ago

erkyrath commented 1 year ago

When compiling glulxercise.inf, I get different binary output when compiling on Intel MacOS vs ARM MacOS.

The difference is at address 0x2151B (the function code segment):

! 00021510  72 03 00 03 32 8b 40 83  4c 2d 63 38 40 83 3f ec  |r...2.@.L-c8@.?.|

! 00021510  72 03 00 03 32 8b 40 83  4c 2d 63 37 40 83 3f ec  |r...2.@.L-c7@.?.|

This doesn't cause any runtime tests to fail, but it trips a checksum error in the inform6-testing suite.

I suspect float math differences, but I haven't dug into it yet.

erkyrath commented 1 year ago

Yeah, the mismatch is in DoubleTrigTest() somewhere.

cfmoorz2 commented 1 year ago

i tried to compile the latest inform6 compiler as well for my M1 mac and got an ARM ARCHITECTURE error.

this may be a trivial fix but i personally do not have the skillset. if possible could someone post an updated inform6 compiler that is universal?

erkyrath commented 1 year ago

How are you trying to compile it?

You can just type cc -o inform *.c without further effort. I have tested this on M1 and Intel Macs.

cfmoorz2 commented 1 year ago

yes, that worked.

sorry, i'm clueless at this and was trying to include the OS-specific flags or something.

thx!

cm

On May 17, 2023, at 10:00 AM, Andrew Plotkin @.***> wrote:

How are you trying to compile it?

You can just type cc -o inform *.c without further effort. I have tested this on M1 and Intel Macs.

— Reply to this email directly, view it on GitHub https://github.com/DavidKinder/Inform6/issues/225#issuecomment-1551453588, or unsubscribe https://github.com/notifications/unsubscribe-auth/A74DAYVREY7CIXM5I6ZF6R3XGTKX5ANCNFSM6AAAAAAYDY3ZFU. You are receiving this because you commented.

erkyrath commented 1 year ago

No problem -- glad you got it working.

erkyrath commented 1 year ago

The constant $<+0.8912073600614354 compiles as 1278042936 (0x4c2d6338) on Intel, 1278042935 (0x4c2d6337) on ARM.

I feel like this wasn't true a year ago -- I tested the double opcodes on ARM and didn't see this warning. Oh well.

erkyrath commented 1 year ago

I'll try updating clang everywhere; maybe that'll bring it back in sync. If not, I'll tweak the test values in glulxercise rather than trying to tweak the compiler.

erkyrath commented 1 year ago

The difference in double constants turned out to be this line in lexer.c:

    fracpow *= 0.1;

After fifteen or sixteen digits (and as many repeated multiplications), this power value diverges on Intel vs ARM.

I tried a couple of different tweaks (fracpow /= 10, or calling pow10_cheap()). These fixed this case but caused ULP divergence on other cases in glulxercise.

I wound up going with the "tweak the test values in glulxercise" solution. We now test sin(1.2) instead of sin(1.1).