casaroli opened a new pull request, #3886: URL: https://github.com/apache/nuttx-apps/pull/3886
## Summary `CONFIG_COVERAGE_ALL` adds `-fprofile-arcs -ftest-coverage` (clang: `-fprofile-instr-generate -fcoverage-mapping`) to the compile options, and the module options `CELFFLAGS` and `CMODULEFLAGS` take them too. A loadable module of a flat or protected build then refers to `__gcov_init()`, `__gcov_merge_add()` and `__gcov_exit()`. The image has them, but the system symbol table does not export them, so no module loads. The simulator config `sim:nsh` has `CONFIG_COVERAGE_ALL`: ``` libelf_symvalue: ERROR: SHN_UNDEF: Exported symbol "__gcov_init" not found nsh: hello: command not found ``` This PR removes the coverage options from the compile options of a loadable module in `Application.mk` and `Library.mk`. The list is in `Make.defs` (`NOCOVERAGE`), and it is empty in a kernel build. ## Impact Builds with `CONFIG_COVERAGE_ALL` and loadable modules: the modules load, without coverage data. The image keeps its coverage, and the programs of a kernel build do not change. ## Testing Linux x86_64 simulator (Debian 12, gcc 12), `sim:nsh` with its own options (`CONFIG_COVERAGE_ALL`, `CONFIG_COVERAGE_TOOLCHAIN`), plus `CONFIG_ELF`, `CONFIG_EXECFUNCS_SYSTEM_SYMTAB`, `CONFIG_SIM_HOSTFS`, `CONFIG_EXAMPLES_HELLO=m` and `CONFIG_TESTING_GETPRIME=m`; modules loaded from hostfs: | | master | this PR | |---|---|---| | hello compile options | `-fprofile-arcs -ftest-coverage -fno-inline` | `-fno-inline` | | hello: undefined symbols | `__gcov_exit __gcov_init __gcov_merge_add puts` | `puts` | | run hello | `Exported symbol "__gcov_init" not found` | `Hello, World!!` | | run getprime | not run (the run stops at the first error); `nm` shows `U __gcov_init` | `found 1230 primes`, `Done` | | image: `sched_lock.c` compile | `-fprofile-arcs -ftest-coverage` | `-fprofile-arcs -ftest-coverage` | | image: `__gcov_init` | present | present | The test needs nuttx apache/nuttx#20807 (`get_environ_ptr` in libc.csv) to load any ELF program with the system symbol table. On arm, arm64, risc-v and x86_64 the module also links crt0, which nuttx compiles: apache/nuttx#20813 removes the options there and in the CMake build. On `qemu-armv8a:nsh` with `CONFIG_COVERAGE_ALL`, the modules load only with both PRs. `tools/checkpatch.sh -c -u -m -g` passes. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
