Closed manoj153 closed 3 years ago
any updates? keen to learn or get some hints what's going on atleast, I can try experimenting for a fix on my end
cc @pfalcon
Reviewing the newlib source code, pthread_t
and its friends should only be defined by the newlib when defined(_POSIX_THREADS) || __POSIX_VISIBLE >= 199506
:
https://github.com/zephyrproject-rtos/newlib-cygwin/blob/b1fe4401fdbd0860e0b91227219b15d2e0142b78/newlib/libc/include/sys/_pthreadtypes.h#L21
As far as tests/posix/common
, which covers pthread, is concerned, it is run with CONFIG_NEWLIB_LIBC=y
and not having any issues. Neither _POSIX_THREADS
nor __POSIX_VISIBLE
is defined in this particular test, making me wonder where/how they are defined in your project.
Also, your CMakeFiles.txt
does not look right -- it is not using the proper Zephyr primitives.
You should either be incorporating that library as a directory under lib/
in the Zephyr repository (not recommended since we are moving non-essential libraries out to modules), or as a Zephyr module (recommended).
See the CMakeLists.txt
files under the relevant directories as to how they should be written (e.g. https://github.com/zephyrproject-rtos/zephyr/blob/e62c3c533a37a4e7a413500a6375a350306e1e0f/lib/gui/lvgl/CMakeLists.txt for lib/
approach).
As per the assessment above, this does not seem to be a Zephyr-side issue.
Closing due to lack of response. Please re-open this issue if you think otherwise.
Hi. I'm facing exactly the same problem.
If you enable CONFIG_POSIX_API=y compiler sees POSIX structures from the external library and from native support. The problem is that those structures are different.
I have run that test locally and POSIX is always taken from the native support:
ding C object zephyr/lib/posix/CMakeFiles/lib__posix.dir/pthread_barrier.c.obj [67/136] Building C object zephyr/lib/posix/CMakeFiles/lib__posix.dir/pthread_mutex.c.obj [68/136] Building C object zephyr/lib/posix/CMakeFiles/lib__posix.dir/pthread_sched.c.obj [69/136] Building C object zephyr/lib/posix/CMakeFiles/lib__posix.dir/sleep.c.obj [70/136] Building C object zephyr/lib/posix/CMakeFiles/lib__posix.dir/clock.c.obj [71/136] Building C object zephyr/lib/posix/CMakeFiles/lib__posix.dir/pthread_key.c.obj [72/136] Building C object zephyr/lib/posix/CMakeFiles/lib__posix.dir/semaphore.c.obj [73/136] Building C object zephyr/lib/posix/CMakeFiles/lib__posix.dir/timer.c.obj
If I use GNU ARM toolchain and use C++ Standard Library I get the same output as @manoj153.
Please reopen this one.
I'm also running into this issue. Trying to build external library with CMake ExternalProject, passing along Zephyr build parameters, doesn't seem to work well when both newlib and posix api support are enabled. Any guidance from Zephyr devs or hints for further debugging are welcome.
As far as
tests/posix/common
, which covers pthread, is concerned, it is run withCONFIG_NEWLIB_LIBC=y
and not having any issues. Neither_POSIX_THREADS
nor__POSIX_VISIBLE
is defined in this particular test, making me wonder where/how they are defined in your project.
These are set internally by newlib headers (sys/features.h). The only way I can successfully omit that is with -nostdinc, which is not what I want (I need the other newlib headers, just not the _pthreadtypes).
Maybe a fix is coming up, noticed this PR: https://github.com/zephyrproject-rtos/zephyr/pull/52087
@PatrickM-ZS Would it be possible to share your prj.conf so I can compare it with my C++ configuration?
@PatrickM-ZS I think this is a valid issue. Not sure why it was closed (maybe Stale?). I'm hoping to resolve the Newlib / zephyr POSIX header issue within the next week.
Hi I have tried what @belussi suggested in #52087 and commented conflicted typas in _pthreadtypes.h -> but failed on linking zephyr_pre0.elf with 2k+ errors:
[build] Consolidate compiler generated dependencies of target zephyr_pre0
[build] [ 94%] Building C object zephyr/CMakeFiles/zephyr_pre0.dir/misc/empty_file.c.obj
[build] [ 94%] Linking CXX executable zephyr_pre0.elf
[build] /opt/zephyr-sdk-0.15.0/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.1.0/../../../../arm-zephyr-eabi/bin/ld.bfd: /opt/zephyr-sdk-0.15.0/arm-zephyr-eabi/arm-zephyr-eabi/lib/thumb/v7e-m/nofp/libstdc++_nano.a(atexit_arm.o): in function `__aeabi_atexit':
[build] atexit_arm.cc:(.text.__aeabi_atexit+0x0): multiple definition of `__aeabi_atexit'; arch/arch/arm/core/aarch32/libarch__arm__core__aarch32.a(__aeabi_atexit.c.obj):/workspaces/daughterboard-application/build/zephyr/arch/arch/arm/core/aarch32/../../../../../../../platforms/zephyr/zephyr_workspace/zephyr-core/arch/arm/core/aarch32/__aeabi_atexit.c:26: first defined here
[build] /opt/zephyr-sdk-0.15.0/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.1.0/../../../../arm-zephyr-eabi/bin/ld.bfd: /opt/zephyr-sdk-0.15.0/arm-zephyr-eabi/arm-zephyr-eabi/lib/thumb/v7e-m/nofp/libm_nano.a(lib_a-acosl.o): in function `acosl':
[build] acosl.c:(.text.acosl+0x0): multiple definition of `acosl'; /opt/zephyr-sdk-0.15.0/arm-zephyr-eabi/arm-zephyr-eabi/lib/thumb/v7e-m/nofp/libstdc++_nano.a(math_stubs_long_double.o):math_stubs_long_double.cc:(.text.acosl+0x0): first defined here
[build] /opt/zephyr-sdk-0.15.0/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.1.0/../../../../arm-zephyr-eabi/bin/ld.bfd: /opt/zephyr-sdk-0.15.0/arm-zephyr-eabi/arm-zephyr-eabi/lib/thumb/v7e-m/nofp/libm_nano.a(lib_a-asinl.o): in function `asinl':
[build] asinl.c:(.text.asinl+0x0): multiple definition of `asinl'; /opt/zephyr-sdk-0.15.0/arm-zephyr-eabi/arm-zephyr-eabi/lib/thumb/v7e-m/nofp/libstdc++_nano.a(math_stubs_long_double.o):math_stubs_long_double.cc:(.text.asinl+0x0): first defined here
[build] /opt/zephyr-sdk-0.15.0/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.1.0/../../../../arm-zephyr-eabi/bin/ld.bfd: /opt/zephyr-sdk-0.15.0/arm-zephyr-eabi/arm-zephyr-eabi/lib/thumb/v7e-m/nofp/libm_nano.a(lib_a-atan2l.o): in function `atan2l':
[build] atan2l.c:(.text.atan2l+0x0): multiple definition of `atan2l'; /opt/zephyr-sdk-0.15.0/arm-zephyr-eabi/arm-zephyr-eabi/lib/thumb/v7e-m/nofp/libstdc++_nano.a(math_stubs_long_double.o):math_stubs_long_double.cc:(.text.atan2l+0x0): first defined here
[build] /opt/zephyr-sdk-0.15.0/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.1.0/../../../../arm-zephyr-eabi/bin/ld.bfd: /opt/zephyr-sdk-0.15.0/arm-zephyr-eabi/arm-zephyr-eabi/lib/thumb/v7e-m/nofp/libm_nano.a(lib_a-atanl.o): in function `atanl':
...
I am using prj.conf flags:
CONFIG_CPLUSPLUS=y
CONFIG_LIB_CPLUSPLUS=y
CONFIG_NEWLIB_LIBC=y
Describe the bug A clear and concise description of what the bug is. Multiple declaration/conflict between
/sys/_pthreadtypes.h
andposix_types.h
I was trying to import and compile an external c source, a posix compliant library with a zephyr based projectExternal library repo: https://github.com/digidotcom/xbee_ansic_library/
What have you tried to diagnose or workaround this issue? Identify which header file is in conflict. Described above
To Reproduce Clone the external library to the project directory, configure it to compile along the project in top-level cmakelist
Expected behavior Successful build
Impact Build error
Logs and console output
XBee subdirectory
CMakeLists.txt
Environment (please complete the following information):
Ubuntu 20.04.2 LTS
Zephyr SDK
0.12.0
Additional context Add any other context about the problem here.