Skip to content

Commit c6f2e4a

Browse files
committed
CMake: Disable COMDAT folding on MSVC
State checks can break on MSVC because Player_State_Static and Player_State_TransportTube (maybe more) are empty and are therefore identical and can be merged. While GCC/Clang knows not to merge both since their addresses are being referenced in the code, but MSVC thinks it's a smart optimization to do... Fixes #303.
1 parent 8795c5a commit c6f2e4a

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

CMakeLists.txt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,4 +93,10 @@ else()
9393
MANIA_FIRST_RELEASE=$<BOOL:${MANIA_FIRST_RELEASE}>
9494
GAME_VERSION=${GAME_VERSION}
9595
)
96-
endif()
96+
endif()
97+
98+
# MSVC likes to merge similar functions together even though their addresses are being referenced.
99+
# Disable COMDAT folding to fix some bugs like not drowning when suspended to a pull chain in HCZ.
100+
if(MSVC)
101+
target_link_options(${GAME_NAME} PRIVATE /OPT:NOICF)
102+
endif()

0 commit comments

Comments
 (0)