diff mbox series

[2/5] distro/include: Add debug_build_tune.inc, collect debug tuning configuration

Message ID 20250912160741.346809-2-hongxu.jia@windriver.com
State New
Headers show
Series [1/5] yocto-space-optimize.inc: move space optimize from recipe webkitgtk | expand

Commit Message

Hongxu Jia Sept. 12, 2025, 4:07 p.m. UTC
The modern compilers and code seem to require extra steps to avoid DEBUG errors,
Move debug tuning configuration from recipes, add an include file to collect them
to address these errors. Require the include file when DEBUG_BUILD is enabled.

Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
---
 meta/conf/bitbake.conf                        |  2 +
 meta/conf/distro/include/debug_build_tune.inc | 45 +++++++++++++++++++
 meta/recipes-connectivity/kea/kea_3.0.1.bb    | 10 -----
 .../debugedit/debugedit_5.2.bb                |  2 -
 meta/recipes-devtools/gcc/gcc-sanitizers.inc  |  3 --
 .../python/python3-lxml_6.0.1.bb              | 12 -----
 meta/recipes-extended/bash/bash_5.3.bb        |  3 --
 meta/recipes-extended/mdadm/mdadm_4.4.bb      |  2 -
 .../jpeg/libjpeg-turbo_3.1.2.bb               |  3 --
 .../vulkan-validation-layers_1.4.321.0.bb     |  2 -
 meta/recipes-kernel/lttng/lttng-ust_2.14.0.bb |  1 -
 meta/recipes-kernel/perf/perf.bb              |  2 -
 meta/recipes-sato/webkit/webkitgtk_2.48.5.bb  |  2 +-
 meta/recipes-support/vim/vim_9.1.bb           |  2 +-
 14 files changed, 49 insertions(+), 42 deletions(-)
 create mode 100644 meta/conf/distro/include/debug_build_tune.inc

Comments

Peter Kjellerstedt Sept. 13, 2025, 10:06 a.m. UTC | #1
> -----Original Message-----
> From: openembedded-core@lists.openembedded.org <openembedded-core@lists.openembedded.org> On Behalf Of hongxu via lists.openembedded.org
> Sent: den 12 september 2025 18:08
> To: openembedded-core@lists.openembedded.org
> Cc: randy.macleod@windriver.com
> Subject: [OE-core] [PATCH 2/5] distro/include: Add debug_build_tune.inc, collect debug tuning configuration
> 
> The modern compilers and code seem to require extra steps to avoid DEBUG errors,
> Move debug tuning configuration from recipes, add an include file to collect them
> to address these errors. Require the include file when DEBUG_BUILD is enabled.
> 
> Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
> ---
>  meta/conf/bitbake.conf                        |  2 +
>  meta/conf/distro/include/debug_build_tune.inc | 45 +++++++++++++++++++
>  meta/recipes-connectivity/kea/kea_3.0.1.bb    | 10 -----
>  .../debugedit/debugedit_5.2.bb                |  2 -
>  meta/recipes-devtools/gcc/gcc-sanitizers.inc  |  3 --
>  .../python/python3-lxml_6.0.1.bb              | 12 -----
>  meta/recipes-extended/bash/bash_5.3.bb        |  3 --
>  meta/recipes-extended/mdadm/mdadm_4.4.bb      |  2 -
>  .../jpeg/libjpeg-turbo_3.1.2.bb               |  3 --
>  .../vulkan-validation-layers_1.4.321.0.bb     |  2 -
>  meta/recipes-kernel/lttng/lttng-ust_2.14.0.bb |  1 -
>  meta/recipes-kernel/perf/perf.bb              |  2 -
>  meta/recipes-sato/webkit/webkitgtk_2.48.5.bb  |  2 +-
>  meta/recipes-support/vim/vim_9.1.bb           |  2 +-
>  14 files changed, 49 insertions(+), 42 deletions(-)
>  create mode 100644 meta/conf/distro/include/debug_build_tune.inc
> 
> diff --git a/meta/conf/bitbake.conf b/meta/conf/bitbake.conf
> index 8e90c7bbc85..193a8377cf2 100644
> --- a/meta/conf/bitbake.conf
> +++ b/meta/conf/bitbake.conf
> @@ -831,6 +831,8 @@ include conf/licenses.conf
>  require conf/sanity.conf
>  include conf/bblock.conf
> 
> +require ${@oe.utils.vartrue('DEBUG_BUILD', 'conf/distro/include/debug_build_tune.inc', '', d)}

Why debug_build_tune.inc, why not just debug_build.inc?

I suggest using include_all instead of require to allow other layers 
to add their own debug configurations in a similar way.

Further, to avoid the :remove operations below, I suggest 
introducing separate variables for the optimization level. And,
since you are moving everything else related to DEBUG_BUILD == 1 
to debug_build_tune.inc, why not move parts of the definitions 
of the *_OPTIMIZATION variables there as well? That would simplify 
their definitions.

You would then get this in bitbake.conf:

FULL_OPTLEVEL = "-O2"
FULL_OPTIMIZATION = "${FULL_OPTLEVEL} ${DEBUG_LEVELFLAG}"
SELECTED_OPTIMIZATION = "${FULL_OPTIMIZATION}"
# compiler flags for native/nativesdk
BUILD_OPTLEVEL = "-O2"
BUILD_OPTIMIZATION = "${BUILD_OPTLEVEL}"

And this in debug_build_tune.inc:

