summaryrefslogtreecommitdiff
path: root/cmake-nRF5x/CMake_nRF5x.cmake
diff options
context:
space:
mode:
authorJF002 <JF002@users.noreply.github.com>2021-06-01 21:03:01 +0200
committerGitHub <noreply@github.com>2021-06-01 21:03:01 +0200
commit1b6acdedc2ae892bece04479a64ad28120eced8c (patch)
tree08e470ec01c51ccbefd0be1759efe0177484821c /cmake-nRF5x/CMake_nRF5x.cmake
parentc0b0f8cb732f0cd8c6a519a97f41b0ef6275a24f (diff)
Enable various compilation flags to reduce the binary size (#401)
* Add the following compilation flags: * -fno-exceptions and -fno-non-call-exceptions : disable exception handling * -fno-rtti : disable run time type information (needed by dynamic_cast, for example) These flags reduce the binary size by about 100KB! Also, -fstack-usage generate debug info (not in final binary) to allow tools like Puncover to do a stack analysis. * Remove unused CMake variables in CMake_nRF5x.cmake (duplicated in src/CMakeLists.txt). Replace -O0 by -Og in DEBUG builds. This generates a smaller binary (small enough for the internal memory) that is debugger friendly.
Diffstat (limited to 'cmake-nRF5x/CMake_nRF5x.cmake')
-rwxr-xr-xcmake-nRF5x/CMake_nRF5x.cmake15
1 files changed, 0 insertions, 15 deletions
diff --git a/cmake-nRF5x/CMake_nRF5x.cmake b/cmake-nRF5x/CMake_nRF5x.cmake
index ead7b9f6..c7d0a68b 100755
--- a/cmake-nRF5x/CMake_nRF5x.cmake
+++ b/cmake-nRF5x/CMake_nRF5x.cmake
@@ -74,21 +74,6 @@ macro(nRF5x_setup)
)
endif ()
- set(COMMON_FLAGS "-MP -MD -mthumb -mabi=aapcs -Wall -g3 -ffunction-sections -fdata-sections -fno-strict-aliasing -fno-builtin --short-enums ${CPU_FLAGS} -Wreturn-type -Werror=return-type")
-
- # compiler/assambler/linker flags
- set(CMAKE_C_FLAGS "${COMMON_FLAGS}")
- set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -O0 -g3")
- set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -O3")
- set(CMAKE_CXX_FLAGS "${COMMON_FLAGS}")
- set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O0 -g3")
- set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3")
- set(CMAKE_ASM_FLAGS "-MP -MD -x assembler-with-cpp")
- set(CMAKE_EXE_LINKER_FLAGS "-mthumb -mabi=aapcs -L ${NRF5_SDK_PATH}/modules/nrfx/mdk -T${NRF5_LINKER_SCRIPT} ${CPU_FLAGS} -Wl,--gc-sections --specs=nano.specs -lc -lnosys -lm")
- # note: we must override the default cmake linker flags so that CMAKE_C_FLAGS are not added implicitly
- set(CMAKE_C_LINK_EXECUTABLE "${CMAKE_C_COMPILER} <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>")
- set(CMAKE_CXX_LINK_EXECUTABLE "${CMAKE_C_COMPILER} <LINK_FLAGS> <OBJECTS> -lstdc++ -o <TARGET> <LINK_LIBRARIES>")
-
# basic board definitions and drivers
include_directories(
"${NRF5_SDK_PATH}/components"