All Yocto projects by default comes with -O2 optimization level
How to override this for a single package with -O0 ?
From bitbake.conf:
export BUILD_CFLAGS = "${BUILD_CPPFLAGS} ${BUILD_OPTIMIZATION}"
FULL_OPTIMIZATION = "-O2 -pipe ${DEBUG_FLAGS}"
DEBUG_OPTIMIZATION = "-O -fno-omit-frame-pointer ${DEBUG_FLAGS} -pipe"
SELECTED_OPTIMIZATION = "${@d.getVar(['FULL_OPTIMIZATION', 'DEBUG_OPTIMIZATION'][d.getVar('DEBUG_BUILD') == '1'])}"
So if you want to switch it to -O0
for debugging purposes, just set DEBUG_BUILD="1"
in the recipe. If the recipe is broken with -O2
because of bad code, override FULL_OPTIMISATION
appropriately.