* [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
* Re: [OE-core] [langdale][master][PATCH] rust: Do not use default compiler flags defined in CC crate 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 ` Richard Purdie 2022-11-18 15:27 ` Anton Antonov 2022-11-18 16:21 ` [OE-core] " Anton Antonov 2022-12-08 12:17 ` Richard Purdie 1 sibling, 2 replies; 10+ messages in thread From: Richard Purdie @ 2022-11-18 15:10 UTC (permalink / raw) To: Anton Antonov, openembedded-core 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 > +} That looks like a good start. I wondered if this might work as a slightly cleaner solution?: CRATE_CC_NO_DEFAULTS = "true" CRATE_CC_NO_DEFAULTS:class-native = "" CRATE_CC_NO_DEFAULTS[export] = "${'1' if d.getVar('CRATE_CC_NO_DEFAULTS') == 'true' else '0'}" Cheers, Richard ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [langdale][master][PATCH] rust: Do not use default compiler flags defined in CC crate 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 1 sibling, 0 replies; 10+ messages in thread From: Anton Antonov @ 2022-11-18 15:27 UTC (permalink / raw) To: openembedded-core [-- Attachment #1: Type: text/plain, Size: 173 bytes --] Hi Richard, Thank you for the suggestion. I was wondering how I can conditionally export a variable without updating a task. I will test and submit a new patch Anton [-- Attachment #2: Type: text/html, Size: 202 bytes --] ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [OE-core] [langdale][master][PATCH] rust: Do not use default compiler flags defined in CC crate 2022-11-18 15:10 ` [OE-core] " Richard Purdie 2022-11-18 15:27 ` Anton Antonov @ 2022-11-18 16:21 ` Anton Antonov 2022-11-18 16:35 ` Richard Purdie 1 sibling, 1 reply; 10+ messages in thread From: Anton Antonov @ 2022-11-18 16:21 UTC (permalink / raw) To: Richard Purdie, openembedded-core@lists.openembedded.org [-- Attachment #1: Type: text/plain, Size: 3388 bytes --] Hi Richard, I’ve tested your approach. It doesn’t work for whatever reason. CRATE_CC_NO_DEFAULTS is empty exported for native recipes: $ MACHINE=qemuarm bitbake rust-native -e |grep CRATE_CC_NO_DEFAULTS # $CRATE_CC_NO_DEFAULTS [3 operations] # [export] "${'1' if d.getVar('CRATE_CC_NO_DEFAULTS') == 'true' else '0'}" export CRATE_CC_NO_DEFAULTS="" # $CRATE_CC_NO_DEFAULTS:class-native CRATE_CC_NO_DEFAULTS:class-native="" I also tried: CRATE_CC_NO_DEFAULTS[export] = "${@oe.utils.conditional('CRATE_CC_NO_DEFAULTS', '', '0', '1', d)}" with the same result – empty export. Cheers, Anton From: Richard Purdie <richard.purdie@linuxfoundation.org> Date: Friday, 18 November 2022 at 15:10 To: Anton Antonov <Anton.Antonov@arm.com>, openembedded-core@lists.openembedded.org <openembedded-core@lists.openembedded.org> Subject: Re: [OE-core] [langdale][master][PATCH] rust: Do not use default compiler flags defined in CC crate 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 > +} That looks like a good start. I wondered if this might work as a slightly cleaner solution?: CRATE_CC_NO_DEFAULTS = "true" CRATE_CC_NO_DEFAULTS:class-native = "" CRATE_CC_NO_DEFAULTS[export] = "${'1' if d.getVar('CRATE_CC_NO_DEFAULTS') == 'true' else '0'}" Cheers, Richard [-- Attachment #2: Type: text/html, Size: 6839 bytes --] ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [OE-core] [langdale][master][PATCH] rust: Do not use default compiler flags defined in CC crate 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 0 siblings, 2 replies; 10+ messages in thread From: Richard Purdie @ 2022-11-18 16:35 UTC (permalink / raw) To: Anton Antonov, openembedded-core@lists.openembedded.org On Fri, 2022-11-18 at 16:21 +0000, Anton Antonov wrote: > I’ve tested your approach. It doesn’t work for whatever reason. > CRATE_CC_NO_DEFAULTS is empty exported for native recipes: > > $ MACHINE=qemuarm bitbake rust-native -e |grep CRATE_CC_NO_DEFAULTS > # $CRATE_CC_NO_DEFAULTS [3 operations] > # [export] "${'1' if d.getVar('CRATE_CC_NO_DEFAULTS') == 'true' > else '0'}" > export CRATE_CC_NO_DEFAULTS="" > # $CRATE_CC_NO_DEFAULTS:class-native > CRATE_CC_NO_DEFAULTS:class-native="" > > > I also tried: > CRATE_CC_NO_DEFAULTS[export] = > "${@oe.utils.conditional('CRATE_CC_NO_DEFAULTS', '', '0', '1', d)}" > with the same result – empty export. I think it might need to be 0 or "" instead of '0'. It would be nice if we could make False work too but I worry that might not. Cheers, Richard ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [OE-core] [langdale][master][PATCH] rust: Do not use default compiler flags defined in CC crate 2022-11-18 16:35 ` Richard Purdie @ 2022-11-18 17:15 ` Anton Antonov 2022-11-19 1:57 ` Peter Kjellerstedt 1 sibling, 0 replies; 10+ messages in thread From: Anton Antonov @ 2022-11-18 17:15 UTC (permalink / raw) To: Richard Purdie, openembedded-core@lists.openembedded.org [-- Attachment #1: Type: text/plain, Size: 2311 bytes --] Hi Richard, I’ve already unsuccessfully tried all these combinations with both “if” and oe.utils.conditional. $ MACHINE=qemuarm bitbake rust-native -e |grep CRATE_CC_NO_DEFAULTS # $CRATE_CC_NO_DEFAULTS [3 operations] # [export] "${@1 if d.getVar('CRATE_CC_NO_DEFAULTS') == 'true' else 0}" export CRATE_CC_NO_DEFAULTS="" # $CRATE_CC_NO_DEFAULTS:class-native CRATE_CC_NO_DEFAULTS:class-native="" $ MACHINE=qemuarm bitbake rust-native -e |grep CRATE_CC_NO_DEFAULTS # $CRATE_CC_NO_DEFAULTS [3 operations] # [export] "${@'1' if d.getVar('CRATE_CC_NO_DEFAULTS') == 'true' else ''}" export CRATE_CC_NO_DEFAULTS="" # $CRATE_CC_NO_DEFAULTS:class-native CRATE_CC_NO_DEFAULTS:class-native="" Looking at this “0” should work https://git.yoctoproject.org/poky/tree/meta/classes-recipe/go.bbclass#n30 But, even if I add CRATE_CC_NO_DEFAULTS[export] = "0" for testing, I still see: $ MACHINE=qemuarm bitbake rust-native -e |grep CRATE_CC_NO_DEFAULTS # $CRATE_CC_NO_DEFAULTS [3 operations] export CRATE_CC_NO_DEFAULTS="" # $CRATE_CC_NO_DEFAULTS:class-native CRATE_CC_NO_DEFAULTS:class-native="" Cheers, Anton From: Richard Purdie <richard.purdie@linuxfoundation.org> Date: Friday, 18 November 2022 at 16:35 To: Anton Antonov <Anton.Antonov@arm.com>, openembedded-core@lists.openembedded.org <openembedded-core@lists.openembedded.org> Subject: Re: [OE-core] [langdale][master][PATCH] rust: Do not use default compiler flags defined in CC crate On Fri, 2022-11-18 at 16:21 +0000, Anton Antonov wrote: > I’ve tested your approach. It doesn’t work for whatever reason. > CRATE_CC_NO_DEFAULTS is empty exported for native recipes: > > $ MACHINE=qemuarm bitbake rust-native -e |grep CRATE_CC_NO_DEFAULTS > # $CRATE_CC_NO_DEFAULTS [3 operations] > # [export] "${'1' if d.getVar('CRATE_CC_NO_DEFAULTS') == 'true' > else '0'}" > export CRATE_CC_NO_DEFAULTS="" > # $CRATE_CC_NO_DEFAULTS:class-native > CRATE_CC_NO_DEFAULTS:class-native="" > > > I also tried: > CRATE_CC_NO_DEFAULTS[export] = > "${@oe.utils.conditional('CRATE_CC_NO_DEFAULTS', '', '0', '1', d)}" > with the same result – empty export. I think it might need to be 0 or "" instead of '0'. It would be nice if we could make False work too but I worry that might not. Cheers, Richard [-- Attachment #2: Type: text/html, Size: 6786 bytes --] ^ permalink raw reply [flat|nested] 10+ messages in thread
* RE: [OE-core] [langdale][master][PATCH] rust: Do not use default compiler flags defined in CC crate 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 1 sibling, 1 reply; 10+ messages in thread From: Peter Kjellerstedt @ 2022-11-19 1:57 UTC (permalink / raw) To: Richard Purdie, Anton Antonov, openembedded-core@lists.openembedded.org > -----Original Message----- > From: openembedded-core@lists.openembedded.org <openembedded-core@lists.openembedded.org> On Behalf Of Richard Purdie > Sent: den 18 november 2022 17:36 > 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 > > On Fri, 2022-11-18 at 16:21 +0000, Anton Antonov wrote: > > I’ve tested your approach. It doesn’t work for whatever reason. > > CRATE_CC_NO_DEFAULTS is empty exported for native recipes: > > > > $ MACHINE=qemuarm bitbake rust-native -e |grep CRATE_CC_NO_DEFAULTS > > # $CRATE_CC_NO_DEFAULTS [3 operations] > > # [export] "${'1' if d.getVar('CRATE_CC_NO_DEFAULTS') == 'true' else '0'}" > > export CRATE_CC_NO_DEFAULTS="" > > # $CRATE_CC_NO_DEFAULTS:class-native > > CRATE_CC_NO_DEFAULTS:class-native="" > > > > > > I also tried: > > CRATE_CC_NO_DEFAULTS[export] = "${@oe.utils.conditional('CRATE_CC_NO_DEFAULTS', '', '0', '1', d)}" > > with the same result – empty export. > > I think it might need to be 0 or "" instead of '0'. It would be nice if > we could make False work too but I worry that might not. > > Cheers, > > Richard None of this will work unless you change the code in bitbake/lib/bb/data.py to use d.getVarFlag(var, "export") instead of d.getVarFlag(var, "export", False). However, I assume that is not wanted given that support for foo[unexport] = "1" was introduced to counteract a foo[export] = "1". //Peter ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [OE-core] [langdale][master][PATCH] rust: Do not use default compiler flags defined in CC crate 2022-11-19 1:57 ` Peter Kjellerstedt @ 2022-11-20 11:45 ` Richard Purdie 2022-11-21 9:39 ` Anton Antonov 0 siblings, 1 reply; 10+ messages in thread From: Richard Purdie @ 2022-11-20 11:45 UTC (permalink / raw) To: Peter Kjellerstedt, Anton Antonov, openembedded-core@lists.openembedded.org On Sat, 2022-11-19 at 01:57 +0000, Peter Kjellerstedt wrote: > > -----Original Message----- > > From: openembedded-core@lists.openembedded.org > > <openembedded-core@lists.openembedded.org> On Behalf Of Richard > > Purdie > > Sent: den 18 november 2022 17:36 > > 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 > > > > On Fri, 2022-11-18 at 16:21 +0000, Anton Antonov wrote: > > > I’ve tested your approach. It doesn’t work for whatever reason. > > > CRATE_CC_NO_DEFAULTS is empty exported for native recipes: > > > > > > $ MACHINE=qemuarm bitbake rust-native -e |grep > > > CRATE_CC_NO_DEFAULTS > > > # $CRATE_CC_NO_DEFAULTS [3 operations] > > > # [export] "${'1' if d.getVar('CRATE_CC_NO_DEFAULTS') == > > > 'true' else '0'}" > > > export CRATE_CC_NO_DEFAULTS="" > > > # $CRATE_CC_NO_DEFAULTS:class-native > > > CRATE_CC_NO_DEFAULTS:class-native="" > > > > > > > > > I also tried: > > > CRATE_CC_NO_DEFAULTS[export] = > > > "${@oe.utils.conditional('CRATE_CC_NO_DEFAULTS', '', '0', '1', > > > d)}" > > > with the same result – empty export. > > > > I think it might need to be 0 or "" instead of '0'. It would be > > nice if > > we could make False work too but I worry that might not. > > > > Cheers, > > > > Richard > > None of this will work unless you change the code in > bitbake/lib/bb/data.py > to use d.getVarFlag(var, "export") instead of d.getVarFlag(var, > "export", False). > However, I assume that is not wanted given that support for > foo[unexport] = "1" > was introduced to counteract a foo[export] = "1". Good point, which reminds me why the code does this. Expanding the value for all export variables would have a significant effect on some performance sensitive code :(. From memory I think there was a bit more to unexport than that. Looking at the history: https://git.yoctoproject.org/poky/commit/?id=0da3c82a66e02bf2d3780e23427d476766a0bcfc I think it wasn't enough just to not export some things, we wanted to actually unset them in the shell environment. We may have later done more environment cleaning which made this unnecessary, less sure about that. I did remove a lot of the unexports (e.g. MACHINE and DISTRO) but SHELL[unexport] = "1" remains. Cheers, Richard ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [OE-core] [langdale][master][PATCH] rust: Do not use default compiler flags defined in CC crate 2022-11-20 11:45 ` Richard Purdie @ 2022-11-21 9:39 ` Anton Antonov 0 siblings, 0 replies; 10+ messages in thread From: Anton Antonov @ 2022-11-21 9:39 UTC (permalink / raw) To: Richard Purdie, Peter Kjellerstedt, openembedded-core@lists.openembedded.org [-- Attachment #1: Type: text/plain, Size: 2909 bytes --] Hi Richard, Are you happy to accept my initial patch as it? Cheers, Anton From: Richard Purdie <richard.purdie@linuxfoundation.org> Date: Sunday, 20 November 2022 at 11:45 To: Peter Kjellerstedt <peter.kjellerstedt@axis.com>, Anton Antonov <Anton.Antonov@arm.com>, openembedded-core@lists.openembedded.org <openembedded-core@lists.openembedded.org> Subject: Re: [OE-core] [langdale][master][PATCH] rust: Do not use default compiler flags defined in CC crate On Sat, 2022-11-19 at 01:57 +0000, Peter Kjellerstedt wrote: > > -----Original Message----- > > From: openembedded-core@lists.openembedded.org > > <openembedded-core@lists.openembedded.org> On Behalf Of Richard > > Purdie > > Sent: den 18 november 2022 17:36 > > 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 > > > > On Fri, 2022-11-18 at 16:21 +0000, Anton Antonov wrote: > > > I’ve tested your approach. It doesn’t work for whatever reason. > > > CRATE_CC_NO_DEFAULTS is empty exported for native recipes: > > > > > > $ MACHINE=qemuarm bitbake rust-native -e |grep > > > CRATE_CC_NO_DEFAULTS > > > # $CRATE_CC_NO_DEFAULTS [3 operations] > > > # [export] "${'1' if d.getVar('CRATE_CC_NO_DEFAULTS') == > > > 'true' else '0'}" > > > export CRATE_CC_NO_DEFAULTS="" > > > # $CRATE_CC_NO_DEFAULTS:class-native > > > CRATE_CC_NO_DEFAULTS:class-native="" > > > > > > > > > I also tried: > > > CRATE_CC_NO_DEFAULTS[export] = > > > "${@oe.utils.conditional('CRATE_CC_NO_DEFAULTS', '', '0', '1', > > > d)}" > > > with the same result – empty export. > > > > I think it might need to be 0 or "" instead of '0'. It would be > > nice if > > we could make False work too but I worry that might not. > > > > Cheers, > > > > Richard > > None of this will work unless you change the code in > bitbake/lib/bb/data.py > to use d.getVarFlag(var, "export") instead of d.getVarFlag(var, > "export", False). > However, I assume that is not wanted given that support for > foo[unexport] = "1" > was introduced to counteract a foo[export] = "1". Good point, which reminds me why the code does this. Expanding the value for all export variables would have a significant effect on some performance sensitive code :(. From memory I think there was a bit more to unexport than that. Looking at the history: https://git.yoctoproject.org/poky/commit/?id=0da3c82a66e02bf2d3780e23427d476766a0bcfc I think it wasn't enough just to not export some things, we wanted to actually unset them in the shell environment. We may have later done more environment cleaning which made this unnecessary, less sure about that. I did remove a lot of the unexports (e.g. MACHINE and DISTRO) but SHELL[unexport] = "1" remains. Cheers, Richard [-- Attachment #2: Type: text/html, Size: 6066 bytes --] ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [OE-core] [langdale][master][PATCH] rust: Do not use default compiler flags defined in CC crate 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-12-08 12:17 ` Richard Purdie 1 sibling, 0 replies; 10+ messages in thread From: Richard Purdie @ 2022-12-08 12:17 UTC (permalink / raw) To: Anton Antonov, openembedded-core 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 ^ permalink raw reply [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