Build: Add optimisation flag build option
Add a TFM wide flag which allows for adding -Og optimisation for Debug
builds. Note that this does not have an impact on assertions which will
still be enabled in Debug builds and will not effect any other command
line flags, it only passes -Og.
This optimisation flag has the following benefits:
- Speeds up code execution
- Vastly reduces code size
- Allows the optimiser to generate more advanced warnings such as
-Wmaybe-uninitialised
The drawback is that optimisations make the code more difficult to step
through although with -Og, given that this flag is designed for
debugging, these should be minimal. The user will still
be able to build without optimisations if desired by overriding this
flag on the command line.
Change-Id: I93e7603700b3111e62723c72087211bbe080a40d
Signed-off-by: Jackson Cooper-Driver <jackson.cooper-driver@arm.com>
diff --git a/config/config_base.cmake b/config/config_base.cmake
index 326ddd5..fd7c19f 100644
--- a/config/config_base.cmake
+++ b/config/config_base.cmake
@@ -28,6 +28,7 @@
set(INSTALL_PLATFORM_NS_DIR ${CMAKE_INSTALL_PREFIX}/platform)
set(TFM_DEBUG_SYMBOLS ON CACHE BOOL "Add debug symbols. Note that setting CMAKE_BUILD_TYPE to Debug or RelWithDebInfo will also add debug symbols.")
+set(TFM_DEBUG_OPTIMISATION OFF CACHE BOOL "Add basic -Og optimisation when CMAKE_BUILD_TYPE is Debug. Note that non Debug builds specify their own optimisation")
set(TFM_CODE_COVERAGE OFF CACHE BOOL "Whether to build the binary for lcov tools")
set(TFM_TESTS_REVISION_CHECKS ON CACHE BOOL "Whether to perform checks on the tf-m-tests repository revision.")