public inbox for openembedded-core@lists.openembedded.org
 help / color / mirror / Atom feed
* [langdale][master][PATCH] rust: Do not use default compiler flags defined in CC crate
@ 2022-11-18 14:42 Anton Antonov
  2022-11-18 15:10 ` [OE-core] " Richard Purdie
  2022-12-08 12:17 ` Richard Purdie
  0 siblings, 2 replies; 10+ messages in thread
From: Anton Antonov @ 2022-11-18 14:42 UTC (permalink / raw)
  To: openembedded-core; +Cc: Anton.Antonov

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
+}
-- 
2.25.1



^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2022-12-08 12:17 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox