nuttx icon indicating copy to clipboard operation
nuttx copied to clipboard

When i use cmake to build sim:libcxxtest, it display undefined reference to `NXpthread_setspecific'

Open shikoumuzi opened this issue 1 year ago • 9 comments

when i use cmake -B build -DBOARD_CONFIG=sim:libcxxtest it can not compile image but when i use make to build sim libcxxtest, it is running properly what can i do to solve this problem, thanks

shikoumuzi avatar Apr 11 '24 13:04 shikoumuzi

you have to set CONFIG_TLS_NELEM > 0 . It's strange that this problem doesn't occur for make.

raiden00pl avatar Apr 11 '24 13:04 raiden00pl

you have to set CONFIG_TLS_NELEM > 0 . It's strange that this problem doesn't occur for make.

thank you for your reply,That's a good way for me to solve the problem

I found that whatever macro definition "in thread.h" encapsulates a layer of "pthread_key_", "tss_key" and other TLS-related functions. It's strange why make can exclude these functions, but cmake can't

shikoumuzi avatar Apr 12 '24 08:04 shikoumuzi

@xuxin930 could you check why cmake is different from make?

xiaoxiang781216 avatar Apr 12 '24 08:04 xiaoxiang781216

@xuxin930 could you check why cmake is different from make?

sure, I'm working on it

xuxin930 avatar Apr 12 '24 08:04 xuxin930

hi @raiden00pl @xiaoxiang781216 my guess is that the redefined symbols for sim in cmake do not have an if block. let me fix it

https://github.com/apache/nuttx/blob/62a47994090860b8daea0ab61121bcbcd4448ff1/arch/sim/src/nuttx-names.in#L99-L112 https://github.com/apache/nuttx/blob/62a47994090860b8daea0ab61121bcbcd4448ff1/cmake/nuttx_redefine_symbols.cmake#L78-L94

xuxin930 avatar Apr 12 '24 09:04 xuxin930

@xuxin930 good find.

Another problem I have with this configuration (and with libcxx in general) is a lot of warnings during compilation. It looks like compiler flags from here doesn't work: https://github.com/apache/nuttx/blob/62a47994090860b8daea0ab61121bcbcd4448ff1/libs/libxx/libcxx.cmake#L99-L124 I haven't had a chance to look for the cause of this problem yet. I'm not sure if this problem only occurs for me on arch linux

raiden00pl avatar Apr 12 '24 10:04 raiden00pl

I haven't had a chance to look for the cause of this problem yet. I'm not sure if this problem only occurs for me on arch linux

Okay, let me check the toolchain file settings and compile otpions settings again.

xuxin930 avatar Apr 12 '24 10:04 xuxin930

I haven't had a chance to look for the cause of this problem yet. I'm not sure if this problem only occurs for me on arch linux

hi @raiden00pl there are two errors:

  1. the toolchain file is not synchronized and is lagging behind. I will update it first.
  2. CMake set_source_files_properties does not perform append, but replaces. 😔

regarding the second one, I have implemented nuttx_set_source_files_properties instead of set_source_files_properties and will submit a batch of bugfixes tomorrow.

xuxin930 avatar Apr 15 '24 13:04 xuxin930

@xuxin930 great ! thanks for solving the issues

raiden00pl avatar Apr 15 '24 14:04 raiden00pl