-
Notifications
You must be signed in to change notification settings - Fork 6.9k
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
Incompatible (u)intptr_t type and PRIxPTR definitions #37718
Comments
TODO: Further investigate all the affected platforms/toolchains and make a list of them. p.s. This should really be fixed before we release LTS. |
LLVM is wrong. On a 64-bits platform, a pointer is wider than an unsigned int. In lib/libc/minimal/include/inttypes.h we have:
What lib are you using? |
@npitre Building For
In case of |
This might give better a overview of the issue seen on p.s. It looks like, in case of |
A while ago, we had many problems like that. Commit f32330b fixed So int32_t is always an int, intptr_t is always a long, and PRIuPTR is Now the native_posix target is a special cases as it runs inside another |
The scope of this issue might be limited to the POSIX arch boards, but I somehow doubt that because we have other third-party toolchains like Arm Compiler and ARC MWDT with their own headers (by the way, cc @tejlmand @abrodkin @evgeniy-paltsev). I don't have time to do an in-depth analysis on this at the moment. I will revisit this later and do full analysis. |
There is also problem of definitions like |
I definitely second the sentiment that native_posix breaks a lot the fun. I had a lot of issues with it while working on POSIX subsys: #13054 . And I also eyeballed "radical" solutions like saying that POSIX subsys simply isn't supported on (Just thinking aloud really, my 2 cents.) |
I think it really depends on how important the native_posix target is,
and how much it is worth affecting all other targets to accommodate it.
Having a coherent set of definitions for all (real) target is a big
plus.
And this particular issue is valid only for native_posix (the 32-bit
one). There are no such conflicts with native_posix_64.
|
TODO: Check how sane the type system is in armclang with both STDLIB and MICROLIB (cc @tejlmand). |
For 2.7, we will leave the Arm Compiler and ARC MWDT out of question since they are very much experimental right now. The scope of fix for 2.7 will be limited to the In the future, we could look into reverting #16645:
|
This commit updates the Zephyr build system such that it does not include the `zephyr_stdint.h`, which tries to define Zephyr's own type system, when compiling for the native POSIX architecture. The native POSIX architecture compiles with the host toolchain and headers, and there can be conflicts if we arbitrarily define our own type system (e.g. mismatch between the types and the specifiers defined in `inttypes.h`). Note that this is not meant to be a permanent fix; instead, it is meant to serve as a temporary workaround until we no longer need to define our own type system. For more details, refer to the issue zephyrproject-rtos#37718. Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
This commit updates the Zephyr build system such that it does not include the `zephyr_stdint.h`, which tries to define Zephyr's own type system, when compiling for the native POSIX architecture. The native POSIX architecture compiles with the host toolchain and headers, and there can be conflicts if we arbitrarily define our own type system (e.g. mismatch between the types and the specifiers defined in `inttypes.h`). Note that this is not meant to be a permanent fix; instead, it is meant to serve as a temporary workaround until we no longer need to define our own type system. For more details, refer to the issue #37718. Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
With "Incompatible (u)intptr_t type and PRIxPTR definitions", zephyrproject-rtos#37718, issue resolved the FIXME code is no longer needed. Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
With "Incompatible (u)intptr_t type and PRIxPTR definitions", #37718, issue resolved the FIXME code is no longer needed. Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
This commit updates the Zephyr build system such that it does not include the `zephyr_stdint.h`, which tries to define Zephyr's own type system, when compiling for the native POSIX architecture. The native POSIX architecture compiles with the host toolchain and headers, and there can be conflicts if we arbitrarily define our own type system (e.g. mismatch between the types and the specifiers defined in `inttypes.h`). Note that this is not meant to be a permanent fix; instead, it is meant to serve as a temporary workaround until we no longer need to define our own type system. For more details, refer to the issue zephyrproject-rtos#37718. Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
With "Incompatible (u)intptr_t type and PRIxPTR definitions", zephyrproject-rtos#37718, issue resolved the FIXME code is no longer needed. Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
Describe the bug
For some platforms, the
intptr_t
anduintptr_t
types do not match thePRIxPTR
types.To Reproduce
On an x86-64 host, build the following code for
native_posix
board using LLVM (ZEPHYR_TOOLCHAIN_VARIANT=llvm
).See the following error:
Expected behavior
The types of
intptr_t
anduintptr_t
and thePRIxPTR
match.For instance:
intptr_t
isint
,PRIdPTR
should be%d
.intptr_t
islong
,PRIdPTR
should be%ld
.Impact
Makes
PRIxPTR
useless on the affected platforms (in particular,native_posix
on x86-64 with Clang/LLVM).Environment (please complete the following information):
Additional context
This happens because
zephyr_stdint.h
re-defines__INTPTR_TYPE__
and__UINTPTR_TYPE__
aslong int
andlong unsigned int
, respectively, while thePRIxPTR
definitions stay%x
with no size prefix.zephyr/include/toolchain/zephyr_stdint.h
Lines 47 to 50 in feb0e9f
See #37712 (comment).
See also #16645.
The text was updated successfully, but these errors were encountered: