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 <[email protected]>
> ---
>  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

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#174402): 
https://lists.openembedded.org/g/openembedded-core/message/174402
Mute This Topic: https://lists.openembedded.org/mt/95113030/21656
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub 
[[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to