Bug 13731 - Cross canadian GCC fails to find header files when using tclibc-newlib
Summary: Cross canadian GCC fails to find header files when using tclibc-newlib
Status: RESOLVED FIXED
Alias: None
Product: OE-Core
Classification: Build System, Metadata & Runtime
Component: devtools / tool chain (show other bugs)
Version: unspecified
Hardware: All Multiple
: Medium+ normal
Target Milestone: 4.1 M2
Assignee: Alejandro
QA Contact:
URL:
Whiteboard:
Depends on:
Blocks:
 
Reported: 2020-01-10 00:15 UTC by Alejandro
Modified: 2022-09-22 16:28 UTC (History)
3 users (show)

See Also:
OS type for building Yocto: ---
Type of Regression: ---
Verified:
Documentation change: No (bug/feature does not impact docs)


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Alejandro 2020-01-10 00:15:16 UTC
When trying to build a "baremetal" application using an sdk produced by OE using TCLIBC=NEWLIB the cross canadian gcc fails to find the correct header files coming from the C library:


echo $CC
arm-oe-eabi-gcc -march=armv5te -marm --sysroot=/tmp/freertos-sdk/sysroots/armv5e-oe-eabi

$CC hello.c 
hello.c:1:10: fatal error: stdio.h: No such file or directory
    1 | #include <stdio.h>
      |          ^~~~~~~~~
compilation terminated.


There's an ambiguity here that I believe should be clarified:

While this is still called a "baremetal" application, using TCLIBC=baremetal should not require a C library to be present, hence there's no reason why it would look for stdio.h in the include directories, although, when TCLIBC=newlib is being used, a C library should be present and header files should be found automatically, so just to clarify, while these two examples qualify as baremetal applications, this bug only only affects when the application uses newlib as a C library.

This seems to be caused by the following commit:
https://git.yoctoproject.org/cgit/cgit.cgi/poky/commit/?h=master&id=ec8a40e231ce67bb5502b309afeac2a4fda34fd6

Specifically these two lines:
EXTRA_OECONF_remove_elf = "--with-sysroot=/not/exist"
EXTRA_OECONF_remove_eabi = "--with-sysroot=/not/exist"

Again, that seems like a proper solution for TCLIBC=baremetal, it just so happens that TARGET_OS is the same for both tclibc-baremetal AND tclibc-newlib.

The other two extra lines:
EXTRA_OECONF_append_elf = "--without-headers --with-newlib"
EXTRA_OECONF_append_eabi = "--without-headers --with-newlib"

Imply that a newlib be used, yes, but its the newlib that comes from GCC itself to be able to build gcc on the initial stages, not the one built and used from the build system.


This issue seems to have been caused for a fix to:
https://github.com/riscv/meta-riscv/issues/117

So, I believe we need to see what the right fix would be that would not interfere with TCLIBC=baremetal either.