[bitbake-devel] Regarding CFLAGS in recipe

Nicolas Dechesne nicolas.dechesne at linaro.org
Fri Dec 20 09:54:38 UTC 2013


On Thu, Nov 7, 2013 at 9:31 PM, Udayan Bapat <uvbapat at gmail.com> wrote:

> Hi all,
>
> I have a Yocto build environment where I intend to build all recipes with
> -fPIE flag. So I have added CFLAGS_append += '-fPIE' in the local.conf.
> However since shared libraries can not be built using -fPIE flag, I would
> like to remove it from some recipes.
>
> So far I have tried this in .bb files -
>
> CFLAGS_noPIE = "${@'${CFLAGS}'.replace('-fPIE','')}"
>
> do_compile_prepend () {
>     CFLAGS = "${CFLAGS_noPIE}"
> }
>
> This throws an error -
>
> */zlib-native/1.2.8-r0/temp/run.do_compile.23159: line 82: CFLAGS: command
> not found
>
> I also have tried -
>
> CFLAGS = "${@'${CFLAGS}'.replace('-fPIE','')}"
>
> This doesn't work because same variable can not be referenced twice.
>
> Then I tried this -
>
> CFLAGS_noPIE = "${@'${CFLAGS}'.replace('-fPIE','')}"
> CFLAGS = "${CFLAGS_noPIE}"
>
> This fails with an error "maximum recursion depth exceeded for variable
> 'CFLAGS'"
>
> What is the correct way to doing this?
>

if you use 'master' you can use the newly added _remove modifier. e.g.
CFLAGS_remove = "-fPIE"

otherwise you might need to query the DB to retrieve CFLAGS, something
along these lines: ${@d.getVar('CFLAGS', True).replace(xxx)}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openembedded.org/pipermail/bitbake-devel/attachments/20131220/1e82797c/attachment-0002.html>


More information about the bitbake-devel mailing list