diff options
| author | Hongxu Jia <hongxu.jia@windriver.com> | 2025-10-10 15:52:54 +0800 |
|---|---|---|
| committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2025-11-07 13:15:35 +0000 |
| commit | 1689392ea5b75f57c0789169b86d1745fe7769b5 (patch) | |
| tree | dd1948de8dbc646ed8b9fd730e71abcc1760d305 | |
| parent | adf7b710d781600e4bb7e65e93a2fa6e3046dd6c (diff) | |
| download | poky-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.bbclass | 3 | ||||
| -rw-r--r-- | meta/classes-recipe/debug_build.bbclass | 8 | ||||
| -rw-r--r-- | meta/conf/bitbake.conf | 9 | ||||
| -rw-r--r-- | meta/conf/distro/include/debug_build.inc | 5 | ||||
| -rw-r--r-- | meta/conf/documentation.conf | 2 |
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}" | |||
| 35 | inherit_defer toolchain/${TOOLCHAIN_NATIVE}-native | 35 | inherit_defer toolchain/${TOOLCHAIN_NATIVE}-native |
| 36 | inherit_defer toolchain/${TOOLCHAIN} | 36 | inherit_defer toolchain/${TOOLCHAIN} |
| 37 | 37 | ||
| 38 | DEBUG_BUILD ??= "0" | ||
| 39 | inherit_defer ${@oe.utils.vartrue('DEBUG_BUILD', 'debug_build', '', d)} | ||
| 40 | |||
| 38 | def lsb_distro_identifier(d): | 41 | def 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 | ||
| 8 | include_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 | " |
| 659 | DEBUG_LEVELFLAG ?= "-g" | 659 | DEBUG_LEVELFLAG ?= "-g" |
| 660 | 660 | ||
| 661 | FULL_OPTIMIZATION = "-O2 ${DEBUG_LEVELFLAG}" | 661 | FULL_OPTIMIZATION ??= "-O2 ${DEBUG_LEVELFLAG}" |
| 662 | DEBUG_OPTIMIZATION = "-Og ${DEBUG_LEVELFLAG}" | 662 | SELECTED_OPTIMIZATION ??= "${FULL_OPTIMIZATION}" |
| 663 | SELECTED_OPTIMIZATION = "${@d.getVar(oe.utils.vartrue('DEBUG_BUILD', 'DEBUG_OPTIMIZATION', 'FULL_OPTIMIZATION', d))}" | ||
| 664 | SELECTED_OPTIMIZATION[vardeps] += "FULL_OPTIMIZATION DEBUG_OPTIMIZATION DEBUG_BUILD" | ||
| 665 | # compiler flags for native/nativesdk | 663 | # compiler flags for native/nativesdk |
| 666 | BUILD_OPTIMIZATION = "${@oe.utils.vartrue('DEBUG_BUILD', '-Og -g', '-O2', d)}" | 664 | BUILD_OPTIMIZATION ??= "-O2" |
| 667 | BUILD_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. | ||
| 2 | DEBUG_OPTIMIZATION ?= "-Og ${DEBUG_LEVELFLAG}" | ||
| 3 | SELECTED_OPTIMIZATION ?= "${DEBUG_OPTIMIZATION}" | ||
| 4 | # compiler flags for native/nativesdk | ||
| 5 | BUILD_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 | |||
| 129 | D[doc] = "The destination directory." | 129 | D[doc] = "The destination directory." |
| 130 | DATE[doc] = "The date the build was started using YMD format." | 130 | DATE[doc] = "The date the build was started using YMD format." |
| 131 | DATETIME[doc] = "The date and time the build was started." | 131 | DATETIME[doc] = "The date and time the build was started." |
| 132 | DEBUG_BUILD[doc] = "Specifies to build packages with debugging information. This influences the value of the SELECTED_OPTIMIZATION variable." | 132 | DEBUG_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" |
| 133 | DEBUG_OPTIMIZATION[doc] = "The options to pass in TARGET_CFLAGS and CFLAGS when compiling a system for debugging. This variable defaults to '-Og ${DEBUG_LEVELFLAG}'." | 133 | DEBUG_OPTIMIZATION[doc] = "The options to pass in TARGET_CFLAGS and CFLAGS when compiling a system for debugging. This variable defaults to '-Og ${DEBUG_LEVELFLAG}'." |
| 134 | DEFAULT_PREFERENCE[doc] = "Specifies a weak bias for recipe selection priority." | 134 | DEFAULT_PREFERENCE[doc] = "Specifies a weak bias for recipe selection priority." |
| 135 | DEPENDS[doc] = "Lists a recipe's build-time dependencies (i.e. other recipe files)." | 135 | DEPENDS[doc] = "Lists a recipe's build-time dependencies (i.e. other recipe files)." |
