Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add global CXX compiler flag to yocto build

It seems something obvious to me, but I couldn't find any solution. Suppose I want to add or change a compiler flag/option which applies to all yocto recipes. It is possible to add a global flag somewhere, without changing the recipes ?

like image 311
Waldorf Avatar asked Sep 23 '14 19:09

Waldorf


2 Answers

You can add it to the machine configuration file.

The machine configuration file is in the board support layer, under conf/machine. It is named $MACHINE.conf, where MACHINE is defined in your local.conf.

Here are the ones in poky 1.4. Yours might be in a layer outside of poky.

> ls -1 meta-yocto-bsp/conf/machine/
atom-pc.conf
beagleboard.conf
mpc8315e-rdb.conf
routerstationpro.conf
> ls -1 meta/conf/machine/
include
qemuarm.conf
qemumips.conf
qemuppc.conf
qemux86-64.conf
qemux86.conf

Once you identify your board configuration file, add a line to the end to add to your C Flags:

TARGET_CFLAGS += " <my flags> "
like image 184
pinta Avatar answered Sep 17 '22 02:09

pinta


You can add global compiler options for Yocto builds in poky/meta/conf/bitbake.conf. After adding options, check the bitbake environment using the command bitbake -e

cat poky/meta/conf/bitbake.conf

...
...
##################################################################
# Build flags and options.
##################################################################

export BUILD_CPPFLAGS = "-isystem${STAGING_INCDIR_NATIVE}"
BUILDSDK_CPPFLAGS = "-isystem${STAGING_INCDIR}"
export CPPFLAGS = "${TARGET_CPPFLAGS}"

export BUILD_CFLAGS = "${BUILD_CPPFLAGS} ${BUILD_OPTIMIZATION}"
BUILDSDK_CFLAGS = "${BUILDSDK_CPPFLAGS} ${BUILD_OPTIMIZATION}"
export CFLAGS = "${TARGET_CFLAGS}"
export TARGET_CFLAGS = "${TARGET_CPPFLAGS} ${SELECTED_OPTIMIZATION}"

export BUILD_CXXFLAGS = "${BUILD_CFLAGS}"
export CXXFLAGS = "${TARGET_CXXFLAGS}"
export TARGET_CXXFLAGS = "${TARGET_CFLAGS}"
like image 22
Ashok Vairavan Avatar answered Sep 17 '22 02:09

Ashok Vairavan