From ce04bc87e1fdfd3f74539839091be56c2fc41e86 Mon Sep 17 00:00:00 2001 From: Alexey Gerenkov Date: Sat, 20 Mar 2021 00:37:15 +0300 Subject: [PATCH] gcov: Fixes not linked gcov rtio functions --- components/app_trace/CMakeLists.txt | 16 ++++++++++------ components/app_trace/component.mk | 9 +++++---- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/components/app_trace/CMakeLists.txt b/components/app_trace/CMakeLists.txt index 3ee0ff6555..0861299b2c 100644 --- a/components/app_trace/CMakeLists.txt +++ b/components/app_trace/CMakeLists.txt @@ -33,10 +33,14 @@ idf_component_register(SRCS "${srcs}" PRIV_REQUIRES soc LDFRAGMENTS linker.lf) -# disable --coverage for this component, as it is used as transport -# for gcov -target_compile_options(${COMPONENT_LIB} PRIVATE "-fno-profile-arcs" "-fno-test-coverage") -# Force app_trace to also appear later than gcov in link line -idf_component_get_property(app_trace app_trace COMPONENT_LIB) -target_link_libraries(${COMPONENT_LIB} INTERFACE $ gcov $ c) +if(CONFIG_APPTRACE_GCOV_ENABLE) + # disable --coverage for this component, as it is used as transport + # for gcov + target_compile_options(${COMPONENT_LIB} PRIVATE "-fno-profile-arcs" "-fno-test-coverage") + + # Force app_trace to also appear later than gcov in link line + idf_component_get_property(app_trace app_trace COMPONENT_LIB) + target_link_libraries(${COMPONENT_LIB} INTERFACE + "-Wl,--undefined=gcov_rtio_atexit" $ gcov $ c) +endif() diff --git a/components/app_trace/component.mk b/components/app_trace/component.mk index a17fa814f0..5dd08322d3 100644 --- a/components/app_trace/component.mk +++ b/components/app_trace/component.mk @@ -8,11 +8,7 @@ COMPONENT_ADD_INCLUDEDIRS = include COMPONENT_ADD_LDFLAGS = -lapp_trace -# do not produce gcov info for this module, it is used as transport for gcov -CFLAGS := $(subst --coverage,,$(CFLAGS)) - ifdef CONFIG_SYSVIEW_ENABLE - COMPONENT_ADD_INCLUDEDIRS += \ sys_view/Config \ sys_view/SEGGER \ @@ -26,7 +22,12 @@ COMPONENT_SRCDIRS += \ sys_view/esp32 \ sys_view/ext else +ifdef CONFIG_APPTRACE_GCOV_ENABLE +# do not produce gcov info for this module, it is used as transport for gcov +CFLAGS := $(subst --coverage,,$(CFLAGS)) +COMPONENT_ADD_LDFLAGS += -Wl,--undefined=gcov_rtio_atexit COMPONENT_SRCDIRS += gcov endif +endif COMPONENT_ADD_LDFRAGMENTS += linker.lf