summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHongxu Jia <hongxu.jia@windriver.com>2025-10-10 15:52:54 +0800
committerRichard Purdie <richard.purdie@linuxfoundation.org>2025-11-07 13:15:35 +0000
commit1689392ea5b75f57c0789169b86d1745fe7769b5 (patch)
treedd1948de8dbc646ed8b9fd730e71abcc1760d305
parentadf7b710d781600e4bb7e65e93a2fa6e3046dd6c (diff)
downloadpoky-1689392ea5b75f57c0789169b86d1745fe7769b5.tar.gz
distro/include: Add debug_build.inc when DEBUG_BUILD is enabled
In bitbake.conf, use ??= to set *_OPTIMIZATION, add a new include file debug_build.inc to use ?= to override *_OPTIMIZATION when DEBUG_BUILD is enabled When DEBUG_BUILD is enabled: - Defer inherit bblcass debug_build, while setting DEBUG_BUILD = "1" in local.conf, the debug build is enabled globally. For the recipe (such as qemu) which doesn't work without optimization, set DEBUG_BUILD = "0" to disable it for a given recipe - Use include_all to allow other layers to add their own debug build configurations Suggested-by: Peter Kjellerstedt <peter.kjellerstedt@axis.com> (From OE-Core rev: 36144bdd5e25da9a523c68174d110013968e0fdf) Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com> Signed-off-by: Mathieu Dubois-Briand <mathieu.dubois-briand@bootlin.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--meta/classes-global/base.bbclass3
-rw-r--r--meta/classes-recipe/debug_build.bbclass8
-rw-r--r--meta/conf/bitbake.conf9
-rw-r--r--meta/conf/distro/include/debug_build.inc5
-rw-r--r--meta/conf/documentation.conf2
5 files changed, 20 insertions, 7 deletions
diff --git a/meta/classes-global/base.bbclass b/meta/classes-global/base.bbclass
index cf303c237a..7f85de3168 100644
--- a/meta/classes-global/base.bbclass
+++ b/meta/classes-global/base.bbclass
@@ -35,6 +35,9 @@ TOOLCHAIN_NATIVE ??= "${PREFERRED_TOOLCHAIN_NATIVE}"
35inherit_defer toolchain/${TOOLCHAIN_NATIVE}-native 35inherit_defer toolchain/${TOOLCHAIN_NATIVE}-native
36inherit_defer toolchain/${TOOLCHAIN} 36inherit_defer toolchain/${TOOLCHAIN}
37 37
38DEBUG_BUILD ??= "0"
39inherit_defer ${@oe.utils.vartrue('DEBUG_BUILD', 'debug_build', '', d)}
40
38def lsb_distro_identifier(d): 41def lsb_distro_identifier(d):
39 adjust = d.getVar('LSB_DISTRO_ADJUST') 42 adjust = d.getVar('LSB_DISTRO_ADJUST')
40 adjust_func = None 43 adjust_func = None
diff --git a/meta/classes-recipe/debug_build.bbclass b/meta/classes-recipe/debug_build.bbclass
new file mode 100644
index 0000000000..a917e9cbc9
--- /dev/null
+++ b/meta/classes-recipe/debug_build.bbclass
@@ -0,0 +1,8 @@
1#
2# Copyright OpenEmbedded Contributors
3#
4# SPDX-License-Identifier: MIT
5#
6
7# Allow other layers to add their own debug build configurations
8include_all conf/distro/include/debug_build.inc
diff --git a/meta/conf/bitbake.conf b/meta/conf/bitbake.conf
index 5406e542db..52ceb76bbb 100644
--- a/meta/conf/bitbake.conf
+++ b/meta/conf/bitbake.conf
@@ -658,13 +658,10 @@ DEBUG_PREFIX_MAP ?= "\
658" 658"
659DEBUG_LEVELFLAG ?= "-g" 659DEBUG_LEVELFLAG ?= "-g"
660 660
661FULL_OPTIMIZATION = "-O2 ${DEBUG_LEVELFLAG}" 661FULL_OPTIMIZATION ??= "-O2 ${DEBUG_LEVELFLAG}"
662DEBUG_OPTIMIZATION = "-Og ${DEBUG_LEVELFLAG}" 662SELECTED_OPTIMIZATION ??= "${FULL_OPTIMIZATION}"
663SELECTED_OPTIMIZATION = "${@d.getVar(oe.utils.vartrue('DEBUG_BUILD', 'DEBUG_OPTIMIZATION', 'FULL_OPTIMIZATION', d))}"
664SELECTED_OPTIMIZATION[vardeps] += "FULL_OPTIMIZATION DEBUG_OPTIMIZATION DEBUG_BUILD"
665# compiler flags for native/nativesdk 663# compiler flags for native/nativesdk
666BUILD_OPTIMIZATION = "${@oe.utils.vartrue('DEBUG_BUILD', '-Og -g', '-O2', d)}" 664BUILD_OPTIMIZATION ??= "-O2"
667BUILD_OPTIMIZATION[vardeps] += "DEBUG_BUILD"
668 665
669################################################################## 666##################################################################
670# Reproducibility 667# Reproducibility
diff --git a/meta/conf/distro/include/debug_build.inc b/meta/conf/distro/include/debug_build.inc
new file mode 100644
index 0000000000..95e09e64f5
--- /dev/null
+++ b/meta/conf/distro/include/debug_build.inc
@@ -0,0 +1,5 @@
1# Override SELECTED_OPTIMIZATION and BUILD_OPTIMIZATION when DEBUG_BUILD is enabled.
2DEBUG_OPTIMIZATION ?= "-Og ${DEBUG_LEVELFLAG}"
3SELECTED_OPTIMIZATION ?= "${DEBUG_OPTIMIZATION}"
4# compiler flags for native/nativesdk
5BUILD_OPTIMIZATION ?= "-Og -g"
diff --git a/meta/conf/documentation.conf b/meta/conf/documentation.conf
index 741130a392..2a7418ccb3 100644
--- a/meta/conf/documentation.conf
+++ b/meta/conf/documentation.conf
@@ -129,7 +129,7 @@ CVE_CHECK_LAYER_INCLUDELIST[doc] = "Defines which layers to include during cve-c
129D[doc] = "The destination directory." 129D[doc] = "The destination directory."
130DATE[doc] = "The date the build was started using YMD format." 130DATE[doc] = "The date the build was started using YMD format."
131DATETIME[doc] = "The date and time the build was started." 131DATETIME[doc] = "The date and time the build was started."
132DEBUG_BUILD[doc] = "Specifies to build packages with debugging information. This influences the value of the SELECTED_OPTIMIZATION variable." 132DEBUG_BUILD[doc] = "Specifies to build packages with debugging information. This influences the value of the SELECTED_OPTIMIZATION variable and includes file conf/distro/include/debug_build.inc"
133DEBUG_OPTIMIZATION[doc] = "The options to pass in TARGET_CFLAGS and CFLAGS when compiling a system for debugging. This variable defaults to '-Og ${DEBUG_LEVELFLAG}'." 133DEBUG_OPTIMIZATION[doc] = "The options to pass in TARGET_CFLAGS and CFLAGS when compiling a system for debugging. This variable defaults to '-Og ${DEBUG_LEVELFLAG}'."
134DEFAULT_PREFERENCE[doc] = "Specifies a weak bias for recipe selection priority." 134DEFAULT_PREFERENCE[doc] = "Specifies a weak bias for recipe selection priority."
135DEPENDS[doc] = "Lists a recipe's build-time dependencies (i.e. other recipe files)." 135DEPENDS[doc] = "Lists a recipe's build-time dependencies (i.e. other recipe files)."