<?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>15976</bug_id>
          
          <creation_ts>2025-09-18 05:55:09 +0000</creation_ts>
          <short_desc>Rust cc crate mixes host flags with target flags</short_desc>
          <delta_ts>2026-05-28 14:03:02 +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>NEW</bug_status>
          <resolution></resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>Medium</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>6.1 M2</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Gyorgy Sarvari">skandigraun</reporter>
          <assigned_to name="Deepesh Varatharajan">deepesh.varatharajan</assigned_to>
          <cc>ccasciato</cc>
    
    <cc>meta.mr.watcher</cc>
    
    <cc>meta.watcher</cc>
    
    <cc>randy.macleod</cc>
    
    <cc>ross.burton</cc>
    
    <cc>sundeep.kokkonda</cc>
          
          
          <cf_os>---</cf_os>
          <cf_regression_type>---</cf_regression_type>
          
          <cf_docchange>Don&apos;t know</cf_docchange>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>102791</commentid>
    <comment_count>0</comment_count>
    <who name="Gyorgy Sarvari">skandigraun</who>
    <bug_when>2025-09-18 05:55:09 +0000</bug_when>
    <thetext>A recent update in the cc crate has changed the way C/C++ compiler flags are gathered, it now reads more environment variables than it used to: https://github.com/rust-lang/cc-rs/pull/1401

This now sometimes leads to incorrect results. I have noticed this during a recent Firefox update, which also brought the update of the cc crate: in case the recipe is compiled for the target, but a crate has a build-only dependency on another crate, then the used compiler flags look wrong. Build-only dependencies are compiled for the build-host (which is correct), but the crate reads both the CFLAGS/CXXFLAGS and HOST_CFLAGS/HOST_CXXFLAGS variables (the latter ones are defined by cargo_common.bbclass).

However the former variables contain flags for the target, and the latter flags contain flags for the build host - and after mixing them, the result can be surprising.

Upstream has a bug tracking this also: https://github.com/rust-lang/cc-rs/issues/1469</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>102795</commentid>
    <comment_count>1</comment_count>
    <who name="Randy MacLeod">randy.macleod</who>
    <bug_when>2025-09-18 14:37:05 +0000</bug_when>
    <thetext>Certain environment variables are passed through to the bitbake system.
We need more info on what happened here and then to decide if we can prevent it.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>103745</commentid>
    <comment_count>2</comment_count>
    <who name="Randy MacLeod">randy.macleod</who>
    <bug_when>2026-01-07 19:37:43 +0000</bug_when>
    <thetext>Move to 6.0.

Gyorgy, do you happen to have a simple reproducer or
a suggestion about how we could produce one?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>103747</commentid>
    <comment_count>3</comment_count>
      <attachid>5168</attachid>
    <who name="Gyorgy Sarvari">skandigraun</who>
    <bug_when>2026-01-07 20:32:39 +0000</bug_when>
    <thetext>Created attachment 5168
cc-rs-test.tar.gz

The easiest reproduction is to have a Cargo.toml that marks a crate as a build-only dependency - that crate will be compiled with wrong flags (when cross-compiling).

This happens with Firefox and Rust also. (But I gotta admit, both are pretty big for testing this).

I have attached a simple repro. This is a hello world, with a build-dependency that uses cc-rs - the dependency itself is irrelevant.

To see the problem, before compiling set two environment variables:
export HOST_CFLAGS=THIS_SHOULD_NOT_APPEAR_ALONG_WITH_CFLAGS
export CFLAGS=THIS_SHOULD_NOT_APPEAR_WHEN_COMPILING_RING
CC_ENABLE_DEBUG_OUTPUT=1 cargo build -vv

Of course both variables are bogus, but they shouldn&apos;t be used together in the same compilation command - and the error you will get will show however that they are used in the same compilation command, when compiling ring crate for the host.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="0"
              isprivate="0"
          >
            <attachid>5168</attachid>
            <date>2026-01-07 20:32:39 +0000</date>
            <delta_ts>2026-01-07 20:34:55 +0000</delta_ts>
            <desc>cc-rs-test.tar.gz</desc>
            <filename>cc-rs-test.tar.gz</filename>
            <type>application/gzip</type>
            <size>452</size>
            <attacher name="Gyorgy Sarvari">skandigraun</attacher>
            
              <data encoding="base64">H4sIAAAAAAAAA+3WUWvbMBAAYD/rV1w9GCk0riRbMTT0Yeyl73sMYaiy6og6cpCUjTD23ydnaZq0
27KCk1J6HwFj+UAO5ztddqnU0Plh0D5cJsdBo1KI7spKQTdXtl7fSJhgvBQFFSzGMc5HIgFxpPfZ
s/RBOoCkXi2d+UfcoedvVLab/9ulaarM+Z736BI8Koq/5p/l+Tb/NOcx/3nJWQK05/f4o3ee/zsL
c2ns4Bx+EIiWXoMztr66qkwdv4nxerXRAb7CNfxee3g2+Phw/+XmExejC7hNZ7pp2vR8TH6S1/5r
6D/s1f9n6eo2C+286XWPQ/XP49mwrX+ax/ovOC2x/k9hspDqXtZ6Sqyc61ji6eP3kJJv2nnT2m6Z
ZiyjKdGVCZsVTnmREjJZnxrDSi+0rbRVRvsp+QBhZjzEnwQnbdXOYRuwuoDvM6NmXa/xoBQoJ4MG
GcOD3wkjXR/abF1mjKfYUfq3V//eqWPMgC+Z/1gx6s5/Kgqc/07hWf67aaDnEfBQ/6e7/V+s+39e
5Nj/T+Hp/LeITTc09myQ3nSTXGzVrWuqM5zoEEIIIYQQQgghhBBCCCGE3ohfWBYsnwAoAAA=
</data>

          </attachment>
      

    </bug>

</bugzilla>