public inbox for openembedded-core@lists.openembedded.org
 help / color / mirror / Atom feed
From: Richard Purdie <richard.purdie@linuxfoundation.org>
To: Anton Antonov <anton.antonov@arm.com>,
	 openembedded-core@lists.openembedded.org
Subject: Re: [OE-core] [langdale][master][PATCH] rust: Do not use default compiler flags defined in CC crate
Date: Thu, 08 Dec 2022 12:17:38 +0000	[thread overview]
Message-ID: <cd5af976d2f6c820f8aced11c07155c71ff16125.camel@linuxfoundation.org> (raw)
In-Reply-To: <20221118144253.1156045-1-Anton.Antonov@arm.com>

On Fri, 2022-11-18 at 14:42 +0000, Anton Antonov wrote:
> Rust crates build dependecy C libraries using "CC" crate.
> This crate adds some default compiler parameters depending on target arch.
> For some target archs these parameters conflict with the parameters defined by OE.
> 
> Warnings/errors like this can be seen in the case:
> 
> cc1: error: switch '-mcpu=cortex-a15' conflicts with switch '-march=armv7-a+fp' [-Werror]
> 
> Lets use the OE parameters only by exporting CRATE_CC_NO_DEFAULTS.
> https://github.com/rust-lang/cc-rs#external-configuration-via-environment-variables
> 
> This patch fixes https://bugzilla.yoctoproject.org/show_bug.cgi?id=14947
> 
> Signed-off-by: Anton Antonov <Anton.Antonov@arm.com>
> ---
>  meta/classes-recipe/rust-target-config.bbclass | 18 ++++++++++++++++++
>  1 file changed, 18 insertions(+)
> 
> diff --git a/meta/classes-recipe/rust-target-config.bbclass b/meta/classes-recipe/rust-target-config.bbclass
> index 2710b4325d..4135335043 100644
> --- a/meta/classes-recipe/rust-target-config.bbclass
> +++ b/meta/classes-recipe/rust-target-config.bbclass
> @@ -401,3 +401,21 @@ python do_rust_gen_targets () {
>  addtask rust_gen_targets after do_patch before do_compile
>  do_rust_gen_targets[dirs] += "${RUST_TARGETS_DIR}"
>  
> +# For building C dependecies only use compiler parameters defined in OE-core
> +# and ignore the default parameters defined in the CC crate.
> +# https://github.com/rust-lang/cc-rs#external-configuration-via-environment-variables
> +# For rust native recipes we still rely on the CC crate parameters.
> +
> +CRATE_CC_NO_DEFAULTS:class-target ?= "true"
> +CRATE_CC_NO_DEFAULTS:class-nativesdk ?= "true"
> +CRATE_CC_NO_DEFAULTS:class-native ?= ""
> +
> +# The CC crate checks for CRATE_CC_NO_DEFAULTS existence not value.
> +# Even empty CRATE_CC_NO_DEFAULTS will be taken into account.
> +# So, don't export it if empty.
> +do_compile:prepend() {
> +    if [ -n "${CRATE_CC_NO_DEFAULTS}" ]; then
> +        export CRATE_CC_NO_DEFAULTS="${CRATE_CC_NO_DEFAULTS}"
> +        bbnote "CRATE_CC_NO_DEFAULTS is exported"
> +    fi
> +}

Sorry about the delays on this. I did want to try and sort the
underlying export issue and whilst I proposed a patch, the performance
impact of it is a concern so it isn't moving forward right now.

I suspect that means we should merge a different fix for now. The above
is still a little more complex and harder to read than it could be.
Could you try a version which does something like:


do_compile:prepend:class-target() {
    export CRATE_CC_NO_DEFAULTS=1
}

do_compile:prepend:class-nativesdk() {
    export CRATE_CC_NO_DEFAULTS=1
}

which should be a bit clearer/simpler?

Cheers,

Richard



      parent reply	other threads:[~2022-12-08 12:17 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-18 14:42 [langdale][master][PATCH] rust: Do not use default compiler flags defined in CC crate Anton Antonov
2022-11-18 15:10 ` [OE-core] " Richard Purdie
2022-11-18 15:27   ` Anton Antonov
2022-11-18 16:21   ` [OE-core] " Anton Antonov
2022-11-18 16:35     ` Richard Purdie
2022-11-18 17:15       ` Anton Antonov
2022-11-19  1:57       ` Peter Kjellerstedt
2022-11-20 11:45         ` Richard Purdie
2022-11-21  9:39           ` Anton Antonov
2022-12-08 12:17 ` Richard Purdie [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=cd5af976d2f6c820f8aced11c07155c71ff16125.camel@linuxfoundation.org \
    --to=richard.purdie@linuxfoundation.org \
    --cc=anton.antonov@arm.com \
    --cc=openembedded-core@lists.openembedded.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox