Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
shikoumuzi opened this issue Apr 11, 2024 · 9 comments

Comments

@shikoumuzi
Copy link

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

@raiden00pl
Copy link
Contributor

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

@shikoumuzi
Copy link
Author

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

@xiaoxiang781216
Copy link
Contributor

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

@xuxin930
Copy link
Contributor

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

sure, I'm working on it

@xuxin930
Copy link
Contributor

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

NXSYMBOLS(pthread_create)
#if defined(CONFIG_TLS_NELEM) && CONFIG_TLS_NELEM > 0
NXSYMBOLS(pthread_getspecific)
NXSYMBOLS(pthread_key_create)
#endif
NXSYMBOLS(pthread_kill)
NXSYMBOLS(pthread_mutex_destroy)
NXSYMBOLS(pthread_mutex_init)
NXSYMBOLS(pthread_mutex_lock)
NXSYMBOLS(pthread_mutex_unlock)
#if defined(CONFIG_TLS_NELEM) && CONFIG_TLS_NELEM > 0
NXSYMBOLS(pthread_setspecific)
#endif
NXSYMBOLS(pthread_sigmask)

pthread_attr_init
pthread_attr_setstack
pthread_attr_destroy
pthread_cond_destroy
pthread_cond_init
pthread_cond_signal
pthread_cond_wait
pthread_create
pthread_getspecific
pthread_key_create
pthread_kill
pthread_mutex_destroy
pthread_mutex_init
pthread_mutex_lock
pthread_mutex_unlock
pthread_setspecific
pthread_sigmask

@raiden00pl
Copy link
Contributor

@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:

if(GCCVER EQUAL 12)
set_source_files_properties(libcxx/src/filesystem/operations.cpp
PROPERTIES COMPILE_FLAGS -Wno-maybe-uninitialized)
set_source_files_properties(libcxx/src/locale.cpp
PROPERTIES COMPILE_FLAGS -Wno-maybe-uninitialized)
set_source_files_properties(
libcxx/src/string.cpp PROPERTIES COMPILE_FLAGS -Wno-alloc-size-larger-than)
set_source_files_properties(libcxx/src/charconv.cpp
PROPERTIES COMPILE_FLAGS -Wno-attributes)
set_source_files_properties(libcxx/src/locale.cpp PROPERTIES COMPILE_FLAGS
-Wno-attributes)
endif()
if(GCCVER GREATER_EQUAL 12)
set_source_files_properties(
libcxx/src/string.cpp PROPERTIES COMPILE_FLAGS -Wno-deprecated-declarations)
set_source_files_properties(libcxx/src/filesystem/path.cpp
PROPERTIES COMPILE_FLAGS -Wno-shadow)
set_source_files_properties(libcxx/src/ryu/d2s.cpp
PROPERTIES COMPILE_FLAGS -Wno-maybe-uninitialized)
endif()
if(GCCVER GREATER_EQUAL 13)
set_source_files_properties(
libcxx/src/string.cpp PROPERTIES COMPILE_FLAGS -Wno-alloc-size-larger-than)
endif()

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

@xuxin930
Copy link
Contributor

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
Copy link
Contributor

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.

@raiden00pl
Copy link
Contributor

@xuxin930 great ! thanks for solving the issues

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants