Skip to content

zephyr: sync stdint guard define and FLOAT16 dependency - #329

Open
XenuIsWatching wants to merge 1 commit into
ARM-software:mainfrom
XenuIsWatching:zephyr-4.5
Open

zephyr: sync stdint guard define and FLOAT16 dependency#329
XenuIsWatching wants to merge 1 commit into
ARM-software:mainfrom
XenuIsWatching:zephyr-4.5

Conversation

@XenuIsWatching

Copy link
Copy Markdown
Contributor

The Zephyr integration files in this module were forked from the zephyr tree in d8bad7d ("Reworked zephyr module"). Two later zephyr-side changes updated the in-tree copies but could not reach the copies here, so both are stale and break the build once zephyr drops its own copies in favour of these.

zephyr renamed the include guard of
include/zephyr/toolchain/zephyr_stdint.h from
ZEPHYR_INCLUDE_TOOLCHAIN_STDINT_H_ to
ZEPHYR_INCLUDE_TOOLCHAIN_ZEPHYR_STDINT_H_ (zephyr commit b04eb25b786), updating its in-tree modules/cmsis-dsp/CMakeLists.txt at the same time. The define here no longer suppresses that header, so the -imacros force-include redefines INT32_TYPE from the toolchain's native 'long int' to 'int'. GCC resolves its polymorphic MVE intrinsics through _Generic associations keyed on the native int32_t, so 'const q31_t *' matches no association and Helium targets fail with:

error: passing 'const q31_t *' {aka 'const int *'} to argument 1 of
'vld1q', but 'q31_t' {aka 'int'} is not a valid MVE element type

zephyr then introduced CONFIG_FP16_ARITHMETIC (zephyr commit 659069617b2) to distinguish half-precision storage from half-precision arithmetic, and narrowed CMSIS_DSP_FLOAT16 to depend on it. FP16 alone is set on cores with storage-only fp16 such as Cortex-R52, where building the F16 sources lets -Ofast vectorize a _Float16 compare into a vector form the backend cannot emit, causing an internal compiler error in arm_clip_f16.c.

The Zephyr integration files in this module were forked from the zephyr
tree in d8bad7d ("Reworked zephyr module"). Three details drifted from
what zephyr itself carries, each of which breaks the build once zephyr
drops its own copies in favour of these.

The optimization flag was written out as a literal -Ofast, where zephyr
used $<TARGET_PROPERTY:compiler,optimization_fast>. zephyr defines that
property per toolchain, as -Ofast for gcc but -O3 -ffast-math for clang,
precisely because clang deprecated -Ofast. Since zephyr builds with
-Werror, hardcoding the flag fails every clang build, for example
native_sim with the host/llvm toolchain:

  clang: error: argument '-Ofast' is deprecated; use '-O3 -ffast-math'
  for the same behavior, or '-O3' to enable only conforming
  optimizations [-Werror,-Wdeprecated-ofast]

zephyr later renamed the include guard of
include/zephyr/toolchain/zephyr_stdint.h from
ZEPHYR_INCLUDE_TOOLCHAIN_STDINT_H_ to
ZEPHYR_INCLUDE_TOOLCHAIN_ZEPHYR_STDINT_H_ (zephyr commit b04eb25b786),
updating its in-tree modules/cmsis-dsp/CMakeLists.txt at the same time.
The define here no longer suppresses that header, so the -imacros
force-include redefines __INT32_TYPE__ from the toolchain's native
'long int' to 'int'. GCC resolves its polymorphic MVE intrinsics through
_Generic associations keyed on the native int32_t, so 'const q31_t *'
matches no association and Helium targets fail with:

  error: passing 'const q31_t *' {aka 'const int *'} to argument 1 of
  'vld1q', but 'q31_t' {aka 'int'} is not a valid MVE element type

zephyr also introduced CONFIG_FP16_ARITHMETIC (zephyr commit
659069617b2) to distinguish half-precision storage from half-precision
arithmetic, and narrowed CMSIS_DSP_FLOAT16 to depend on it. FP16 alone
is set on cores with storage-only fp16 such as Cortex-R52, where
building the F16 sources lets -Ofast vectorize a _Float16 compare into a
vector form the backend cannot emit, causing an internal compiler error
in arm_clip_f16.c.

Signed-off-by: Ryan McClelland <ryanmcclelland@meta.com>
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

Successfully merging this pull request may close these issues.

1 participant