DEBUG_OPTLEVEL = "-Og"
DEBUG_OPTIMIZATION = "${DEBUG_OPTLEVEL} ${DEBUG_LEVELFLAG}"
SELECTED_OPTIMIZATION = "${DEBUG_OPTIMIZATION}"
# compiler flags for native/nativesdk
BUILD_OPTLEVEL = "-Og"
BUILD_OPTIMIZATION = "${BUILD_OPTLEVEL} -g"

*_OPTLEVEL need to be documented, and the documentation for 
FULL_OPTIMIZATION and DEBUG_OPTIMIZATION probably needs to be 
updated.

And poky-tiny.conf and harfbuzz need to set FULL_OPTLEVEL instead of 
FULL_OPTIMIZATION.

> +
>  ##################################################################
>  # Weak variables (usually to retain backwards compatibility)
>  ##################################################################
> diff --git a/meta/conf/distro/include/debug_build_tune.inc b/meta/conf/distro/include/debug_build_tune.inc
> new file mode 100644
> index 00000000000..ca43d2b955c
> --- /dev/null
> +++ b/meta/conf/distro/include/debug_build_tune.inc
> @@ -0,0 +1,45 @@
> +# The modern compilers and code seem to require extra steps to avoid DEBUG errors,
> +# this file collects debug tuning configuration to address DEBUG errors.
> +
> +DEBUG_OPTIMIZATION:append:pn-perf = " -Wno-error=maybe-uninitialized"
> +DEBUG_OPTIMIZATION:append:armv4:pn-libjpeg-turbo = " ${@bb.utils.contains('TUNE_CCARGS', '-mthumb', '-fomit-frame-pointer', '', d)}"
> +DEBUG_OPTIMIZATION:append:armv5:pn-libjpeg-turbo = " ${@bb.utils.contains('TUNE_CCARGS', '-mthumb', '-fomit-frame-pointer', '', d)}"
> +DEBUG_OPTIMIZATION:append:armv4:pn-bash = " ${@bb.utils.contains('TUNE_CCARGS', '-mthumb', '-fomit-frame-pointer', '', d)}"
> +DEBUG_OPTIMIZATION:append:armv5:pn-bash = " ${@bb.utils.contains('TUNE_CCARGS', '-mthumb', '-fomit-frame-pointer', '', d)}"
> +DEBUG_OPTIMIZATION:append:pn-mdadm = " -Wno-error"
> +DEBUG_OPTIMIZATION:remove:mips:pn-kea = " -Og"
> +DEBUG_OPTIMIZATION:append:mips:pn-kea = " -O"
> +DEBUG_OPTIMIZATION:remove:mipsel:pn-kea = " -Og"
> +DEBUG_OPTIMIZATION:append:mipsel:pn-kea = " -O"
> +# {standard input}: Assembler messages:
> +# {standard input}:1488805: Error: branch out of range
> +DEBUG_OPTIMIZATION:remove:mips:pn-python3-lxml = " -Og"
> +DEBUG_OPTIMIZATION:append:mips:pn-python3-lxml = " -O"
> +DEBUG_OPTIMIZATION:remove:mipsel:pn-python3-lxml = " -Og"
> +DEBUG_OPTIMIZATION:append:mipsel:pn-python3-lxml = " -O"
> +# used to fix ../../../../../../../../../work-shared/gcc-8.3.0-r0/gcc-8.3.0/libsanitizer/libbacktrace/../../libbacktrace/elf.c:772:21: error: 'st.st_mode' may be used uninitialized in this function [-Werror=maybe-uninitialized]
> +DEBUG_OPTIMIZATION:append:pn-gcc-sanitizers = " -Wno-error"
> +
> +BUILD_OPTIMIZATION:remove:mips:pn-kea = " -Og"
> +BUILD_OPTIMIZATION:append:mips:pn-kea = " -O"
> +BUILD_OPTIMIZATION:remove:mipsel:pn-kea = " -Og"
> +BUILD_OPTIMIZATION:append:mipsel:pn-kea = " -O"
> +# {standard input}: Assembler messages:
> +# {standard input}:1488805: Error: branch out of range
> +BUILD_OPTIMIZATION:remove:mips:pn-python3-lxml = " -Og"
> +BUILD_OPTIMIZATION:append:mips:pn-python3-lxml = " -O"
> +BUILD_OPTIMIZATION:remove:mipsel:pn-python3-lxml = " -Og"
> +BUILD_OPTIMIZATION:append:mipsel:pn-python3-lxml = " -O"
> +
> +CPPFLAGS:append:arm::pn-lttng-ust = " -DUATOMIC_NO_LINK_ERROR"

Change :: to :

> +
> +EXTRA_OECMAKE:remove:pn-webkitgtk = "-DWEBKIT_NO_INLINE_HINTS=OFF"
> +EXTRA_OECMAKE:append:pn-webkitgtk = " -DWEBKIT_NO_INLINE_HINTS=ON"
> +
> +EXTRA_OECONF:pn-debugedit = "--disable-inlined-xxhash"
> +EXTRA_OECONF:pn-debugedit-native = "--disable-inlined-xxhash"
> +EXTRA_OECONF:pn-nativesdk-debugedit = "--disable-inlined-xxhash"

These need to use :append.

