zephyrproject-rtos / zephyr

Primary Git Repository for the Zephyr Project. Zephyr is a new generation, scalable, optimized, secure RTOS for multiple hardware architectures.
https://docs.zephyrproject.org
Apache License 2.0
10.02k stars 6.17k forks source link

`fatal error: sys/_timespec.h: No such file or directory` with v3.7.0-rc2 #75319

Open 0x6e opened 2 days ago

0x6e commented 2 days ago

I've started a discussion regarding this issue, but received no feedback so far.

Describe the bug Compiling my application with v3.7.0-rc2 fails to build:

FAILED: zephyr/lib/os/zvfs/CMakeFiles/lib__os__zvfs.dir/zvfs_eventfd.c.obj 
ccache /usr/bin/gcc -DKERNEL -DK_HEAP_MEM_POOL_SIZE=1024 -D__ZEPHYR__=1 -I<path>/build-native/zephyr/include/generated/zephyr -I<path>/zephyr/include -I<path>/build-native/zephyr/include/generated -I<path>/zephyr/soc/native/inf_clock -I<path>/zephyr/boards/native/native_sim -I<path>/zephyr/scripts/native_simulator/common/src/include -I<path>/zephyr/scripts/native_simulator/native/src/include -g -Wshadow -fno-strict-aliasing -Os -imacros <path>/build-native/zephyr/include/generated/zephyr/autoconf.h -fno-common -g -gdwarf-4 -fdiagnostics-color=always -Wall -Wformat -Wformat-security -Wno-format-zero-length -Wdouble-promotion -Wno-pointer-sign -Wpointer-arith -Wexpansion-to-defined -Wno-unused-but-set-variable -Werror=implicit-int -fno-pic -fno-pie -fno-asynchronous-unwind-tables -fno-reorder-functions --param=min-pagesize=0 -fno-defer-pop -fmacro-prefix-map=<path>/slint/examples/printerdemo_mcu/zephyr=CMAKE_SOURCE_DIR -fmacro-prefix-map=<path>/zephyr=ZEPHYR_BASE -fmacro-prefix-map=<path>=WEST_TOPDIR -ffunction-sections -fdata-sections -m64 -fPIC -fvisibility=hidden -fno-freestanding -std=c11 -MD -MT zephyr/lib/os/zvfs/CMakeFiles/lib__os__zvfs.dir/zvfs_eventfd.c.obj -MF zephyr/lib/os/zvfs/CMakeFiles/lib__os__zvfs.dir/zvfs_eventfd.c.obj.d -o zephyr/lib/os/zvfs/CMakeFiles/lib__os__zvfs.dir/zvfs_eventfd.c.obj -c <path>/zephyr/lib/os/zvfs/zvfs_eventfd.c
In file included from <path>/zephyr/include/zephyr/toolchain.h:50,
                 from <path>/zephyr/include/zephyr/kernel_includes.h:23,
                 from <path>/zephyr/include/zephyr/kernel.h:17,
                 from <path>/zephyr/lib/os/zvfs/zvfs_eventfd.c:9:
<path>/zephyr/include/zephyr/posix/posix_types.h:51:21: error: ‘pthread_attr_t’ undeclared here (not in a function); did you mean ‘pthread_attr’?
   51 | BUILD_ASSERT(sizeof(pthread_attr_t) >= sizeof(struct pthread_attr));
      |                     ^~~~~~~~~~~~~~
<path>/zephyr/include/zephyr/toolchain/gcc.h:87:52: note: in definition of macro ‘BUILD_ASSERT’
   87 | #define BUILD_ASSERT(EXPR, MSG...) _Static_assert((EXPR), "" MSG)
      |                                                    ^~~~
<path>/zephyr/include/zephyr/toolchain/gcc.h:87:51: error: expression in static assertion is not an integer
   87 | #define BUILD_ASSERT(EXPR, MSG...) _Static_assert((EXPR), "" MSG)
      |                                                   ^
<path>/zephyr/include/zephyr/posix/posix_types.h:51:1: note: in expansion of macro ‘BUILD_ASSERT’
   51 | BUILD_ASSERT(sizeof(pthread_attr_t) >= sizeof(struct pthread_attr));
      | ^~~~~~~~~~~~
<path>/zephyr/include/zephyr/posix/posix_types.h:70:21: error: ‘pthread_mutexattr_t’ undeclared here (not in a function); did you mean ‘pthread_mutexattr’?
   70 | BUILD_ASSERT(sizeof(pthread_mutexattr_t) >= sizeof(struct pthread_mutexattr));
      |                     ^~~~~~~~~~~~~~~~~~~
<path>/zephyr/include/zephyr/toolchain/gcc.h:87:52: note: in definition of macro ‘BUILD_ASSERT’
   87 | #define BUILD_ASSERT(EXPR, MSG...) _Static_assert((EXPR), "" MSG)
      |                                                    ^~~~
