openmoh / openmohaa

Open re-implementation of Medal of Honor: Allied Assault with modern features and bugfixes from ioquake3 with cross-platform support
https://www.openmohaa.org
GNU General Public License v2.0
323 stars 23 forks source link

(MoHAA/Spearhead/Breaktrough) The soldiers aren't displayed correctly in a Release mode #337

Closed gbudny closed 2 months ago

gbudny commented 3 months ago

Hi

I want to inform you that all soldiers aren't displayed correctly only in a Release mode in all levels.

Tooltip_035

https://gist.github.com/gbudny/a86604e5fb49f07344b3529de3a6e661

Can you fix it?

smallmodel commented 2 months ago

I tried MSVC, Clang and GCC in release mode and the only compiler that causes openmohaa to have strange issues is GCC. This bug comes from GCC itself when it optimizes code for release mode and it cannot be fixed in openmohaa. There are also a lot of other crashes when using the GCC optimizer, this is why a more stable compiler (like clang) is used for the project instead

gbudny commented 2 months ago

Hi

Thank you for the answer.

I tried MSVC, Clang and GCC in release mode and the only compiler that causes openmohaa to have strange issues is GCC. This bug comes from GCC itself when it optimizes code for release mode and it cannot be fixed in openmohaa.

Is there any workaround for it?

I don't have this issue in Debug mode, so I don't know what is causing it, but it reminds me of this:

https://github.com/openmoh/openmohaa/issues/307

I can switch to Clang, but I have doubts about dropping the support for GCC in OpenMoHAA. It's the popular compiler used by many regular users on Linux and many other operating systems.

I suspect this change could negatively affect the availability of OpenMoHAA for other operating systems in the future. I don't know if Clang is actively maintained on systems like MorphOS, but many users are expecting this port to be released:

https://morph.zone/modules/newbb_plus/viewtopic.php?topic_id=13819&forum=10 https://www.ppa.pl/forum/strefa-gier/46915/medal-of-honor-allied-assault-war-chest-dla-amigaos-i-morphos https://www.meta-morphos.org/viewtopic.php?topic=2382&forum=54 https://www.youtube.com/watch?v=bG_lrdkFVxQ

I hope that users working on the unreleased ports of OpenMoHAA can share their opinions about it.

There are also a lot of other crashes when using the GCC optimizer, this is why a more stable compiler (like clang) is used for the project instead

I have to admit that I haven't tested the Release mode for many months. On the other hand, I can say that OpenMoHAA in the Debug mode is very stable.

For example, I had played the base version (the default sound system) from the beginning to the end without cheat codes, and I only had two random crashes. It's more stable than many other commercial games.

I don't know if OpenMoHAA builds with GCC on Linux are less stable than builds with MSVC on Windows. I saw issues reported on Windows that I have never encountered on Linux.

I hope you reconsider it because it looks like a big change in this project.

smallmodel commented 2 months ago

It's not a big change, the Linux binaries in the Release page of the project are produced by clang (since the beginning), GitHub actions use clang to compile the project. The only rule is that the project must compile with all 3 compilers, GCC, Clang and MSVC. Currently for release/optimized binaries, MSVC/Clang must be used to avoid those bugs, unless there are specific parameters that can be used for the gcc compiler to remove some kind of buggy optimizations.

mohabhassan commented 2 months ago

It's an out-of-hand issue when only GCC has weird behaviour like this, @gbudny your Debug build worked most probably because optimizations are disabled in debug. A quick-and-dirty fix would be to disable all optimizations for GCC on release (would need a new release configuration probably), but there's no telling how it will affect performance. I'm wondering if ioq3 has/had this problem and how'd they solve it.

Cowcat5150 commented 2 months ago

Dhewm3 uses "-fno-math-errno -fno-trapping-math -ffinite-math-only" for gcc anf g++ "-ffp-contract=off".

Way to enable/test those options in Cmakelists ?

smallmodel commented 2 months ago

These parameters don't work after trying, the current issue is the way that GCC optimize loops

gbudny commented 2 months ago

Hi

Thank you for the answers.

I know this issue should exist in both versions:

cmake .. -DCMAKE_BUILD_TYPE=Debug -DDEBUG_DROP_ASSERT=1 -DDEBUG_MEMORY=1

Unfortunately, I only have this issue when I build it this way.

cmake .. -DCMAKE_BUILD_TYPE=Release

@Cowcat5150 I added these parameters to a file: CMakeLists.txt. I'm not sure if I did it correctly because I still have this problem:

https://we.tl/t-gYRua0Diud

Can you check my file?

gbudny commented 2 months ago

@smallmodel PtitSeb is developing OpenMoHAA for OpenPandora and has a question about Clang.

It looks like GCC is more common on MorphOS and OpenPandora.

@ptitSeb

Clang (an old version) can be available on the OpenPandora, but I don't really maintain it anymore... Why would Clang be needed?

https://pyra-handheld.com/boards/threads/medal-of-honor-allied-assault-war-chest-on-pyra-openpandora.100011/page-4#post-1719478

smallmodel commented 2 months ago

Anyone can use whatever compiler they want, but must be aware of stability issues when enabling optimizations with GCC

smallmodel commented 2 months ago

It should be fixed now, there were 2 issues that caused GCC optimizer to behave strangely

gbudny commented 2 months ago

Thank you.

It works now!