From 755ee95a45a4a5e3f880b6143e755ec699194416 Mon Sep 17 00:00:00 2001 From: Anton Antonov Date: Tue, 3 Jan 2023 14:36:39 +0000 Subject: rust: Do not use default compiler flags defined in CC crate Rust crates build dependecy C libraries using "CC" crate. This crate adds some default compiler parameters depending on target arch. For some targets 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 (From OE-Core rev: 0c07089bdf7e0d7d8f37552db0bcd75f860979d9) Signed-off-by: Anton Antonov Signed-off-by: Alexandre Belloni Signed-off-by: Richard Purdie --- meta/classes-recipe/rust-target-config.bbclass | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'meta/classes-recipe/rust-target-config.bbclass') diff --git a/meta/classes-recipe/rust-target-config.bbclass b/meta/classes-recipe/rust-target-config.bbclass index 7fd7128bcf..939dd13d2f 100644 --- a/meta/classes-recipe/rust-target-config.bbclass +++ b/meta/classes-recipe/rust-target-config.bbclass @@ -404,3 +404,19 @@ 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 target C dependecies use only compiler parameters defined in OE +# and ignore the CC crate defaults which conflicts with OE ones in some cases. +# https://github.com/rust-lang/cc-rs#external-configuration-via-environment-variables +# Some CC crate compiler flags are still required. +# We apply them conditionally in rust wrappers. + +CRATE_CC_FLAGS:class-native = "" +CRATE_CC_FLAGS:class-nativesdk = "" +CRATE_CC_FLAGS:class-target = " -ffunction-sections -fdata-sections -fPIC" + +do_compile:prepend:class-target() { + export CRATE_CC_NO_DEFAULTS=1 +} +do_install:prepend:class-target() { + export CRATE_CC_NO_DEFAULTS=1 +} -- cgit v1.2.3-54-g00ecf