<path>/zephyr/include/zephyr/toolchain/gcc.h:87:51: error: expression in static assertion is not an integer
   87 | #define BUILD_ASSERT(EXPR, MSG...) _Static_assert((EXPR), "" MSG)
      |                                                   ^
<path>/zephyr/include/zephyr/posix/posix_types.h:70:1: note: in expansion of macro ‘BUILD_ASSERT’
   70 | BUILD_ASSERT(sizeof(pthread_mutexattr_t) >= sizeof(struct pthread_mutexattr));
      | ^~~~~~~~~~~~
<path>/zephyr/include/zephyr/posix/posix_types.h:83:21: error: ‘pthread_condattr_t’ undeclared here (not in a function); did you mean ‘pthread_condattr’?
   83 | BUILD_ASSERT(sizeof(pthread_condattr_t) >= sizeof(struct pthread_condattr));
      |                     ^~~~~~~~~~~~~~~~~~
<path>/zephyr/include/zephyr/toolchain/gcc.h:87:52: note: in definition of macro ‘BUILD_ASSERT’
   87 | #define BUILD_ASSERT(EXPR, MSG...) _Static_assert((EXPR), "" MSG)
      |                                                    ^~~~
<path>/zephyr/include/zephyr/toolchain/gcc.h:87:51: error: expression in static assertion is not an integer
   87 | #define BUILD_ASSERT(EXPR, MSG...) _Static_assert((EXPR), "" MSG)
      |                                                   ^
<path>/zephyr/include/zephyr/posix/posix_types.h:83:1: note: in expansion of macro ‘BUILD_ASSERT’
   83 | BUILD_ASSERT(sizeof(pthread_condattr_t) >= sizeof(struct pthread_condattr));
      | ^~~~~~~~~~~~
<path>/zephyr/include/zephyr/posix/posix_types.h:107:21: error: ‘pthread_once_t’ undeclared here (not in a function); did you mean ‘pthread_once’?
  107 | BUILD_ASSERT(sizeof(pthread_once_t) >= sizeof(struct pthread_once));
      |                     ^~~~~~~~~~~~~~
<path>/zephyr/include/zephyr/toolchain/gcc.h:87:52: note: in definition of macro ‘BUILD_ASSERT’
   87 | #define BUILD_ASSERT(EXPR, MSG...) _Static_assert((EXPR), "" MSG)
      |                                                    ^~~~
<path>/zephyr/include/zephyr/toolchain/gcc.h:87:51: error: expression in static assertion is not an integer
   87 | #define BUILD_ASSERT(EXPR, MSG...) _Static_assert((EXPR), "" MSG)
      |                                                   ^
<path>/zephyr/include/zephyr/posix/posix_types.h:107:1: note: in expansion of macro ‘BUILD_ASSERT’
  107 | BUILD_ASSERT(sizeof(pthread_once_t) >= sizeof(struct pthread_once));
      | ^~~~~~~~~~~~
In file included from <path>/zephyr/include/zephyr/posix/unistd.h:20,
                 from <path>/zephyr/include/zephyr/net/socket.h:1416,
                 from <path>/zephyr/lib/os/zvfs/zvfs_eventfd.c:10:
<path>/zephyr/include/zephyr/posix/sys/stat.h:40:10: fatal error: sys/_timespec.h: No such file or directory
   40 | #include <sys/_timespec.h>
      |          ^~~~~~~~~~~~~~~~~
compilation terminated.

To Reproduce I wasn't able to find any existing samples that set CONFIG_POSIX_API=y which also failed to build.

Expected behavior The applicaiton should compile.

Impact Cannot update to v3.7.0-rc2 (or future versions).

Environment (please complete the following information):

Additional context Git bisect shows the breakage is introduced by the following change: 487a8756c32320f0f1fbe1fbe342849ef89e7440 posix: eventfd: fix dependency cycle between net and posix.

github-actions[bot] commented 2 days ago

Hi @0x6e! We appreciate you submitting your first issue for our open-source project. 🌟

Even though I'm a bot, I can assure you that the whole community is genuinely grateful for your time and effort. 🤖💙

ycsin commented 2 days ago

Would you be able to share the full compile log & autoconf.h?

EDIT: nvm, I managed to reproduce this

west build -b native_sim -p auto zephyr/samples/hello_world/ -- -DCONFIG_CPP=y -DCONFIG_POSIX_API=y -DCONFIG_STD_CPP20=y -DCONFIG_REQUIRES_FULL_LIBCPP=y
ycsin commented 2 days ago

I'm not sure what is the root cause yet, it compiles fine if this line is disabled:

https://github.com/zephyrproject-rtos/zephyr/blob/6700a154be3ca29be50fb4f1e35d899de69be5ca/include/zephyr/net/socket.h#L1416

Can't really understand the magic here, cc @jukkar @cfriedt @rlubos

cfriedt commented 2 days ago

@ycsin - can you make a PR?

I think there likely won't be a problem if that line is removed

0x6e commented 2 days ago

Removing the specified line allows my project to build.