<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugzilla.yoctoproject.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.6"
          urlbase="https://bugzilla.yoctoproject.org/"
          
          maintainer="it-coreprojects-helpdesk@linuxfoundation.org"
>

    <bug>
          <bug_id>13731</bug_id>
          
          <creation_ts>2020-01-10 00:15:16 +0000</creation_ts>
          <short_desc>Cross canadian GCC fails to find header files when using tclibc-newlib</short_desc>
          <delta_ts>2022-09-22 16:28:33 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>7</classification_id>
          <classification>Build System, Metadata &amp; Runtime</classification>
          <product>OE-Core</product>
          <component>devtools / tool chain</component>
          <version>unspecified</version>
          <rep_platform>All</rep_platform>
          <op_sys>Multiple</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>Medium+</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>4.1 M2</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Alejandro">alejandro</reporter>
          <assigned_to name="Alejandro">alejandro</assigned_to>
          <cc>meta.mr.watcher</cc>
    
    <cc>meta.watcher</cc>
    
    <cc>randy.macleod</cc>
          
          
          <cf_os>---</cf_os>
          <cf_regression_type>---</cf_regression_type>
          
          <cf_docchange>No (bug/feature does not impact docs)</cf_docchange>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>86016</commentid>
    <comment_count>0</comment_count>
    <who name="Alejandro">alejandro</who>
    <bug_when>2020-01-10 00:15:16 +0000</bug_when>
    <thetext>When trying to build a &quot;baremetal&quot; 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 &lt;stdio.h&gt;
      |          ^~~~~~~~~
compilation terminated.


There&apos;s an ambiguity here that I believe should be clarified:

While this is still called a &quot;baremetal&quot; application, using TCLIBC=baremetal should not require a C library to be present, hence there&apos;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&amp;id=ec8a40e231ce67bb5502b309afeac2a4fda34fd6

Specifically these two lines:
EXTRA_OECONF_remove_elf = &quot;--with-sysroot=/not/exist&quot;
EXTRA_OECONF_remove_eabi = &quot;--with-sysroot=/not/exist&quot;

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 = &quot;--without-headers --with-newlib&quot;
EXTRA_OECONF_append_eabi = &quot;--without-headers --with-newlib&quot;

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.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>94062</commentid>
    <comment_count>1</comment_count>
    <who name="Alejandro">alejandro</who>
    <bug_when>2022-09-22 16:28:33 +0000</bug_when>
    <thetext>Fixed here:

https://git.yoctoproject.org/poky/commit/?h=master&amp;id=d4b186c2cfe62ba92850093fb165000c9f933202</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>