diff options
author | Sam Clegg <sbc@chromium.org> | 2023-04-28 17:32:59 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-29 00:32:59 +0000 |
commit | e87d3a455580b20fa71abf5fe58b6d62cb41980d (patch) | |
tree | c1b81c2b9750c953619a572fd575f7f55afc626e | |
parent | e3ff8b539355df39dd1222322e7f55e81e297390 (diff) | |
download | binaryen-e87d3a455580b20fa71abf5fe58b6d62cb41980d.tar.gz binaryen-e87d3a455580b20fa71abf5fe58b6d62cb41980d.tar.bz2 binaryen-e87d3a455580b20fa71abf5fe58b6d62cb41980d.zip |
Avoid specifying multiple opt level in cflags (#5103)
CMake defaults to -O3 to release builds. We were overriding that to
-O2 in general and re-overriding back to -O3 for emscripten.
-rw-r--r-- | CMakeLists.txt | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 07ed2f96d..27d9744b2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -290,9 +290,7 @@ else() elseif(NOT EMSCRIPTEN) add_compile_flag("-fPIC") endif() - add_debug_compile_flag("-O0") add_debug_compile_flag("-g3") - add_nondebug_compile_flag("-O2") if(BYN_ENABLE_ASSERTIONS) # On non-Debug builds cmake automatically defines NDEBUG, so we # explicitly undefine it: @@ -320,10 +318,12 @@ if(EMSCRIPTEN) endif() if("${CMAKE_BUILD_TYPE}" MATCHES "Release") - # link with -O3 for metadce and other powerful optimizations. note that we - # must use add_link_options so that this appears after CMake's default -O2 - add_link_options("-O3") add_link_flag("-sSINGLE_FILE") + # Extra check that cmake has set -O3 in its release flags. + # This is really as an assertion that cmake is behaving as we expect. + if(NOT CMAKE_CXX_FLAGS_RELEASE_INIT MATCHES "-O3") + message(FATAL_ERROR "Expected -O3 to be in release link flags") + endif() endif() add_link_flag("-sALLOW_MEMORY_GROWTH") |