Skip to content

Commit 3a566c9

Browse files
authored
Merge pull request #816 from hjyamauchi/arm64miscompile
Add a workaround for Windows ARM64 miscompile
2 parents 1c0abe7 + d4147e8 commit 3a566c9

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/CMakeLists.txt

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,24 @@ else()
124124
target_compile_options(dispatch PRIVATE -Wall)
125125
endif()
126126

127+
# Work around a release-mode miscompile on windows arm64
128+
# Disable /Os and /Ot in /O1 and /O2 on queue.c
129+
if(("${CMAKE_C_SIMULATE_ID}" STREQUAL "MSVC") AND
130+
(("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "ARM64") OR
131+
("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "aarch64")))
132+
string(TOUPPER "${CMAKE_BUILD_TYPE}" uppercase_CMAKE_BUILD_TYPE)
133+
set(FLAGS_BUILD_TYPE "${CMAKE_C_FLAGS_${uppercase_CMAKE_BUILD_TYPE}}")
134+
string(REGEX MATCHALL "/[Oo][12]" FLAGS "${CMAKE_C_FLAGS} ${FLAGS_BUILD_TYPE}")
135+
if (FLAGS)
136+
if (FLAGS MATCHES "1$")
137+
set(FLAGS "/Od;/Og;/Oy;/Ob2;/GF;/Gy")
138+
elseif (FLAGS MATCHES "2$")
139+
set(FLAGS "/Od;/Og;/Oi;/Oy;/Ob2;/GF;/Gy")
140+
endif()
141+
set_source_files_properties(queue.c PROPERTIES COMPILE_OPTIONS "${FLAGS}")
142+
endif()
143+
endif()
144+
127145
# FIXME(compnerd) add check for -fblocks?
128146
target_compile_options(dispatch PRIVATE -fblocks)
129147

0 commit comments

Comments
 (0)