How to add global CXX compiler flag to yocto build - compiler-flags

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 ?

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> "

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}"

Related

Internal Error: no cycle found in Scons Build

When I build my Sconstruct file, I am getting the below error.
scons: *** Found dependency cycle(s):
build/sselser/sselConfigArgs.h -> build/sselser/sselConfigArgs.h
Internal Error: no cycle found for node build/sselser/sselMain (<SCons.Node.FS.File instance at 0x9f61e8>) in state pending
Internal Error: no cycle found for node build/sselser/sselMain.o (<SCons.Node.FS.File instance at 0x9f2e68>) in state pending
File "/nfs/scons/scons-1.3.0/lib/scons-1.3.0/SCons/Taskmaster.py", line 1026, in cleanup
I guess this is due to dependency of sselMain in sselTransorm as the error occurs during the build of sselTransform directory.
Makefile in sselTransform:
UNIT_SUPPORT_FILES += ../sselser/sselMain intest ../../../make/Makenv
MDE_SUPPORT_FILES += ../sselser/sselMain intest ../../../make/Makenv
I need to add the same in Sconscript of sselTransform directory to resolve this issue.
How to resolve this issue?
Sconscript:
#Set CPPPATH, RPATH, DEFINES and CCFLAGS
env = Environment(CPPPATH =['.','../sselTransform','../sselSm','../sselSRC'],
RPATH = ['/l-n/app/colr/lib/infra/SunOS5.10/WS12.0'],CPPDEFINES = ['THREADSAFE','_RWSTD_SOLARIS_THREADS','_SVID_GETTO
D','DEBUG','sun5'],CCFLAGS = ['library=rwtools7_std','features=no%tmplife','-pta','-mt','-xdebugformat=stabs','-g0','-xildoff'])
env['CXX']=CXX
Src = Split('sselManager.C PromoNotifyMgr.C ')
env.StaticLibrary('libSselser-g0.a',Src)
Src1 = Split('sselMain.C sselManager.o PromoNotifyMgr.o ')
env.Program('sselMain',Src1)
configfile = 'sselConfigArgs.h'
CONFIG_PATH = '../../build/include/'
CONFIG=CONFIG_PATH+configfile
env.Command(CONFIG,configfile,
[Copy('$TARGET', '$SOURCE'),
Chmod('$TARGET', 0444)])
Sconstruct:
SConscript('src/ssel/sselser/SConscript',variant_dir='build/sselser',duplicate=0,exports='env')
Try this?
Notes:
I'm saving the build objects for your two source files and using those in both the program and static library.
I've added the target dir you're copying the header file to earlier in the CPPPATH.
You could have skipped the variables configfile, CONFIG_PATH, CONFIG and just used the strings in your Command.
You are using a VERY old version of SCons. If you're limited to python 2.7 please try using SCons 3.0.1? If you're not and can use Python 3.6, then try using SCons 4.3.0.
#Set CPPPATH, RPATH, DEFINES and CCFLAGS
env = Environment(
CPPPATH =['.','../include','../sselTransform','../sselSm','../sselSRC'],
RPATH = ['/l-n/app/colr/lib/infra/SunOS5.10/WS12.0'],
CPPDEFINES = ['THREADSAFE','_RWSTD_SOLARIS_THREADS','_SVID_GETTOD','DEBUG','sun5'],
CCFLAGS = ['library=rwtools7_std','features=no%tmplife','-pta','-mt','-xdebugformat=stabs','-g0','-xildoff'])
env['CXX']=CXX
Src = ['sselManager.C','PromoNotifyMgr.C']
objects = []
for s in Src:
objects.extend(env.StaticObject(s))
env.StaticLibrary('Sselser-g0',objects)
Src1 = ['sselMain.C'] + objects
env.Program('sselMain', Src1)
configfile = 'sselConfigArgs.h'
CONFIG_PATH = '../include/'
CONFIG=CONFIG_PATH+configfile
env.Command(CONFIG, configfile,
[Copy('$TARGET', '$SOURCE'),
Chmod('$TARGET', 0444)])

How can I run qmake tool on target with yocto?

My team is using Petalinux 18.02 which uses Yocto ver.rocko and meta-qt5.
I added IMAGE_INSTALL_append = " packagegroup-qt5-toolchain-target " in local.conf but it did not integrate qmake to target image. Then I modified local.conf one more time and added IMAGE_INSTALL_append = " qtbase-tools " and it did that! So I finally integrated qmake tool on target system.
However, it does not work well...
Its configuration looks invalid and it can't find features, test functions.
I'll add a detail below.
# Environment variables
export QTDIR="/usr/bin/qt5";
export QTINC="/usr/include/qt5";
export QTLIB="/usr/lib/qt5";
export QMAKESPEC="/usr/lib/qt5/mkspecs/linux-oe-g++";
export QMAKEFEATURES="/usr/lib/qt5/mkspecs/features";
export PATH="${QTDIR}:${PATH}"
root#petalinux18.02:~# /usr/bin/qt5/qmake -query
QT_SYSROOT:/scratch/petalinux-yocto/yocto_downloads_2018.2_zynqmp-generic/build_zynqmp-generic/tmp/work/aarch64-xilinx-linuxt
QT_INSTALL_PREFIX:/scratch/petalinux-yocto/yocto_downloads_2018.2_zynqmp-generic/build_zynqmp-generic/tmp/work/aarch64-xilinr
QT_INSTALL_PREFIX/raw:/usr
QT_INSTALL_ARCHDATA:/scratch/petalinux-yocto/yocto_downloads_2018.2_zynqmp-generic/build_zynqmp-generic/tmp/work/aarch64-xil5
QT_INSTALL_ARCHDATA/raw:/usr/lib/qt5
QT_INSTALL_DATA:/scratch/petalinux-yocto/yocto_downloads_2018.2_zynqmp-generic/build_zynqmp-generic/tmp/work/aarch64-xilinx-5
QT_INSTALL_DATA/raw:/usr/share/qt5
QT_INSTALL_DOCS:/scratch/petalinux-yocto/yocto_downloads_2018.2_zynqmp-generic/build_zynqmp-generic/tmp/work/aarch64-xilinx-5
QT_INSTALL_DOCS/raw:/usr/share/doc/qt5
QT_INSTALL_HEADERS:/scratch/petalinux-yocto/yocto_downloads_2018.2_zynqmp-generic/build_zynqmp-generic/tmp/work/aarch64-xili5
QT_INSTALL_HEADERS/raw:/usr/include/qt5
QT_INSTALL_LIBS:/scratch/petalinux-yocto/yocto_downloads_2018.2_zynqmp-generic/build_zynqmp-generic/tmp/work/aarch64-xilinx-b
QT_INSTALL_LIBS/raw:/usr/lib
QT_INSTALL_LIBEXECS:/scratch/petalinux-yocto/yocto_downloads_2018.2_zynqmp-generic/build_zynqmp-generic/tmp/work/aarch64-xilc
QT_INSTALL_LIBEXECS/raw:/usr/lib/qt5/libexec
QT_INSTALL_BINS:/scratch/petalinux-yocto/yocto_downloads_2018.2_zynqmp-generic/build_zynqmp-generic/tmp/work/aarch64-xilinx-5
QT_INSTALL_BINS/raw:/usr/bin/qt5
QT_INSTALL_TESTS:/scratch/petalinux-yocto/yocto_downloads_2018.2_zynqmp-generic/build_zynqmp-generic/tmp/work/aarch64-xilinxs
QT_INSTALL_TESTS/raw:/usr/share/qt5/tests
QT_INSTALL_PLUGINS:/scratch/petalinux-yocto/yocto_downloads_2018.2_zynqmp-generic/build_zynqmp-generic/tmp/work/aarch64-xilis
QT_INSTALL_PLUGINS/raw:/usr/lib/qt5/plugins
QT_INSTALL_IMPORTS:/scratch/petalinux-yocto/yocto_downloads_2018.2_zynqmp-generic/build_zynqmp-generic/tmp/work/aarch64-xilis
QT_INSTALL_IMPORTS/raw:/usr/lib/qt5/imports
QT_INSTALL_QML:/scratch/petalinux-yocto/yocto_downloads_2018.2_zynqmp-generic/build_zynqmp-generic/tmp/work/aarch64-xilinx-ll
QT_INSTALL_QML/raw:/usr/lib/qt5/qml
QT_INSTALL_TRANSLATIONS:/scratch/petalinux-yocto/yocto_downloads_2018.2_zynqmp-generic/build_zynqmp-generic/tmp/work/aarch64s
QT_INSTALL_TRANSLATIONS/raw:/usr/share/qt5/translations
QT_INSTALL_CONFIGURATION:/scratch/petalinux-yocto/yocto_downloads_2018.2_zynqmp-generic/build_zynqmp-generic/tmp/work/aarch65
QT_INSTALL_CONFIGURATION/raw:/etc/qt5
QT_INSTALL_EXAMPLES:/scratch/petalinux-yocto/yocto_downloads_2018.2_zynqmp-generic/build_zynqmp-generic/tmp/work/aarch64-xils
QT_INSTALL_EXAMPLES/raw:/usr/share/qt5/examples
QT_INSTALL_DEMOS:/scratch/petalinux-yocto/yocto_downloads_2018.2_zynqmp-generic/build_zynqmp-generic/tmp/work/aarch64-xilinxs
QT_INSTALL_DEMOS/raw:/usr/share/qt5/examples
QT_HOST_PREFIX:/scratch/petalinux-yocto/yocto_downloads_2018.2_zynqmp-generic/build_zynqmp-generic/tmp/work/aarch64-xilinx-le
QT_HOST_DATA:/scratch/petalinux-yocto/yocto_downloads_2018.2_zynqmp-generic/build_zynqmp-generic/tmp/work/aarch64-xilinx-lin5
QT_HOST_BINS:/usr/bin/qt5
QT_HOST_LIBS:/scratch/petalinux-yocto/yocto_downloads_2018.2_zynqmp-generic/build_zynqmp-generic/tmp/work/aarch64-xilinx-linb
QMAKE_SPEC:linux-oe-g++
QMAKE_XSPEC:linux-oe-g++
QMAKE_VERSION:3.1
QT_VERSION:5.9.4
# test.pro
TEMPLATE = app
TARGET = test_qmake
DEPENDPATH += .
INCLUDEPATH += .
INCLUDEPATH += /usr/include/qt5
# Input
HEADERS += test_qmake.hpp
SOURCES += test_qmake.cpp
root#petalinux18.02:~# ls
test.pro
root#petalinux18.02:~# /usr/bin/qt5/qmake
/usr/lib/qt5/mkspecs/features/resolve_config.prf:25: 'addExclusiveBuilds' is not a recognized test function.
/usr/lib/qt5/mkspecs/features/resolve_config.prf:37: 'addExclusiveBuilds' is not a recognized test function.
Project ERROR: Could not find feature force_asserts.
I know running qmake on target not host is not normal. But our client wants it then I have to do it.
I have been searching a solution in google but I found out nothing...
Is there anyone else has a solution?

New Yocto Recipe Builds but Work Directory is Deleted after Compilation

I am trying to update the recipe for zbar from 0.10.0 to 0.20.1. Here is the original recipe:
https://github.com/openembedded/meta-openembedded/blob/master/meta-oe/recipes-support/zbar/zbar_0.10.bb
My modified recipe is at the bottom of this question. The package does compile, but the problem is that something happens during the "packaging" step and the "work" directory is wiped out except for the "temp" directory inside the "work" directory. During compilation, if I list the files in the work directory, everything I expect is present, but after compilation succeeds, something cleans the files up. What am I doing wrong?
During compilation:
user#ubuntu:~/rpi/build/tmp/work/cortexa7hf-neon-vfpv4-poky-linux-gnueabi/zbar/0.20.1-r0$ cd ../0.20.1-r0/ ; ls
build image pkgdata sysroot-destdir
configure.sstate license-destdir pseudo temp
debugsources.list package recipe-sysroot
git packages-split recipe-sysroot-native
After Compilation:
user#ubuntu:~/rpi/build/tmp/work/cortexa7hf-neon-vfpv4-poky-linux-gnueabi/zbar/0.20.1-r0$ cd ../0.20.1-r0/ ; ls
temp
Yocto Recipe:
DESRIPTION = "2D barcode scanner toolkit."
SECTION = "graphics"
LICENSE = "LGPL-2.1"
DEPENDS = "pkgconfig intltool-native libpng jpeg"
LIC_FILES_CHKSUM = "file://LICENSE;md5=243b725d71bb5df4a1e5920b344b86ad"
S = "${WORKDIR}/git"
SRCREV = "edcf08b49e0a5fe71c18fa9d4b8ed83ed8fc9082"
SRC_URI = "git://github.com/mchehab/zbar.git"
inherit autotools pkgconfig
EXTRA_OECONF = " --without-x --without-imagemagick --without-qt --without-python2 --disable-video --without-gtk"
FILES_${PN} += "${bindir}"
FILES_${PN} += "${libdir}"
do_install_append() {
echo "done..."
}
This is because of the rm_work class. You can remove,
INHERIT += "rm_work"
this from local.conf or in according image recipe file. Or you can disable the rm_work only for your recipe using,
RM_WORK_EXCLUDE += "zbar"
in conf/local.conf.

debug_and_release option didn't work for linux

I'm trying to build my qt-plugin in both debug and release modes under Linux OS (Ubuntu 13.10), but it seems to me qmake ignores CONFIG += debug_and_release option. I also tried to use CONFIG += build_all, but it didn't work to. When I use the same options on Windows Qt generated two output files (for example plugin.a and plugind.a), but on Linux i get just one of them. When I force QtCreator to build my project in opposite mode (debug instead of relesae) it overrides already generated target file with the one that has the same name. Where did I go wrong?
Maybe the problem is that in your .pro file you should have set different target directories or different target file names. I do not know why but it looks like on Windows the target file names generated into your Makefiles are different and on Linux they are not different. You can try to change either your target directory or your target file name for debug build.
Try either
CONFIG(release, debug|release) {
TARGET = plugin
} else {
TARGET = plugind
}
or
CONFIG(release, debug|release) {
DESTDIR = release
OBJECTS_DIR = release/.obj
MOC_DIR = release/.moc
RCC_DIR = release/.rcc
UI_DIR = release/.ui
} else {
DESTDIR = debug
OBJECTS_DIR = debug/.obj
MOC_DIR = debug/.moc
RCC_DIR = debug/.rcc
UI_DIR = debug/.ui
}

Using scons with Keil compiler/linker

I'm trying to use the Keil C51 compiler with scons as a build system.
The final problem I have is how to get $SOURCES to be output comma-separated to the linker. The default uses space as separator.
The relevant parts of the SConstruct is
path = ['C:\Keil\C51\BIN']
env = Environment(ENV = {'PATH' : path})
#Compiler settings
env['CC'] = 'c51.exe'
env['CCCOM'] = '$CC $SOURCES $_CPPINCFLAGS $CFLAGS $_CCCOMCOM ' #-o $TARGET
env['INCPREFIX'] = 'INCDIR('
env['INCSUFFIX'] = ')'
# Linker settings
env.Replace(LINK='BL51.exe')
env['LINKCOM'] = '$LINK $SOURCES TO $TARGET $LINKFLAGS $__RPATH $_LIBDIRFLAGS $_LIBFLAGS'
With this I get:
BL51.exe driver.obj flash.obj initialization.obj power.obj TO Outfile.omf
What I want is:
BL51.exe driver.obj,flash.obj,initialization.obj,power.obj TO Outfile.omf
$SOURCES is a construction variable and I cant find how to change how it is printed to the command-line.
Anyone?
I solved this by using:
env['LINKCOM'] = '$LINK ",".join( $SOURCES ) TO $TARGET $LINKFLAGS $__RPATH $_LIBDIRFLAGS $_LIBFLAGS'

Resources