casaroli opened a new pull request, #20813:
URL: https://github.com/apache/nuttx/pull/20813

   ## Summary
   
   `CONFIG_COVERAGE_ALL` adds `-fprofile-arcs -ftest-coverage` (clang: 
`-fprofile-instr-generate -fcoverage-mapping`) to the compile options. A 
loadable module of a flat or protected build takes them too: in CMake through 
the targets of `nuttx_add_application()`, and in both build systems through 
crt0 (`STARTUP_OBJS` in CMake, `CELFFLAGS` in the arch Makefiles). The module 
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:
   
   ```
   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 and of crt0 in `nuttx_add_application()`, and from the crt0 compile of 
arm, arm64, risc-v and x86_64 in Make (`ELF_NOCOVERAGE` in `tools/Config.mk`). 
The module objects of the Make build are compiled by apps, which gets the same 
change in an apache/nuttx-apps PR ("build: Build a loadable module without the 
coverage options").
   
   ## Impact
   
   Builds with `CONFIG_COVERAGE_ALL` and loadable modules: the modules load, 
without coverage data. The image keeps its coverage, and a kernel build does 
not change.
   
   ## Testing
   
   `qemu-armv8a:nsh` (flat, Arm GNU 14.2, QEMU HVF) with `CONFIG_COVERAGE_ALL`, 
`CONFIG_COVERAGE_MINI`, `CONFIG_ELF`, `CONFIG_EXECFUNCS_SYSTEM_SYMTAB`; TLS 
test programs and `hello` as loadable modules from a 9p share:
   
   | Build | master | this PR |
   |---|---|---|
   | CMake | every module: `Exported symbol "__gcov_init" not found` | 
tlsgroup, tls4, tlsmany, uctls, tlscxx PASS; `Hello, World!!` |
   | Make, with the apps PR | every module: `Exported symbol "__gcov_init" not 
found` (crt0.o has 9 gcov symbols) | tlsgroup, tls4, tlsmany, uctls, tlscxx, 
tlsdl PASS; `Hello, World!!` |
   
   In both builds `crt0` and the module objects have no gcov symbols, and the 
image keeps them: `__gcov_init` is in `nuttx`, and `sched_lock` is compiled 
with coverage.
   
   The tests ran with #20723 and #20807 for the TLS programs and 
`get_environ_ptr`, and with the apache/nuttx-apps PRs for the emutls of a 
module and for `hello` in CMake.
   
   `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]

Reply via email to