I’m cross compiling my application with PLATFORM=gcc for testing.
In my unit tests, I use gcc’s address sanitizer, undefined behavior sanitizer and coverage reporting: -fsanitize=address -fsanitize=undefined -fprofile-arcs -ftest-coverage --coverage -fprofile-arcs
.
I would like to include do this for the cross-compiled executable too, but I can’t get the linker to include the dependencies.
These linker flags should ensure that gcov, libasan and libusan are available when linking.
LDFLAGS += --coverage -fsanitize=address,undefined
If I add them in build/module.mk
like below, the linker has no problems.
$(TARGET_BASE)$(EXECUTABLE_EXTENSION) : $(ALLOBJ) $(LIB_DEPS) $(LINKER_DEPS)
$(call echo,'Building target: $@')
$(call echo,'Invoking: GCC C++ Linker')
$(VERBOSE)$(MKDIR) $(dir $@)
$(VERBOSE)$(CCACHE) $(CPP) $(CFLAGS) $(ALLOBJ) --output $@ $(LDFLAGS) --coverage -fsanitize=address,undefined
$(call echo,)
But if I add them in the build.mk of the user app, the linker cannot find the dependencies.
I’m guessing they are lost between building the user module and the final link step, but can’t figure out how.
What would be the correct way to include these libraries when linking?