Skip to content

CONFIG_PICOLIBC + sparse = zephyr/posix/sys/stat.h:40:11: error: unable to open 'sys/_timespec.h' #63003

@marc-hb

Description

@marc-hb

Describe the bug

CONFIG_PICOLIBC is currently incompatible with sparse due to some .h files complexities.

EDIT October 2nd with newer, simpler, SOF-free reproduction

# Compiles and provides all sparse warnings
west build -b intel_adsp_cavs25  samples/hello_world -p -- \
 -DCONFIG_MINIMAL_LIBC=y -DZEPHYR_SCA_VARIANT=sparse

# Does not compile and can't provide some sparse warnings
west build -b intel_adsp_cavs25  samples/hello_world -p -- \
 -DCONFIG_PICOLIBC=y -DZEPHYR_SCA_VARIANT=sparse 



Slower, -j1 version that does not bury the relevant error:

west build -b intel_adsp_cavs25  samples/hello_world -p -- \
 -DCONFIG_PICOLIBC=y  -DZEPHYR_SCA_VARIANT=sparse

ninja -j1 -C build

Building C object zephyr/lib/libc/picolibc/CMakeFiles/lib__libc__picolibc.dir/libc-hooks.c.obj
zephyr/lib/libc/picolibc/libc-hooks.c: note: in included file:
zephyr/include/zephyr/posix/sys/stat.h:40:11: error: unable to open 'sys/_timespec.h'

OLDER, initial and more complex reproduction that requires SOF. Kept here for completeness, you can probably skip it.

Commit f0daf90 switched CONFIG_PICOLIBC on by default. This broke the "sparse" analyzer used in the SOF project:

https://github.com/thesofproject/sof/actions/runs/6247162197/job/16959223474?pr=8235

/zep_workspace/zephyr/lib/os/printk.c:123:33: error: undefined identifier 'FDEV_SETUP_STREAM'
/zep_workspace/zephyr/lib/os/printk.c:144:32: error: undefined identifier 'FDEV_SETUP_STREAM'
/zep_workspace/zephyr/lib/os/printk.c:144:49: error: invalid initializer
/zep_workspace/zephyr/include/zephyr/posix/sys/stat.h:40:11: error: unable to open 'sys/_timespec.h'

Note this is not just a sparse warning or false positive: compilation with sparse actually FAILS, it cannot even complete.

To Reproduce

Detailed steps at


Expected behavior

Sparse can still sparse.

Impact

Broken SOF CI

Logs and console output

Environment (please complete the following information):

Github runner Ubuntu 22.04 LTS

Zephyr CI image with Zephyr SDK + marc-hb/sparse@3848a76ba49f336

zephyr commit 3415905 and SOF commit 75337b41eb51)

Additional context

These two workarounds were tested successfully:

  • git revert f0daf90

  • CONFIG_MINIMAL_LIBC=y as in ~/SOF/sof/scripts/xtensa-build-zephyr.py -p mtl --cmake-args=-DZEPHYR_SCA_VARIANT=sparse --cmake-args=-DCONFIG_LOG_USE_VLA=n --cmake-args=-DCONFIG_MINIMAL_LIBC=y

Metadata

Metadata

Assignees

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions