From a9a1b976a7cbac855523996dbe4197caf014d99c Mon Sep 17 00:00:00 2001 From: George Joseph Date: Thu, 30 Oct 2025 06:55:49 -0600 Subject: [PATCH] build: Add menuselect options to facilitate code tracing and coverage The following options have been added to the menuselect "Compiler Flags" section... CODE_COVERAGE: The ability to enable code coverage via the `--enable-coverage` configure flag has existed for many years but changing it requires re-running ./configure which is painfully slow. With this commit, you can now enable and disable it via menuselect. Setting this option adds the `-ftest-coverage` and `-fprofile-arcs` flags on the gcc and ld command lines. It also sets DONT_OPTIMIZE. Note: If you use the `--enable-coverage` configure flag, you can't turn it off via menuselect so choose one method and stick to it. KEEP_FRAME_POINTERS: This option sets `-fno-omit-frame-pointers` on the gcc command line which can facilitate debugging with 'gdb' and tracing with 'perf'. Unlike CODE_COVERAGE, this option doesn't depend on optimization being disabled. It does however conflict with COMPILE_DOUBLE. --- Makefile.rules | 12 ++++++++---- build_tools/cflags.xml | 11 +++++++++++ 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/Makefile.rules b/Makefile.rules index d39640ee29..7319a1a6bb 100644 --- a/Makefile.rules +++ b/Makefile.rules @@ -82,17 +82,21 @@ ifeq ($(CC),gcc) endif endif -ifeq ($(findstring DONT_OPTIMIZE,$(MENUSELECT_CFLAGS))$(AST_CODE_COVERAGE),no) +ifeq ($(findstring DONT_OPTIMIZE,$(MENUSELECT_CFLAGS))$(findstring CODE_COVERAGE,$(MENUSELECT_CFLAGS))$(findstring CODE_PROFILE,$(MENUSELECT_CFLAGS))$(AST_CODE_COVERAGE),no) _ASTCFLAGS+=$(OPTIMIZE) else _ASTCFLAGS+=-O0 endif -ifeq ($(AST_CODE_COVERAGE),yes) +ifeq ($(findstring CODE_COVERAGE,$(MENUSELECT_CFLAGS))$(AST_CODE_COVERAGE),no) + _ASTCFLAGS_COVERAGE= +else _ASTCFLAGS_COVERAGE=-ftest-coverage -fprofile-arcs _ASTLDFLAGS+=-ftest-coverage -fprofile-arcs -else - _ASTCFLAGS_COVERAGE= +endif + +ifneq ($(findstring KEEP_FRAME_POINTERS,$(MENUSELECT_CFLAGS)),) + _ASTCFLAGS+=-fno-omit-frame-pointer endif ifeq ($(findstring $(CONFIG_CFLAGS),$(_ASTCFLAGS)),) diff --git a/build_tools/cflags.xml b/build_tools/cflags.xml index 38a2683f96..41d35e7757 100644 --- a/build_tools/cflags.xml +++ b/build_tools/cflags.xml @@ -5,6 +5,8 @@ DONT_OPTIMIZE + KEEP_FRAME_POINTERS + CODE_COVERAGE core @@ -132,4 +134,13 @@ core no + + COMPILE_DOUBLE + core + + + extended + DONT_OPTIMIZE + + -- 2.47.3