diff mbox series

[langdale,master,v2] rust: Do not use default compiler flags defined in CC crate

Message ID 20221209095008.563491-1-Anton.Antonov@arm.com
State New
Headers show
Series [langdale,master,v2] rust: Do not use default compiler flags defined in CC crate | expand

Commit Message

Anton Antonov Dec. 9, 2022, 9:50 a.m. UTC
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 only the OE parameters 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 | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

Comments

Alexandre Belloni Dec. 18, 2022, 6:28 p.m. UTC | #1
Hello,

This caused errors on the autobuilders:
https://autobuilder.yoctoproject.org/typhoon/#/builders/37/builds/6367/steps/12/logs/stdio

On 09/12/2022 09:50:08+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 only the OE parameters 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 | 17 +++++++++++++++++
>  1 file changed, 17 insertions(+)
> 
> diff --git a/meta/classes-recipe/rust-target-config.bbclass b/meta/classes-recipe/rust-target-config.bbclass
> index 2710b4325d..0f72d685df 100644
> --- a/meta/classes-recipe/rust-target-config.bbclass
> +++ b/meta/classes-recipe/rust-target-config.bbclass
> @@ -401,3 +401,20 @@ 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
> +
> +# The CC crate checks for CRATE_CC_NO_DEFAULTS existence not value.
> +# Even empty CRATE_CC_NO_DEFAULTS will be taken into account.
> +# For rust native recipes we still rely on the CC crate parameters.
> +# Currently it's not possible to export a variable conditionally,
> +# so, let's export it for class-target and class-nativesdk only
> +
> +do_compile:prepend:class-target() {
> +    export CRATE_CC_NO_DEFAULTS=1
> +}
> +
> +do_compile:prepend:class-nativesdk() {
> +    export CRATE_CC_NO_DEFAULTS=1
> +}
> -- 
> 2.25.1
> 

> 
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#174440): https://lists.openembedded.org/g/openembedded-core/message/174440
> Mute This Topic: https://lists.openembedded.org/mt/95557415/3617179
> Group Owner: openembedded-core+owner@lists.openembedded.org
> Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [alexandre.belloni@bootlin.com]
> -=-=-=-=-=-=-=-=-=-=-=-
>
Anton Antonov Dec. 20, 2022, 11:24 a.m. UTC | #2
Hi Alexandre,

CRATE_CC_NO_DEFAULTS should not be set for native-sdk recipes. The issue is fixed in v3 of the patch.

Cheers,
Anton
diff mbox series

Patch

diff --git a/meta/classes-recipe/rust-target-config.bbclass b/meta/classes-recipe/rust-target-config.bbclass
index 2710b4325d..0f72d685df 100644
--- a/meta/classes-recipe/rust-target-config.bbclass
+++ b/meta/classes-recipe/rust-target-config.bbclass
@@ -401,3 +401,20 @@  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
+
+# The CC crate checks for CRATE_CC_NO_DEFAULTS existence not value.
+# Even empty CRATE_CC_NO_DEFAULTS will be taken into account.
+# For rust native recipes we still rely on the CC crate parameters.
+# Currently it's not possible to export a variable conditionally,
+# so, let's export it for class-target and class-nativesdk only
+
+do_compile:prepend:class-target() {
+    export CRATE_CC_NO_DEFAULTS=1
+}
+
+do_compile:prepend:class-nativesdk() {
+    export CRATE_CC_NO_DEFAULTS=1
+}