Skip to contentSkip to conversation

debug_build.inc: support disable debug build for specific recipe when DEBUG_BUILD is enabled globally

PATCH In review Hongxu Jia 3 participants 4 messages Sep 19, 2025 – Sep 22, 2025 1 message not in the archive

lore
Share & tools
lore

Hongxu Jia

author
#1 lore raw

PATCH 9/9 debug_build.inc: support disable debug build for specific recipe when DEBUG_BUILD is enabled globally

In reply to a message not in the archive

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, we have to set DEBUG_BUILD = "0" in the recipe. In this situation, conf/distro/include/debug_build.inc is included, although set DEBUG_BUILD = "0" in qemu recipe, the debug build is still enabled for qemu and break qemu build.

This commit sets SELECTED_OPTIMIZATION, BUILD_OPTLEVE and BUILD_OPTIMIZATION conditionally according to the value of DEBUG_BUILD, then disable debug build for specific recipe could work

Also move DEBUG_BUILD setting from qemu.inc to debug_build.inc

---
 meta/conf/distro/include/debug_build.inc | 18 +++++++++++++++---
 meta/recipes-devtools/qemu/qemu.inc      |  4 ----
 2 files changed, 15 insertions(+), 7 deletions(-)
meta/conf/distro/include/debug_build.inc +15 -3
index 81b6a5f234..c3f19666e6 100644
@@ -1,10 +1,14 @@
 # Override SELECTED_OPTIMIZATION and BUILD_OPTIMIZATION when DEBUG_BUILD is enabled.
 DEBUG_OPTLEVEL ?= "-Og"
 DEBUG_OPTIMIZATION = "${DEBUG_OPTLEVEL} ${DEBUG_LEVELFLAG}"
-SELECTED_OPTIMIZATION = "${DEBUG_OPTIMIZATION}"
+SELECTED_OPTIMIZATION = "${@d.getVar(oe.utils.vartrue('DEBUG_BUILD', 'DEBUG_OPTIMIZATION', 'FULL_OPTIMIZATION', d))}"
+SELECTED_OPTIMIZATION[vardeps] += "DEBUG_BUILD"
+
 # compiler flags for native/nativesdk
-BUILD_OPTLEVEL = "-Og"
-BUILD_OPTIMIZATION = "${BUILD_OPTLEVEL} -g"
+BUILD_OPTLEVEL = "${@oe.utils.vartrue('DEBUG_BUILD', '-Og', '-O2', d)}"
+BUILD_OPTLEVEL[vardeps] += "DEBUG_BUILD"
+BUILD_OPTIMIZATION += "${@oe.utils.vartrue('DEBUG_BUILD', '-g', '', d)}"
+BUILD_OPTIMIZATION[vardeps] += "DEBUG_BUILD"
 
 # The modern compilers and code seem to require extra steps to avoid DEBUG errors,
 # this file collects debug tuning configuration to address DEBUG errors.
@@ -53,3 +57,11 @@ MESON_BUILDTYPE ?= "debug"
 # For cargo.bbclass
 BUILD_MODE ?= ""
 BUILD_DIR ?= "debug"
+
+# Per https://lists.nongnu.org/archive/html/qemu-devel/2020-09/msg03873.html
+# upstream states qemu doesn't work without optimization
+DEBUG_BUILD:pn-qemu = "0"
+DEBUG_BUILD:pn-qemu-native = "0"
+DEBUG_BUILD:pn-qemu-system-native = "0"
+DEBUG_BUILD:pn-nativesdk-qemu = "0"
+
meta/recipes-devtools/qemu/qemu.inc +0 -4
index 2ee76e9a7c..7bd28dbbb5 100644
@@ -58,10 +58,6 @@ COMPATIBLE_HOST:mipsarchn32 = "null"
 COMPATIBLE_HOST:mipsarchn64 = "null"
 COMPATIBLE_HOST:riscv32 = "null"
 