> +
> +lcl_maybe_fortify:pn-vim = ""
> +
> +CXXFLAGS:append:pn-vulkan-validation-layers = " -DXXH_NO_INLINE_HINTS=1"
> diff --git a/meta/recipes-connectivity/kea/kea_3.0.1.bb b/meta/recipes-connectivity/kea/kea_3.0.1.bb
> index cc34c05093a..ead4e98e708 100644
> --- a/meta/recipes-connectivity/kea/kea_3.0.1.bb
> +++ b/meta/recipes-connectivity/kea/kea_3.0.1.bb
> @@ -34,16 +34,6 @@ INITSCRIPT_PARAMS = "defaults 30"
>  SYSTEMD_SERVICE:${PN} = "kea-dhcp4.service kea-dhcp6.service kea-dhcp-ddns.service"
>  SYSTEMD_AUTO_ENABLE = "disable"
> 
> -DEBUG_OPTIMIZATION:remove:mips = " -Og"
> -DEBUG_OPTIMIZATION:append:mips = " -O"
> -BUILD_OPTIMIZATION:remove:mips = " -Og"
> -BUILD_OPTIMIZATION:append:mips = " -O"
> -
> -DEBUG_OPTIMIZATION:remove:mipsel = " -Og"
> -DEBUG_OPTIMIZATION:append:mipsel = " -O"
> -BUILD_OPTIMIZATION:remove:mipsel = " -Og"
> -BUILD_OPTIMIZATION:append:mipsel = " -O"
> -
>  CXXFLAGS:remove = "-fvisibility-inlines-hidden"
> 
>  do_configure:prepend() {
> diff --git a/meta/recipes-devtools/debugedit/debugedit_5.2.bb b/meta/recipes-devtools/debugedit/debugedit_5.2.bb
> index 76c54ba63d4..4ac6cab559e 100644
> --- a/meta/recipes-devtools/debugedit/debugedit_5.2.bb
> +++ b/meta/recipes-devtools/debugedit/debugedit_5.2.bb
> @@ -22,8 +22,6 @@ inherit pkgconfig autotools multilib_script
> 
>  RDEPENDS:${PN} += "bash elfutils-binutils"
> 
> -EXTRA_OECONF = "${@oe.utils.vartrue('DEBUG_BUILD', '--disable-inlined-xxhash', '', d)}"
> -
>  BBCLASSEXTEND = "native nativesdk"
> 
>  MULTILIB_SCRIPTS = "${PN}:${bindir}/find-debuginfo"
> diff --git a/meta/recipes-devtools/gcc/gcc-sanitizers.inc b/meta/recipes-devtools/gcc/gcc-sanitizers.inc
> index 6c81d302438..f4727ee6dba 100644
> --- a/meta/recipes-devtools/gcc/gcc-sanitizers.inc
> +++ b/meta/recipes-devtools/gcc/gcc-sanitizers.inc
> @@ -54,9 +54,6 @@ INHIBIT_DEFAULT_DEPS = "1"
>  ALLOW_EMPTY:${PN} = "1"
>  DEPENDS = "virtual/crypt gcc-runtime virtual/cross-cc"
> 
> -# used to fix ../../../../../../../../../work-shared/gcc-8.3.0-r0/gcc-8.3.0/libsanitizer/libbacktrace/../../libbacktrace/elf.c:772:21: error: 'st.st_mode' may be used uninitialized in this function [-Werror=maybe-uninitialized]
> -DEBUG_OPTIMIZATION:append = " -Wno-error"
> -
>  BBCLASSEXTEND = "nativesdk"
> 
>  PACKAGES = "${PN} ${PN}-dbg"
> diff --git a/meta/recipes-devtools/python/python3-lxml_6.0.1.bb b/meta/recipes-devtools/python/python3-lxml_6.0.1.bb
> index 5d76641675c..6bcd399da54 100644
> --- a/meta/recipes-devtools/python/python3-lxml_6.0.1.bb
> +++ b/meta/recipes-devtools/python/python3-lxml_6.0.1.bb
> @@ -23,18 +23,6 @@ SRC_URI[sha256sum] = "2b3a882ebf27dd026df3801a87cf49ff791336e0f94b0fad195db77e01
>  SRC_URI += "${PYPI_SRC_URI}"
>  inherit pkgconfig pypi setuptools3
> 
> -# {standard input}: Assembler messages:
> -# {standard input}:1488805: Error: branch out of range
> -DEBUG_OPTIMIZATION:remove:mips = " -Og"
> -DEBUG_OPTIMIZATION:append:mips = " -O"
> -BUILD_OPTIMIZATION:remove:mips = " -Og"
> -BUILD_OPTIMIZATION:append:mips = " -O"
> -
> -DEBUG_OPTIMIZATION:remove:mipsel = " -Og"
> -DEBUG_OPTIMIZATION:append:mipsel = " -O"
> -BUILD_OPTIMIZATION:remove:mipsel = " -Og"
> -BUILD_OPTIMIZATION:append:mipsel = " -O"
> -
>  BBCLASSEXTEND = "native nativesdk"
> 
>  RDEPENDS:${PN} += "libxml2 libxslt python3-compression"
> diff --git a/meta/recipes-extended/bash/bash_5.3.bb b/meta/recipes-extended/bash/bash_5.3.bb
> index b50a48d28c9..74671f5a563 100644
> --- a/meta/recipes-extended/bash/bash_5.3.bb
> +++ b/meta/recipes-extended/bash/bash_5.3.bb
> @@ -15,9 +15,6 @@ SRC_URI = "${GNU_MIRROR}/bash/${BP}.tar.gz;name=tarball \
> 
>  SRC_URI[tarball.sha256sum] = "0d5cd86965f869a26cf64f4b71be7b96f90a3ba8b3d74e27e8e9d9d5550f31ba"
> 
> -DEBUG_OPTIMIZATION:append:armv4 = " ${@bb.utils.contains('TUNE_CCARGS', '-mthumb', '-fomit-frame-pointer', '', d)}"
> -DEBUG_OPTIMIZATION:append:armv5 = " ${@bb.utils.contains('TUNE_CCARGS', '-mthumb', '-fomit-frame-pointer', '', d)}"
> -
>  CFLAGS += "-std=gnu17"
>  # mkbuiltins.c is built with native toolchain and needs gnu17 as well:
>  # http://errors.yoctoproject.org/Errors/Details/853016/
> diff --git a/meta/recipes-extended/mdadm/mdadm_4.4.bb b/meta/recipes-extended/mdadm/mdadm_4.4.bb
> index 26a60e4c1a3..e81b8fdf3cb 100644
> --- a/meta/recipes-extended/mdadm/mdadm_4.4.bb
> +++ b/meta/recipes-extended/mdadm/mdadm_4.4.bb
> @@ -39,8 +39,6 @@ EXTRA_OEMAKE = 'CHECK_RUN_DIR=0 CWFLAGS="" CXFLAGS="${CFLAGS}" SYSTEMD_DIR=${sys
>                  BINDIR="${base_sbindir}" UDEVDIR="${nonarch_base_libdir}/udev" LDFLAGS="${LDFLAGS}" \
>                  SYSROOT="${STAGING_DIR_TARGET}" STRIP='
> 
> -DEBUG_OPTIMIZATION:append = " -Wno-error"
> -
>  do_install() {
>          oe_runmake 'DESTDIR=${D}' install install-systemd
>          install -d ${D}/${sysconfdir}/
> diff --git a/meta/recipes-graphics/jpeg/libjpeg-turbo_3.1.2.bb b/meta/recipes-graphics/jpeg/libjpeg-turbo_3.1.2.bb
> index d4877bb92b5..bc9d803f6b9 100644
> --- a/meta/recipes-graphics/jpeg/libjpeg-turbo_3.1.2.bb
> +++ b/meta/recipes-graphics/jpeg/libjpeg-turbo_3.1.2.bb
> @@ -44,9 +44,6 @@ EXTRA_OECMAKE:append:class-target:powerpc = " ${@bb.utils.contains("TUNE_FEATURE
>  EXTRA_OECMAKE:append:class-target:powerpc64 = " ${@bb.utils.contains("TUNE_FEATURES", "altivec", "", "-DWITH_SIMD=False", d)}"
>  EXTRA_OECMAKE:append:class-target:powerpc64le = " ${@bb.utils.contains("TUNE_FEATURES", "altivec", "", "-DWITH_SIMD=False", d)}"
> 
> -DEBUG_OPTIMIZATION:append:armv4 = " ${@bb.utils.contains('TUNE_CCARGS', '-mthumb', '-fomit-frame-pointer', '', d)}"
> -DEBUG_OPTIMIZATION:append:armv5 = " ${@bb.utils.contains('TUNE_CCARGS', '-mthumb', '-fomit-frame-pointer', '', d)}"
> -
>  # libjpeg-turbo-2.0.2/simd/mips/jsimd_dspr2.S
>  # <instantiation>:13:5: error: invalid token in expression
>  # .if $17 != 0
> diff --git a/meta/recipes-graphics/vulkan/vulkan-validation-layers_1.4.321.0.bb b/meta/recipes-graphics/vulkan/vulkan-validation-layers_1.4.321.0.bb
> index 466e757a908..fa7873b62d3 100644
> --- a/meta/recipes-graphics/vulkan/vulkan-validation-layers_1.4.321.0.bb
> +++ b/meta/recipes-graphics/vulkan/vulkan-validation-layers_1.4.321.0.bb
> @@ -26,8 +26,6 @@ EXTRA_OECMAKE = "\
>      -DSPIRV_HEADERS_INSTALL_DIR=${STAGING_EXECPREFIXDIR} \
>      "
> 
> -CXXFLAGS:append = " ${@oe.utils.vartrue('DEBUG_BUILD', '-DXXH_NO_INLINE_HINTS=1', '', d)}"
> -
>  PACKAGECONFIG[x11] = "-DBUILD_WSI_XLIB_SUPPORT=ON -DBUILD_WSI_XCB_SUPPORT=ON, -DBUILD_WSI_XLIB_SUPPORT=OFF -DBUILD_WSI_XCB_SUPPORT=OFF, libxcb libx11 libxrandr"
>  PACKAGECONFIG[wayland] = "-DBUILD_WSI_WAYLAND_SUPPORT=ON, -DBUILD_WSI_WAYLAND_SUPPORT=OFF, wayland"
> 
> diff --git a/meta/recipes-kernel/lttng/lttng-ust_2.14.0.bb b/meta/recipes-kernel/lttng/lttng-ust_2.14.0.bb
> index 1a15c5b4201..0d4c67f0fa7 100644
> --- a/meta/recipes-kernel/lttng/lttng-ust_2.14.0.bb
> +++ b/meta/recipes-kernel/lttng/lttng-ust_2.14.0.bb
> @@ -16,7 +16,6 @@ inherit autotools lib_package manpages python3native pkgconfig
>  include lttng-platforms.inc
> 
>  EXTRA_OECONF = "--disable-numa"
> -CPPFLAGS:append:arm = "${@oe.utils.vartrue('DEBUG_BUILD', '-DUATOMIC_NO_LINK_ERROR', '', d)}"
> 
>  DEPENDS = "liburcu util-linux"
>  RDEPENDS:${PN}-bin = "python3-core"
> diff --git a/meta/recipes-kernel/perf/perf.bb b/meta/recipes-kernel/perf/perf.bb
> index e1915207eed..98dffd1cc99 100644
> --- a/meta/recipes-kernel/perf/perf.bb
> +++ b/meta/recipes-kernel/perf/perf.bb
> @@ -415,8 +415,6 @@ FILES:${PN}-python = " \
>                         "
>  FILES:${PN}-perl = "${libexecdir}/perf-core/scripts/perl"
> 
> -DEBUG_OPTIMIZATION:append = " -Wno-error=maybe-uninitialized"
> -
>  PACKAGESPLITFUNCS =+ "perf_fix_sources"
> 
>  perf_fix_sources () {
> diff --git a/meta/recipes-sato/webkit/webkitgtk_2.48.5.bb b/meta/recipes-
> sato/webkit/webkitgtk_2.48.5.bb
> index 46031322b92..616cd353337 100644
> --- a/meta/recipes-sato/webkit/webkitgtk_2.48.5.bb
> +++ b/meta/recipes-sato/webkit/webkitgtk_2.48.5.bb
> @@ -90,7 +90,7 @@ EXTRA_OECMAKE = " \
>                   -DPORT=GTK \
>                   ${@oe.utils.vartrue('GI_DATA_ENABLED', '-DENABLE_INTROSPECTION=ON', '-DENABLE_INTROSPECTION=OFF', d)} \
>                   ${@oe.utils.vartrue('GIDOCGEN_ENABLED', '-DENABLE_DOCUMENTATION=ON', '-DENABLE_DOCUMENTATION=OFF', d)} \
> -                 ${@oe.utils.vartrue('DEBUG_BUILD', '-DWEBKIT_NO_INLINE_HINTS=ON', '-DWEBKIT_NO_INLINE_HINTS=OFF', d)} \
> +                 -DWEBKIT_NO_INLINE_HINTS=OFF \
>                   -DENABLE_MINIBROWSER=ON \
>                   -DENABLE_BUBBLEWRAP_SANDBOX=OFF \
>                   -DUSE_GTK4=ON \
> diff --git a/meta/recipes-support/vim/vim_9.1.bb b/meta/recipes-support/vim/vim_9.1.bb
> index fee9f055e9a..a24a863ba5c 100644
> --- a/meta/recipes-support/vim/vim_9.1.bb
> +++ b/meta/recipes-support/vim/vim_9.1.bb
> @@ -20,4 +20,4 @@ ALTERNATIVE_LINK_NAME[xxd] = "${bindir}/xxd"
>  # We override the default in security_flags.inc because vim (not vim-tiny!) will abort
>  # in many places for _FORTIFY_SOURCE=2.  Security flags become part of CC.
>  #
> -lcl_maybe_fortify = "${@oe.utils.conditional('DEBUG_BUILD','1','','-D_FORTIFY_SOURCE=1',d)}"
> +lcl_maybe_fortify = "-D_FORTIFY_SOURCE=1"
> --
> 2.34.1

//Peter
diff mbox series

Patch

diff --git a/meta/conf/bitbake.conf b/meta/conf/bitbake.conf
index 8e90c7bbc85..193a8377cf2 100644
--- a/meta/conf/bitbake.conf
+++ b/meta/conf/bitbake.conf
@@ -831,6 +831,8 @@  include conf/licenses.conf
 require conf/sanity.conf
 include conf/bblock.conf
 
+require ${@oe.utils.vartrue('DEBUG_BUILD', 'conf/distro/include/debug_build_tune.inc', '', d)}
+
 ##################################################################
 # Weak variables (usually to retain backwards compatibility)
 ##################################################################
diff --git a/meta/conf/distro/include/debug_build_tune.inc b/meta/conf/distro/include/debug_build_tune.inc
new file mode 100644
index 00000000000..ca43d2b955c
--- /dev/null
+++ b/meta/conf/distro/include/debug_build_tune.inc
@@ -0,0 +1,45 @@ 
+# The modern compilers and code seem to require extra steps to avoid DEBUG errors,
+# this file collects debug tuning configuration to address DEBUG errors.
+
+DEBUG_OPTIMIZATION:append:pn-perf = " -Wno-error=maybe-uninitialized"
+DEBUG_OPTIMIZATION:append:armv4:pn-libjpeg-turbo = " ${@bb.utils.contains('TUNE_CCARGS', '-mthumb', '-fomit-frame-pointer', '', d)}"
+DEBUG_OPTIMIZATION:append:armv5:pn-libjpeg-turbo = " ${@bb.utils.contains('TUNE_CCARGS', '-mthumb', '-fomit-frame-pointer', '', d)}"
+DEBUG_OPTIMIZATION:append:armv4:pn-bash = " ${@bb.utils.contains('TUNE_CCARGS', '-mthumb', '-fomit-frame-pointer', '', d)}"
+DEBUG_OPTIMIZATION:append:armv5:pn-bash = " ${@bb.utils.contains('TUNE_CCARGS', '-mthumb', '-fomit-frame-pointer', '', d)}"
+DEBUG_OPTIMIZATION:append:pn-mdadm = " -Wno-error"
+DEBUG_OPTIMIZATION:remove:mips:pn-kea = " -Og"
+DEBUG_OPTIMIZATION:append:mips:pn-kea = " -O"
+DEBUG_OPTIMIZATION:remove:mipsel:pn-kea = " -Og"
+DEBUG_OPTIMIZATION:append:mipsel:pn-kea = " -O"
+# {standard input}: Assembler messages:
+# {standard input}:1488805: Error: branch out of range
+DEBUG_OPTIMIZATION:remove:mips:pn-python3-lxml = " -Og"
+DEBUG_OPTIMIZATION:append:mips:pn-python3-lxml = " -O"
+DEBUG_OPTIMIZATION:remove:mipsel:pn-python3-lxml = " -Og"
+DEBUG_OPTIMIZATION:append:mipsel:pn-python3-lxml = " -O"
+# used to fix ../../../../../../../../../work-shared/gcc-8.3.0-r0/gcc-8.3.0/libsanitizer/libbacktrace/../../libbacktrace/elf.c:772:21: error: 'st.st_mode' may be used uninitialized in this function [-Werror=maybe-uninitialized]
+DEBUG_OPTIMIZATION:append:pn-gcc-sanitizers = " -Wno-error"
+
+BUILD_OPTIMIZATION:remove:mips:pn-kea = " -Og"
+BUILD_OPTIMIZATION:append:mips:pn-kea = " -O"
+BUILD_OPTIMIZATION:remove:mipsel:pn-kea = " -Og"
+BUILD_OPTIMIZATION:append:mipsel:pn-kea = " -O"
+# {standard input}: Assembler messages:
+# {standard input}:1488805: Error: branch out of range
+BUILD_OPTIMIZATION:remove:mips:pn-python3-lxml = " -Og"
+BUILD_OPTIMIZATION:append:mips:pn-python3-lxml = " -O"
+BUILD_OPTIMIZATION:remove:mipsel:pn-python3-lxml = " -Og"
+BUILD_OPTIMIZATION:append:mipsel:pn-python3-lxml = " -O"
+
+CPPFLAGS:append:arm::pn-lttng-ust = " -DUATOMIC_NO_LINK_ERROR"
+
+EXTRA_OECMAKE:remove:pn-webkitgtk = "-DWEBKIT_NO_INLINE_HINTS=OFF"
+EXTRA_OECMAKE:append:pn-webkitgtk = " -DWEBKIT_NO_INLINE_HINTS=ON"
+
+EXTRA_OECONF:pn-debugedit = "--disable-inlined-xxhash"
+EXTRA_OECONF:pn-debugedit-native = "--disable-inlined-xxhash"
+EXTRA_OECONF:pn-nativesdk-debugedit = "--disable-inlined-xxhash"
+
+lcl_maybe_fortify:pn-vim = ""
+
+CXXFLAGS:append:pn-vulkan-validation-layers = " -DXXH_NO_INLINE_HINTS=1"
diff --git a/meta/recipes-connectivity/kea/kea_3.0.1.bb b/meta/recipes-connectivity/kea/kea_3.0.1.bb
index cc34c05093a..ead4e98e708 100644
--- a/meta/recipes-connectivity/kea/kea_3.0.1.bb
+++ b/meta/recipes-connectivity/kea/kea_3.0.1.bb
@@ -34,16 +34,6 @@  INITSCRIPT_PARAMS = "defaults 30"
 SYSTEMD_SERVICE:${PN} = "kea-dhcp4.service kea-dhcp6.service kea-dhcp-ddns.service"
 SYSTEMD_AUTO_ENABLE = "disable"
 
-DEBUG_OPTIMIZATION:remove:mips = " -Og"
-DEBUG_OPTIMIZATION:append:mips = " -O"
-BUILD_OPTIMIZATION:remove:mips = " -Og"
-BUILD_OPTIMIZATION:append:mips = " -O"
-
-DEBUG_OPTIMIZATION:remove:mipsel = " -Og"
-DEBUG_OPTIMIZATION:append:mipsel = " -O"
-BUILD_OPTIMIZATION:remove:mipsel = " -Og"
-BUILD_OPTIMIZATION:append:mipsel = " -O"
-
 CXXFLAGS:remove = "-fvisibility-inlines-hidden"
 
 do_configure:prepend() {
diff --git a/meta/recipes-devtools/debugedit/debugedit_5.2.bb b/meta/recipes-devtools/debugedit/debugedit_5.2.bb
index 76c54ba63d4..4ac6cab559e 100644
--- a/meta/recipes-devtools/debugedit/debugedit_5.2.bb
+++ b/meta/recipes-devtools/debugedit/debugedit_5.2.bb
@@ -22,8 +22,6 @@  inherit pkgconfig autotools multilib_script
 
 RDEPENDS:${PN} += "bash elfutils-binutils"
 
-EXTRA_OECONF = "${@oe.utils.vartrue('DEBUG_BUILD', '--disable-inlined-xxhash', '', d)}"
-
 BBCLASSEXTEND = "native nativesdk"
 
 MULTILIB_SCRIPTS = "${PN}:${bindir}/find-debuginfo"
diff --git a/meta/recipes-devtools/gcc/gcc-sanitizers.inc b/meta/recipes-devtools/gcc/gcc-sanitizers.inc
index 6c81d302438..f4727ee6dba 100644
--- a/meta/recipes-devtools/gcc/gcc-sanitizers.inc
+++ b/meta/recipes-devtools/gcc/gcc-sanitizers.inc
@@ -54,9 +54,6 @@  INHIBIT_DEFAULT_DEPS = "1"
 ALLOW_EMPTY:${PN} = "1"
 DEPENDS = "virtual/crypt gcc-runtime virtual/cross-cc"
 
-# used to fix ../../../../../../../../../work-shared/gcc-8.3.0-r0/gcc-8.3.0/libsanitizer/libbacktrace/../../libbacktrace/elf.c:772:21: error: 'st.st_mode' may be used uninitialized in this function [-Werror=maybe-uninitialized]
-DEBUG_OPTIMIZATION:append = " -Wno-error"
-
 BBCLASSEXTEND = "nativesdk"
 
 PACKAGES = "${PN} ${PN}-dbg"
diff --git a/meta/recipes-devtools/python/python3-lxml_6.0.1.bb b/meta/recipes-devtools/python/python3-lxml_6.0.1.bb
index 5d76641675c..6bcd399da54 100644
--- a/meta/recipes-devtools/python/python3-lxml_6.0.1.bb
+++ b/meta/recipes-devtools/python/python3-lxml_6.0.1.bb
@@ -23,18 +23,6 @@  SRC_URI[sha256sum] = "2b3a882ebf27dd026df3801a87cf49ff791336e0f94b0fad195db77e01
 SRC_URI += "${PYPI_SRC_URI}"
 inherit pkgconfig pypi setuptools3
 
-# {standard input}: Assembler messages:
-# {standard input}:1488805: Error: branch out of range
-DEBUG_OPTIMIZATION:remove:mips = " -Og"
-DEBUG_OPTIMIZATION:append:mips = " -O"
-BUILD_OPTIMIZATION:remove:mips = " -Og"
-BUILD_OPTIMIZATION:append:mips = " -O"
-
-DEBUG_OPTIMIZATION:remove:mipsel = " -Og"
-DEBUG_OPTIMIZATION:append:mipsel = " -O"
-BUILD_OPTIMIZATION:remove:mipsel = " -Og"
-BUILD_OPTIMIZATION:append:mipsel = " -O"
-
 BBCLASSEXTEND = "native nativesdk"
 
 RDEPENDS:${PN} += "libxml2 libxslt python3-compression"
diff --git a/meta/recipes-extended/bash/bash_5.3.bb b/meta/recipes-extended/bash/bash_5.3.bb
index b50a48d28c9..74671f5a563 100644
--- a/meta/recipes-extended/bash/bash_5.3.bb
+++ b/meta/recipes-extended/bash/bash_5.3.bb
@@ -15,9 +15,6 @@  SRC_URI = "${GNU_MIRROR}/bash/${BP}.tar.gz;name=tarball \
 
 SRC_URI[tarball.sha256sum] = "0d5cd86965f869a26cf64f4b71be7b96f90a3ba8b3d74e27e8e9d9d5550f31ba"
 
-DEBUG_OPTIMIZATION:append:armv4 = " ${@bb.utils.contains('TUNE_CCARGS', '-mthumb', '-fomit-frame-pointer', '', d)}"
-DEBUG_OPTIMIZATION:append:armv5 = " ${@bb.utils.contains('TUNE_CCARGS', '-mthumb', '-fomit-frame-pointer', '', d)}"
-
 CFLAGS += "-std=gnu17"
 # mkbuiltins.c is built with native toolchain and needs gnu17 as well:
 # http://errors.yoctoproject.org/Errors/Details/853016/
diff --git a/meta/recipes-extended/mdadm/mdadm_4.4.bb b/meta/recipes-extended/mdadm/mdadm_4.4.bb
index 26a60e4c1a3..e81b8fdf3cb 100644
--- a/meta/recipes-extended/mdadm/mdadm_4.4.bb
+++ b/meta/recipes-extended/mdadm/mdadm_4.4.bb
@@ -39,8 +39,6 @@  EXTRA_OEMAKE = 'CHECK_RUN_DIR=0 CWFLAGS="" CXFLAGS="${CFLAGS}" SYSTEMD_DIR=${sys
                 BINDIR="${base_sbindir}" UDEVDIR="${nonarch_base_libdir}/udev" LDFLAGS="${LDFLAGS}" \
                 SYSROOT="${STAGING_DIR_TARGET}" STRIP='
 
-DEBUG_OPTIMIZATION:append = " -Wno-error"
-
 do_install() {
         oe_runmake 'DESTDIR=${D}' install install-systemd
         install -d ${D}/${sysconfdir}/
diff --git a/meta/recipes-graphics/jpeg/libjpeg-turbo_3.1.2.bb b/meta/recipes-graphics/jpeg/libjpeg-turbo_3.1.2.bb
index d4877bb92b5..bc9d803f6b9 100644
--- a/meta/recipes-graphics/jpeg/libjpeg-turbo_3.1.2.bb
+++ b/meta/recipes-graphics/jpeg/libjpeg-turbo_3.1.2.bb
@@ -44,9 +44,6 @@  EXTRA_OECMAKE:append:class-target:powerpc = " ${@bb.utils.contains("TUNE_FEATURE
 EXTRA_OECMAKE:append:class-target:powerpc64 = " ${@bb.utils.contains("TUNE_FEATURES", "altivec", "", "-DWITH_SIMD=False", d)}"
 EXTRA_OECMAKE:append:class-target:powerpc64le = " ${@bb.utils.contains("TUNE_FEATURES", "altivec", "", "-DWITH_SIMD=False", d)}"
 
-DEBUG_OPTIMIZATION:append:armv4 = " ${@bb.utils.contains('TUNE_CCARGS', '-mthumb', '-fomit-frame-pointer', '', d)}"
-DEBUG_OPTIMIZATION:append:armv5 = " ${@bb.utils.contains('TUNE_CCARGS', '-mthumb', '-fomit-frame-pointer', '', d)}"
-
 # libjpeg-turbo-2.0.2/simd/mips/jsimd_dspr2.S
 # <instantiation>:13:5: error: invalid token in expression
 # .if $17 != 0
diff --git a/meta/recipes-graphics/vulkan/vulkan-validation-layers_1.4.321.0.bb b/meta/recipes-graphics/vulkan/vulkan-validation-layers_1.4.321.0.bb
index 466e757a908..fa7873b62d3 100644
--- a/meta/recipes-graphics/vulkan/vulkan-validation-layers_1.4.321.0.bb
+++ b/meta/recipes-graphics/vulkan/vulkan-validation-layers_1.4.321.0.bb
@@ -26,8 +26,6 @@  EXTRA_OECMAKE = "\
     -DSPIRV_HEADERS_INSTALL_DIR=${STAGING_EXECPREFIXDIR} \
     "
 
-CXXFLAGS:append = " ${@oe.utils.vartrue('DEBUG_BUILD', '-DXXH_NO_INLINE_HINTS=1', '', d)}"
-
 PACKAGECONFIG[x11] = "-DBUILD_WSI_XLIB_SUPPORT=ON -DBUILD_WSI_XCB_SUPPORT=ON, -DBUILD_WSI_XLIB_SUPPORT=OFF -DBUILD_WSI_XCB_SUPPORT=OFF, libxcb libx11 libxrandr"
 PACKAGECONFIG[wayland] = "-DBUILD_WSI_WAYLAND_SUPPORT=ON, -DBUILD_WSI_WAYLAND_SUPPORT=OFF, wayland"
 
diff --git a/meta/recipes-kernel/lttng/lttng-ust_2.14.0.bb b/meta/recipes-kernel/lttng/lttng-ust_2.14.0.bb
index 1a15c5b4201..0d4c67f0fa7 100644
--- a/meta/recipes-kernel/lttng/lttng-ust_2.14.0.bb
+++ b/meta/recipes-kernel/lttng/lttng-ust_2.14.0.bb
@@ -16,7 +16,6 @@  inherit autotools lib_package manpages python3native pkgconfig
 include lttng-platforms.inc
 
 EXTRA_OECONF = "--disable-numa"
-CPPFLAGS:append:arm = "${@oe.utils.vartrue('DEBUG_BUILD', '-DUATOMIC_NO_LINK_ERROR', '', d)}"
 
 DEPENDS = "liburcu util-linux"
 RDEPENDS:${PN}-bin = "python3-core"
diff --git a/meta/recipes-kernel/perf/perf.bb b/meta/recipes-kernel/perf/perf.bb
index e1915207eed..98dffd1cc99 100644
--- a/meta/recipes-kernel/perf/perf.bb
+++ b/meta/recipes-kernel/perf/perf.bb
@@ -415,8 +415,6 @@  FILES:${PN}-python = " \
                        "
 FILES:${PN}-perl = "${libexecdir}/perf-core/scripts/perl"
 
-DEBUG_OPTIMIZATION:append = " -Wno-error=maybe-uninitialized"
-
 PACKAGESPLITFUNCS =+ "perf_fix_sources"
 
 perf_fix_sources () {
diff --git a/meta/recipes-sato/webkit/webkitgtk_2.48.5.bb b/meta/recipes-sato/webkit/webkitgtk_2.48.5.bb
index 46031322b92..616cd353337 100644
--- a/meta/recipes-sato/webkit/webkitgtk_2.48.5.bb
+++ b/meta/recipes-sato/webkit/webkitgtk_2.48.5.bb
@@ -90,7 +90,7 @@  EXTRA_OECMAKE = " \
                  -DPORT=GTK \
                  ${@oe.utils.vartrue('GI_DATA_ENABLED', '-DENABLE_INTROSPECTION=ON', '-DENABLE_INTROSPECTION=OFF', d)} \
                  ${@oe.utils.vartrue('GIDOCGEN_ENABLED', '-DENABLE_DOCUMENTATION=ON', '-DENABLE_DOCUMENTATION=OFF', d)} \
-                 ${@oe.utils.vartrue('DEBUG_BUILD', '-DWEBKIT_NO_INLINE_HINTS=ON', '-DWEBKIT_NO_INLINE_HINTS=OFF', d)} \
+                 -DWEBKIT_NO_INLINE_HINTS=OFF \
                  -DENABLE_MINIBROWSER=ON \
                  -DENABLE_BUBBLEWRAP_SANDBOX=OFF \
                  -DUSE_GTK4=ON \
diff --git a/meta/recipes-support/vim/vim_9.1.bb b/meta/recipes-support/vim/vim_9.1.bb
index fee9f055e9a..a24a863ba5c 100644
--- a/meta/recipes-support/vim/vim_9.1.bb
+++ b/meta/recipes-support/vim/vim_9.1.bb
@@ -20,4 +20,4 @@  ALTERNATIVE_LINK_NAME[xxd] = "${bindir}/xxd"
 # We override the default in security_flags.inc because vim (not vim-tiny!) will abort
 # in many places for _FORTIFY_SOURCE=2.  Security flags become part of CC.
 #
-lcl_maybe_fortify = "${@oe.utils.conditional('DEBUG_BUILD','1','','-D_FORTIFY_SOURCE=1',d)}"
+lcl_maybe_fortify = "-D_FORTIFY_SOURCE=1"