-
Notifications
You must be signed in to change notification settings - Fork 8.2k
libc: Cleanup/fix setting of system include paths #14312
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
Conversation
|
@SteveOss this should hopefully fix your issue. |
Codecov Report
@@ Coverage Diff @@
## master #14312 +/- ##
=========================================
Coverage ? 52%
=========================================
Files ? 308
Lines ? 45554
Branches ? 10545
=========================================
Hits ? 23691
Misses ? 17063
Partials ? 4800Continue to review full report at Codecov.
|
|
There is something wrong with this sentence:
|
|
LGTM, however this should be done for clang too |
When we build with newlib we don't set -nostdinc. In that case make sure that we leave it to the toolchain to set the system include paths. The one exception to leaving to the toolchain to set the system include paths is the path to the newlib headers. Since we build with -ffreestanding we need to make sure the newlib header path is the before the toolchain headers. Otherwise the toolchain's 'freestanding' headers get picked up and that causes issues (for example getting PRI*64 defined properly from inttypes.h due to __STDC_HOSTED__ being '0'). For newlib we accomplish this by having the only system header specified by zephyr_system_include_directories() being just the newlib headers. Note: for minlibc we leave things alone as things just happen to work as the -I include of the libc headers takes precedence over -isystem so we get the libc headers over the toolchain ones. For the newlib case it appears that setting both -I and -isystem for the same dir causes the -I to be ignored. Fixes zephyrproject-rtos#14310 Signed-off-by: Kumar Gala <[email protected]>
|
Can confirm fixes my original issue. |
The solution from zephyrproject-rtos#14312 of using -isystem to prioritize the position of the libc directory bypasses the effect of -ffreestanding with respect to libc symbols expected to be present in a non-hosted environment. Further, it breaks C++ with the ARM Embedded toolchain as the system fails to find the right file with #include_next. Use a more fine-grained solution that explicitly includes the underlying newlib header required for <inttypes.h> support before moving on to include the next available one, whether system or non-system. Closes zephyrproject-rtos#17564 Signed-off-by: Peter Bigot <[email protected]>
The solution from #14312 of using -isystem to prioritize the position of the libc directory bypasses the effect of -ffreestanding with respect to libc symbols expected to be present in a non-hosted environment. Further, it breaks C++ with the ARM Embedded toolchain as the system fails to find the right file with #include_next. Use a more fine-grained solution that explicitly includes the underlying newlib header required for <inttypes.h> support before moving on to include the next available one, whether system or non-system. Closes #17564 Signed-off-by: Peter Bigot <[email protected]>
The solution from zephyrproject-rtos#14312 of using -isystem to prioritize the position of the libc directory bypasses the effect of -ffreestanding with respect to libc symbols expected to be present in a non-hosted environment. Further, it breaks C++ with the ARM Embedded toolchain as the system fails to find the right file with #include_next. Use a more fine-grained solution that explicitly includes the underlying newlib header required for <inttypes.h> support before moving on to include the next available one, whether system or non-system. Closes zephyrproject-rtos#17564 Backport: 96c1b05 Signed-off-by: Peter Bigot <[email protected]>
The solution from zephyrproject-rtos#14312 of using -isystem to prioritize the position of the libc directory bypasses the effect of -ffreestanding with respect to libc symbols expected to be present in a non-hosted environment. Further, it breaks C++ with the ARM Embedded toolchain as the system fails to find the right file with #include_next. Use a more fine-grained solution that explicitly includes the underlying newlib header required for <inttypes.h> support before moving on to include the next available one, whether system or non-system. Closes zephyrproject-rtos#17564 Signed-off-by: Peter Bigot <[email protected]>
The solution from #14312 of using -isystem to prioritize the position of the libc directory bypasses the effect of -ffreestanding with respect to libc symbols expected to be present in a non-hosted environment. Further, it breaks C++ with the ARM Embedded toolchain as the system fails to find the right file with #include_next. Use a more fine-grained solution that explicitly includes the underlying newlib header required for <inttypes.h> support before moving on to include the next available one, whether system or non-system. Closes #17564 Backport: 96c1b05 Signed-off-by: Peter Bigot <[email protected]>
We use to build with -nostdinc and thus we explicitly set the system
include paths. Instead we should let the compiler do that and remove
doing it outselves.
Since we build with -ffreestanding we do need to explicitly set the a
system include path for the libc headers. Thus we change the libc
cases from zephyr_include_directories to
zephyr_system_include_directories. We need to ensure that the libc
headers are picked up instead of the 'freestanding' toolchain headers.
Note for whatever reason the SDK 0.9.5 version of the tools was treating
-I and -isystem similarly and thus would find the libc headers first
before the 'freestanding' headers from the toolchain.
Fixes #14310
Signed-off-by: Kumar Gala [email protected]