-# Per https://lists.nongnu.org/archive/html/qemu-devel/2020-09/msg03873.html
-# upstream states qemu doesn't work without optimization
-DEBUG_BUILD = "0"
-
 do_install:append() {
     # Prevent QA warnings about installed ${localstatedir}/run
     if [ -d ${D}${localstatedir}/run ]; then rmdir ${D}${localstatedir}/run; fi
Signature · 1 line
2.34.1
#2 lore raw

Patchtest results for [PATCH 9/9] debug_build.inc: support disable debug build for specific recipe when DEBUG_BUILD is enabled globally

Thank you for your submission. Patchtest identified one or more issues with the patch. Please see the log below for more information:

---
Testing patch /home/patchtest/share/mboxes/9-9-debug_build.inc-support-disable-debug-build-for-specific-recipe-when-DEBUG_BUILD-is-enabled-globally.patch

FAIL: test shortlog length: Edit shortlog so that it is 90 characters or less (currently 101 characters) (test_mbox.TestMbox.test_shortlog_length)

PASS: test Signed-off-by presence (test_mbox.TestMbox.test_signed_off_by_presence)
PASS: test author valid (test_mbox.TestMbox.test_author_valid)
PASS: test commit message presence (test_mbox.TestMbox.test_commit_message_presence)
PASS: test commit message user tags (test_mbox.TestMbox.test_commit_message_user_tags)
PASS: test max line length (test_metadata.TestMetadata.test_max_line_length)
PASS: test mbox format (test_mbox.TestMbox.test_mbox_format)
PASS: test non-AUH upgrade (test_mbox.TestMbox.test_non_auh_upgrade)
PASS: test shortlog format (test_mbox.TestMbox.test_shortlog_format)
PASS: test target mailing list (test_mbox.TestMbox.test_target_mailing_list)

SKIP: pretest pylint: No python related patches, skipping test (test_python_pylint.PyLint.pretest_pylint)
SKIP: pretest src uri left files: Patch cannot be merged (test_metadata.TestMetadata.pretest_src_uri_left_files)
SKIP: test CVE check ignore: No modified recipes or older target branch, skipping test (test_metadata.TestMetadata.test_cve_check_ignore)
SKIP: test CVE tag format: No new CVE patches introduced (test_patch.TestPatch.test_cve_tag_format)
SKIP: test Signed-off-by presence: No new CVE patches introduced (test_patch.TestPatch.test_signed_off_by_presence)
SKIP: test Upstream-Status presence: No new CVE patches introduced (test_patch.TestPatch.test_upstream_status_presence_format)
SKIP: test bugzilla entry format: No bug ID found (test_mbox.TestMbox.test_bugzilla_entry_format)
SKIP: test lic files chksum modified not mentioned: No modified recipes, skipping test (test_metadata.TestMetadata.test_lic_files_chksum_modified_not_mentioned)
SKIP: test lic files chksum presence: No added recipes, skipping test (test_metadata.TestMetadata.test_lic_files_chksum_presence)
SKIP: test license presence: No added recipes, skipping test (test_metadata.TestMetadata.test_license_presence)
SKIP: test pylint: No python related patches, skipping test (test_python_pylint.PyLint.test_pylint)
SKIP: test series merge on head: Merge test is disabled for now (test_mbox.TestMbox.test_series_merge_on_head)
SKIP: test src uri left files: Patch cannot be merged (test_metadata.TestMetadata.test_src_uri_left_files)
SKIP: test summary presence: No added recipes, skipping test (test_metadata.TestMetadata.test_summary_presence)

---

Please address the issues identified and
submit a new revision of the patch, or alternatively, reply to this email with an explanation of why the patch should be accepted. If you believe these results are due to an error in patchtest, please submit a bug at https://bugzilla.yoctoproject.org/ (use the 'Patchtest' category under 'Yocto Project Subprojects'). For more information on specific failures, see: https://wiki.yoctoproject.org/wiki/Patchtest. Thank you!

#3 lore raw
In reply to Hongxu Jia
Quoted 13 lines

-----Original Message-----
From: Hongxu Jia <[email protected]>
Sent: den 19 september 2025 09:56
To: [email protected]; Peter Kjellerstedt <[email protected]>
Subject: [PATCH 9/9] debug_build.inc: support disable debug build for specific recipe when DEBUG_BUILD is enabled globally

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, we have to set DEBUG_BUILD = "0" in the recipe. In this situation, conf/distro/include/debug_build.inc is included, although set DEBUG_BUILD = "0" in qemu recipe, the debug build is still enabled for qemu and break qemu build.

Quoted 8 lines

This commit sets SELECTED_OPTIMIZATION, BUILD_OPTLEVE and BUILD_OPTIMIZATION conditionally according to the value of DEBUG_BUILD, then disable debug build for specific recipe could work

Also move DEBUG_BUILD setting from qemu.inc to debug_build.inc

Unfortunately, I think this defeats the purpose of this whole change. :( I.e., when parsing debug_build.inc you should know that DEBUG_BUILD is set to 1. If that is not the case, then what's the point of moving everything to that file? You would still have to check DEBUG_BUILD for every variable you modify.

Here is a solution I came up with that would maintain the property that debug_build.inc is only included if DEBUG_BUILD is set to 1 for a given recipe. Add this to bitbake.conf:

INHERIT += "debug_build"

Then create meta/classes-global/debug_build.bbclass with this line:

inherit_defer debug_build_deferred

and create meta/classes-recipe/debug_build_deferred.bbclass with this line:

include_all ${@oe.utils.vartrue('DEBUG_BUILD', 'conf/distro/include/debug_build.inc', '', d)}

Having to have the two bbclasses to defer the include_all so that debug_build.inc is only included if DEBUG_BUILD is actually set for a given recipe is a bit awkward, but it seems to work. At least with my quick test I could modify DEBUG_BUILD in a recipe and debug_build.inc would only be included when it was set to 1.

//Peter

Quoted 57 lines
---
 meta/conf/distro/include/debug_build.inc | 18 +++++++++++++++---
 meta/recipes-devtools/qemu/qemu.inc      |  4 ----
 2 files changed, 15 insertions(+), 7 deletions(-)
meta/conf/distro/include/debug_build.inc +15 -3
index 81b6a5f234..c3f19666e6 100644
@@ -1,10 +1,14 @@
 # Override SELECTED_OPTIMIZATION and BUILD_OPTIMIZATION when DEBUG_BUILD is enabled.
 DEBUG_OPTLEVEL ?= "-Og"
 DEBUG_OPTIMIZATION = "${DEBUG_OPTLEVEL} ${DEBUG_LEVELFLAG}"
-SELECTED_OPTIMIZATION = "${DEBUG_OPTIMIZATION}"
+SELECTED_OPTIMIZATION = "${@d.getVar(oe.utils.vartrue('DEBUG_BUILD', 'DEBUG_OPTIMIZATION', 'FULL_OPTIMIZATION', d))}"
+SELECTED_OPTIMIZATION[vardeps] += "DEBUG_BUILD"
+
 # compiler flags for native/nativesdk
-BUILD_OPTLEVEL = "-Og"
-BUILD_OPTIMIZATION = "${BUILD_OPTLEVEL} -g"
+BUILD_OPTLEVEL = "${@oe.utils.vartrue('DEBUG_BUILD', '-Og', '-O2', d)}"
+BUILD_OPTLEVEL[vardeps] += "DEBUG_BUILD"
+BUILD_OPTIMIZATION += "${@oe.utils.vartrue('DEBUG_BUILD', '-g', '', d)}"
+BUILD_OPTIMIZATION[vardeps] += "DEBUG_BUILD"
 
 # The modern compilers and code seem to require extra steps to avoid DEBUG errors,
 # this file collects debug tuning configuration to address DEBUG errors.
@@ -53,3 +57,11 @@ MESON_BUILDTYPE ?= "debug"
 # For cargo.bbclass
 BUILD_MODE ?= ""
 BUILD_DIR ?= "debug"
+
+# Per https://lists.nongnu.org/archive/html/qemu-devel/2020-09/msg03873.html
+# upstream states qemu doesn't work without optimization
+DEBUG_BUILD:pn-qemu = "0"
+DEBUG_BUILD:pn-qemu-native = "0"
+DEBUG_BUILD:pn-qemu-system-native = "0"
+DEBUG_BUILD:pn-nativesdk-qemu = "0"
+
meta/recipes- renamed from meta/recipes-devtools/qemu/qemu.inc +0 -0

devtools/qemu/qemu.inc
index 2ee76e9a7c..7bd28dbbb5 100644

meta/recipes-devtools/qemu/qemu.inc +0 -5
@@ -58,10 +58,6 @@ COMPATIBLE_HOST:mipsarchn32 = "null"
 COMPATIBLE_HOST:mipsarchn64 = "null"
 COMPATIBLE_HOST:riscv32 = "null"
 
-# Per https://lists.nongnu.org/archive/html/qemu-devel/2020-09/msg03873.html
-# upstream states qemu doesn't work without optimization
-DEBUG_BUILD = "0"
-
 do_install:append() {
     # Prevent QA warnings about installed ${localstatedir}/run
     if [ -d ${D}${localstatedir}/run ]; then rmdir ${D}${localstatedir}/run; fi
--

2.34.1

author
#4 lore raw
Quoted 44 lines · Peter Kjellerstedt via lists.openembedded.org

CAUTION: This email comes from a non Wind River email account!
Do not click links or open attachments unless you recognize the sender and know the content is safe.

Quoted 13 lines

-----Original Message-----
From: Hongxu Jia <[email protected]>
Sent: den 19 september 2025 09:56
To: [email protected]; Peter Kjellerstedt <[email protected]>
Subject: [PATCH 9/9] debug_build.inc: support disable debug build for specific recipe when DEBUG_BUILD is enabled globally

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, we have to set DEBUG_BUILD = "0" in the recipe. In this situation, conf/distro/include/debug_build.inc is included, although set DEBUG_BUILD = "0" in qemu recipe, the debug build is still enabled for qemu and break qemu build.

Quoted 8 lines

This commit sets SELECTED_OPTIMIZATION, BUILD_OPTLEVE and BUILD_OPTIMIZATION conditionally according to the value of DEBUG_BUILD, then disable debug build for specific recipe could work

Also move DEBUG_BUILD setting from qemu.inc to debug_build.inc

Unfortunately, I think this defeats the purpose of this whole change. :( I.e., when parsing debug_build.inc you should know that DEBUG_BUILD is set to 1. If that is not the case, then what's the point of moving everything to that file? You would still have to check DEBUG_BUILD for every variable you modify.

Here is a solution I came up with that would maintain the property that debug_build.inc is only included if DEBUG_BUILD is set to 1 for a given recipe. Add this to bitbake.conf:

INHERIT += "debug_build"

Then create meta/classes-global/debug_build.bbclass with this line:

inherit_defer debug_build_deferred

and create meta/classes-recipe/debug_build_deferred.bbclass with this line:

Quoted 8 lines

include_all ${@oe.utils.vartrue('DEBUG_BUILD', 'conf/distro/include/debug_build.inc', '', d)}

Having to have the two bbclasses to defer the include_all so that debug_build.inc is only included if DEBUG_BUILD is actually set for a given recipe is a bit awkward, but it seems to work. At least with my quick test I could modify DEBUG_BUILD in a recipe and debug_build.inc would only be included when it was set to 1.

Many thanks for your suggestion, I will follow it with slightly simplified, v2 incoming

//Hongxu

Quoted 68 lines

//Peter

Quoted 56 lines
---
  meta/conf/distro/include/debug_build.inc | 18 +++++++++++++++---
  meta/recipes-devtools/qemu/qemu.inc      |  4 ----
  2 files changed, 15 insertions(+), 7 deletions(-)
meta/conf/distro/include/debug_build.inc +15 -3
index 81b6a5f234..c3f19666e6 100644
@@ -1,10 +1,14 @@
  # Override SELECTED_OPTIMIZATION and BUILD_OPTIMIZATION when DEBUG_BUILD is enabled.
  DEBUG_OPTLEVEL ?= "-Og"
  DEBUG_OPTIMIZATION = "${DEBUG_OPTLEVEL} ${DEBUG_LEVELFLAG}"
-SELECTED_OPTIMIZATION = "${DEBUG_OPTIMIZATION}"
+SELECTED_OPTIMIZATION = "${@d.getVar(oe.utils.vartrue('DEBUG_BUILD', 'DEBUG_OPTIMIZATION', 'FULL_OPTIMIZATION', d))}"
+SELECTED_OPTIMIZATION[vardeps] += "DEBUG_BUILD"
+
  # compiler flags for native/nativesdk
-BUILD_OPTLEVEL = "-Og"
-BUILD_OPTIMIZATION = "${BUILD_OPTLEVEL} -g"
+BUILD_OPTLEVEL = "${@oe.utils.vartrue('DEBUG_BUILD', '-Og', '-O2', d)}"
+BUILD_OPTLEVEL[vardeps] += "DEBUG_BUILD"
+BUILD_OPTIMIZATION += "${@oe.utils.vartrue('DEBUG_BUILD', '-g', '', d)}"
+BUILD_OPTIMIZATION[vardeps] += "DEBUG_BUILD"
 
  # The modern compilers and code seem to require extra steps to avoid DEBUG errors,
  # this file collects debug tuning configuration to address DEBUG errors.
@@ -53,3 +57,11 @@ MESON_BUILDTYPE ?= "debug"
  # For cargo.bbclass
  BUILD_MODE ?= ""
  BUILD_DIR ?= "debug"
+
+# Per https://lists.nongnu.org/archive/html/qemu-devel/2020-09/msg03873.html
+# upstream states qemu doesn't work without optimization
+DEBUG_BUILD:pn-qemu = "0"
+DEBUG_BUILD:pn-qemu-native = "0"
+DEBUG_BUILD:pn-qemu-system-native = "0"
+DEBUG_BUILD:pn-nativesdk-qemu = "0"
+
meta/recipes- renamed from meta/recipes-devtools/qemu/qemu.inc +0 -0

devtools/qemu/qemu.inc
index 2ee76e9a7c..7bd28dbbb5 100644

meta/recipes-devtools/qemu/qemu.inc +0 -5
@@ -58,10 +58,6 @@ COMPATIBLE_HOST:mipsarchn32 = "null"
  COMPATIBLE_HOST:mipsarchn64 = "null"
  COMPATIBLE_HOST:riscv32 = "null"
 
-# Per https://lists.nongnu.org/archive/html/qemu-devel/2020-09/msg03873.html
-# upstream states qemu doesn't work without optimization
-DEBUG_BUILD = "0"
-
  do_install:append() {
      # Prevent QA warnings about installed ${localstatedir}/run
      if [ -d ${D}${localstatedir}/run ]; then rmdir ${D}${localstatedir}/run; fi
--
Quoted 1 line

2.34.1

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#223775): https://lists.openembedded.org/g/openembedded-core/message/223775
Mute This Topic: https://lists.openembedded.org/mt/115324540/3617049
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-