diff --git a/CMakeLists.txt b/CMakeLists.txt index cf7e42c8b7..2a78f92205 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -136,6 +136,10 @@ if(CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_DISABLE) list(APPEND compile_definitions "-DNDEBUG") endif() +if(CONFIG_COMPILER_NO_MERGE_CONSTANTS) + list(APPEND compile_options "-fno-merge-constants") +endif() + if(CONFIG_COMPILER_STACK_CHECK_MODE_NORM) list(APPEND compile_options "-fstack-protector") elseif(CONFIG_COMPILER_STACK_CHECK_MODE_STRONG) diff --git a/Kconfig b/Kconfig index 8768a086f2..1d9e813748 100644 --- a/Kconfig +++ b/Kconfig @@ -529,6 +529,15 @@ mainmenu "Espressif IoT Development Framework Configuration" help Stack smashing protection. + config COMPILER_NO_MERGE_CONSTANTS + bool "Disable merging const sections" + depends on IDF_TOOLCHAIN_GCC + help + Disable merging identical constants (string/floating-point) across compilation units. + This helps in better size analysis of the application binary as the rodata section + distribution is more uniform across libraries. On downside, it may increase + the binary size and hence should be used during development phase only. + config COMPILER_WARN_WRITE_STRINGS bool "Enable -Wwrite-strings warning flag" default "n" diff --git a/tools/test_apps/system/build_test/sdkconfig.ci.no_merge_constants b/tools/test_apps/system/build_test/sdkconfig.ci.no_merge_constants new file mode 100644 index 0000000000..d30e4da72b --- /dev/null +++ b/tools/test_apps/system/build_test/sdkconfig.ci.no_merge_constants @@ -0,0 +1 @@ +CONFIG_COMPILER_NO_MERGE_CONSTANTS=y