Open yf13 opened 11 months ago
Configurations with CONFIG_ALLSYMS
needs to call tools/mkallsyms.py
(or tools/mkallsyms.sh
) which is not currently supported by cmake build system. Here's how it's done with make: https://github.com/apache/nuttx/blob/4f9d0149947cc3625726127e491cc5b8f978c690/arch/risc-v/src/Makefile#L164-L171
and something similar must be ported to cmake
@raiden00pl thanks a lot. The above point explains CMake's undefined errors when CONFIG_ALLSYMS=y
.
How does Makefile system work well when CONFIG_ALLSYMS=n
but CONFIG_NSH_SYMTAB=y
? Does it contain logic so that undefined errors don't happen?
It looks like CONFIG_NSH_SYMTAB
is also not supported for cmake. We have function to generate symbol table in cmake/nuttx_add_symtab.cmake
but it's not called anywhere and it's quite possible that this logic hasn't been tested by anyone before.
How does Makefile system works well when CONFIG_ALLSYMS=n but CONFIG_NSH_SYMTAB=y? Does it contain logic so that undefined errors don't happen?
CONFIG_ALLSYMS
depends on g_allsyms
and is used for debug purposes (%pS
and %ps
format strings for printf, here doc from Linux https://www.kernel.org/doc/html/v4.19/core-api/printk-formats.html#symbols-function-pointers):
CONFIG_NSH_SYMTAB
depends on symbol table called CONFIG_NSH_SYMTAB_ARRAYNAME
which for upstream boards is usually g_symtab
.
These are two separate symbol tables, generated in a different way:
CONFIG_NSH_SYMTAB
table generated by apps/tools/mksymtab.sh
(or mentioned earlier cmake/nuttx_add_symtab.cmake
)CONFIG_ALLSYMS
table generated by nuttx/tools/mkallsyms.{py|sh}
For the
rv-virt:nsh
target, make approach works well, but CMake build leads to undefined symbols forg_symtab
etc. It seems thatdefconfig
hasCONFIG_ALLSYMS
off andCONFIG_NSH_SYMTAB
on.Further tests show that:
CONFIG_NSH_SYMTAB
is on andCONFIG_ALLSYMS
is off, Make build works but CMake fails.CONFIG_NSH_SYMTAB
andCONFIG_ALLSYMS
are off, CMake build works.CONFIG_NSH_SYMTAB
andCONFIG_ALLSYMS
are on, Makefile build works out a larger binary but CMake build leads to undefinedg_symtab
etc.Is this issue in current CMake system or something else?