Skip to content

Commit

Permalink
Don't clobber existing CMAKE_CXX_FLAGS_RELEASE
Browse files Browse the repository at this point in the history
We were likely losing -DNDEBUG. Preserve our current intent to clobber the -O flag in particular, though.

ghstack-source-id: 5ac98ab449f4d2ed9df9d5ee28cb3f3b63eb9f15
ghstack-comment-id: 2599288432
Pull Request resolved: #7742
  • Loading branch information
swolchok committed Jan 17, 2025
1 parent cd0e584 commit a7b77d8
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -149,19 +149,19 @@ endif()
# they can be properly gc'd. -s: strip symbol. -fno-exceptions -fno-rtti:
# disables exceptions and runtime type.
set(CMAKE_CXX_FLAGS_RELEASE
"-ffunction-sections -fdata-sections -fno-exceptions -fno-rtti"
"-ffunction-sections -fdata-sections -fno-exceptions -fno-rtti ${CMAKE_CXX_FLAGS_RELEASE}"
)
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -s")
endif()

option(OPTIMIZE_SIZE "Build executorch runtime optimizing for binary size" OFF)
if(OPTIMIZE_SIZE)
# -Os: Optimize for size
set(CMAKE_CXX_FLAGS_RELEASE "-Os ${CMAKE_CXX_FLAGS_RELEASE}")
# -Os: Optimize for size.
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -Os")
else()
# -O2: Moderate opt.
set(CMAKE_CXX_FLAGS_RELEASE "-O2 ${CMAKE_CXX_FLAGS_RELEASE}")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O2")
endif()

set(CMAKE_CXX_FLAGS_DEBUG "-O0 -g")
Expand Down

0 comments on commit a7b77d8

Please sign in to comment.