From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0294BECAAA1 for ; Mon, 24 Oct 2022 17:10:21 +0000 (UTC) Subject: rust: conflicts between Yocto and CC-RS compiler parameters To: openembedded-core@lists.openembedded.org From: "Anton Antonov" X-Originating-Location: Cambridge, England, GB (217.140.106.13) X-Originating-Platform: Mac Firefox 105 User-Agent: GROUPS.IO Web Poster MIME-Version: 1.0 Date: Mon, 24 Oct 2022 10:10:19 -0700 Message-ID: Content-Type: multipart/alternative; boundary="pM3jSviEISvmkeHNhAzH" List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Mon, 24 Oct 2022 17:10:21 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/172113 --pM3jSviEISvmkeHNhAzH Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Hi all, After this change (using RUST_HOST_SYS instead of HOST_SYS): https://github= .com/yoctoproject/poky/commit/5c45b73c8fa445b5192bb9fac1bc80b038b44c0d buil= ds of parsec-service recipe for qemuarm machine started to fail: cc1: error: switch '-mcpu=3Dcortex-a15' conflicts with switch '-march=3Darm= v7-a+fp' [-Werror] Full log can be seen here: https://gitlab.com/akuster/meta-security/-/jobs/3204450989#L2086 This is the cargo build command before the change: cargo build -v --target arm-poky-linux-gnueabi =20 and this is after: cargo build -v --target armv7-poky-linux-gnueabihf The problem is that some Rust crates build dependency C libraries using "cc= -rs" crate. This crate adds some compiler parameters depending on target =E2=80=9Carch= =E2=80=9D and for =E2=80=9Carmv7" these parameters conflicts with compiler = parameter defined by Yocto via TUNE_CCARGS: https://github.com/rust-lang/cc-rs/blob/53fb72c87e5769a299f1886ead831901b9c= 775d6/src/lib.rs#L1700 We noticed it with qemuarm, but there might be other= conflicts as well. (If -Werror is used then builds would fail, otherwise i= t would be just a warning which is easy to miss) To fix the issue in our recipe we can define =E2=80=9CCRATE_CC_NO_DEFAULTS= =E2=80=9D env variable which disables adding compiler flags in "cc-rs": https://github.com/rust-lang/cc-rs#external-configuration-via-environment-v= ariables So, my questions is: shouldn=E2=80=99t =E2=80=9CCRATE_CC_NO_DEFAULTS=E2=80= =9D be defined in the Rust bbclass instead of expecting that owners of all = Rust apps recipes would be aware about this issue for some machines and wou= ld add workarounds in their recipes? I've tried to add "CRATE_CC_NO_DEFAULTS" into rust-target-config.bbclass , = but it breaks building rust-native. Looks like we don=E2=80=99t define all = the required parameters for native builds and rely (maybe not even intentio= nally) on parameters defined by cc-rs crate. Therefore to do it properly th= ere should be some logic around defining of "CRATE_CC_NO_DEFAULTS" in rust-= target-config.bbclass. I would be happy to hear ideas or recommendations. Cheers, Anton --pM3jSviEISvmkeHNhAzH Content-Type: text/html; charset="utf-8" Content-Transfer-Encoding: quoted-printable
Hi all,
 
 After this change (using RUST_HOST_SYS instead of HOST_SYS): https://github.com/yoctoproject/poky/commit/5c45b73c8fa445b5192bb= 9fac1bc80b038b44c0d  builds of parsec-service recipe for qemuarm m= achine started to fail:
cc1: error: switch '-=
mcpu=3Dcortex-a15' conflicts with switch '-march=3Darmv7-a+fp' [-Werror]
Full log can be seen here:
https://gitlab.com/akuster/meta-security/-/jobs/3204450989#L2086

  This is the cargo bu= ild command before the change:
cargo build -v --targ=
et arm-poky-linux-gnueabi  
  and this is after:
cargo build -v --targ=
et armv7-poky-linux-gnueabihf
  
  The problem is that some Rust crates build dependency C librar= ies using "cc-rs" crate.
This crate adds some compiler parameters depe= nding on target “arch” and for “armv7" these parameters c= onflicts with compiler parameter defined by Yocto via TUNE_CCARGS:
https://github.com/rust-lang/cc-rs/blob/53fb72c87e5769a299= f1886ead831901b9c775d6/src/lib.rs#L1700We noticed it with qemuarm, bu= t there might be other conflicts as well. (If -Werror is used then buil= ds would fail, otherwise it would be just a warning which is easy to miss)<= br />=

  To fix the issue in our recipe we can define &ldquo= ;CRATE_CC_NO_DEFAULTS” env variable which disables adding compiler fl= ags in "cc-rs": 
ht= tps://github.com/rust-lang/cc-rs#external-configuration-via-environment-var= iables
  So, my questions is: shouldn’t “CRATE= _CC_NO_DEFAULTS” be defined in the Rust bbclass instead of expecting = that owners of all Rust apps recipes would be aware about this issue for so= me machines and would add workarounds in their recipes?
   I've tried to add "CRATE_CC_NO_DEFAULTS" into rust-target-config.bbclass, but it breaks building rust= -native. Looks like we don’t define all the required parameters for n= ative builds and rely (maybe not even intentionally) on parameters defined = by cc-rs crate. Therefore to do it properly there should be some logic arou= nd defining of "CRATE_CC_NO_DEFAULTS" in rust-target-config.bbclass. I would be= happy to hear ideas or recommendations.
 
Cheers,
Anton
--pM3jSviEISvmkeHNhAzH--