Compare commits

...

2 Commits

Author SHA1 Message Date
Zhao Yuhang 5f12a41393 update 2023-11-16 12:15:59 +08:00
Zhao Yuhang 914832b4da update 2023-11-16 11:28:26 +08:00
1 changed files with 15 additions and 4 deletions

View File

@ -698,7 +698,10 @@ function(setup_compile_params)
)
if(NOT (CMAKE_CXX_COMPILER_ID STREQUAL "Clang"))
target_compile_options(${__target} PRIVATE
/bigobj /FS /MP /utf-8 $<$<CONFIG:Release>:/fp:fast /GT /Gw /Gy /Oi /Ot /Oy /Zc:inline>
# NOTE:
# Don't add "/fp:fast" unless absolutely necessary, because it makes many floating point
# based math calculations give very wrong result, eg: NaN.
/bigobj /FS /MP /utf-8 $<$<CONFIG:Release>:/GT /Gw /Gy /Oi /Ot /Oy /Zc:inline>
)
if(COM_ARGS_SECURE_CODE)
target_compile_options(${__target} PRIVATE
@ -838,8 +841,15 @@ function(setup_compile_params)
else()
target_compile_options(${__target} PRIVATE
-fthreadsafe-statics
$<$<CONFIG:Release>:-fmerge-all-constants -ffp-contract=fast -fomit-frame-pointer
-ffunction-sections -fdata-sections -funroll-all-loops>
# NOTE #1:
# https://gcc.gnu.org/onlinedocs/gcc-13.2.0/gcc/Optimize-Options.html#index-ffp-contract
# The official documentation tells us that "-ffp-contract=fast" is compiler default,
# does it mean GCC/Clang doesn't have the same math calculation issue with MSVC?
# NOTE #2:
# -fomit-frame-pointer: Enabled by default at -O1 and higher.
# NOTE #3:
# -funroll-all-loops: This usually makes programs run more slowly.
$<$<CONFIG:Release>:-fmerge-all-constants -ffunction-sections -fdata-sections -funroll-loops>
)
if(APPLE)
target_link_options(${__target} PRIVATE
@ -949,7 +959,8 @@ function(setup_compile_params)
-fansi-escape-codes
/Zc:dllexportInlines- # Do not export inline member functions. This is similar to "-fvisibility-inlines-hidden".
/Zc:char8_t /Zc:sizedDealloc /Zc:strictStrings /Zc:threadSafeInit /Zc:trigraphs /Zc:twoPhase
$<$<CONFIG:Release>:/clang:-mbranches-within-32B-boundaries /fp:fast /Gw /Gy /Oi /Ot /Zc:inline>
# No "/fp:fast", same reason as MSVC above.
$<$<CONFIG:Release>:/clang:-mbranches-within-32B-boundaries /Gw /Gy /Oi /Ot /Zc:inline>
)
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
target_compile_options(${__target} PRIVATE