Skip to contentSkip to conversation

bitbake.conf: Use -Og in DEBUG_OPTIMIZATION

PATCH New Khem Raj 1 participant 5 messages Mar 1, 2019

lore
Share & tools
lore

Khem Raj

author
#0 lore raw

PATCH v3 1/5 bitbake.conf: Use -Og in DEBUG_OPTIMIZATION

-Og is for optimized debugging experience.
this makes this consistent across different compilers especially gcc and clang, -O in clang is equal to -O2 where as in gcc its similar to -O1 so it was not giving consistent debugging experience across compilers

---
v2: Change documentation to reflect the change and also build host flags
v3: Rebase

 meta/conf/bitbake.conf       | 4 ++--
 meta/conf/documentation.conf | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)
meta/conf/bitbake.conf +2 -2
index 1c5369ec98..85aab98462 100644
@@ -610,10 +610,10 @@ DEBUG_FLAGS ?= "-g -feliminate-unused-debug-types ${DEBUG_PREFIX_MAP}"
 
 # Disabled until the option works properly -feliminate-dwarf2-dups
 FULL_OPTIMIZATION = "-O2 -pipe ${DEBUG_FLAGS}"
-DEBUG_OPTIMIZATION = "-O -fno-omit-frame-pointer ${DEBUG_FLAGS} -pipe"
+DEBUG_OPTIMIZATION = "-Og -fno-omit-frame-pointer ${DEBUG_FLAGS} -pipe"
 SELECTED_OPTIMIZATION = "${@d.getVar(oe.utils.vartrue('DEBUG_BUILD', 'DEBUG_OPTIMIZATION', 'FULL_OPTIMIZATION', d))}"
 SELECTED_OPTIMIZATION[vardeps] += "FULL_OPTIMIZATION DEBUG_OPTIMIZATION DEBUG_BUILD"
-BUILD_OPTIMIZATION = "${@oe.utils.vartrue('DEBUG_BUILD', '-O -g -feliminate-unused-debug-types -fno-omit-frame-pointer', '-O2', d)} -pipe"
+BUILD_OPTIMIZATION = "${@oe.utils.vartrue('DEBUG_BUILD', '-Og -g -feliminate-unused-debug-types -fno-omit-frame-pointer', '-O2', d)} -pipe"
 BUILD_OPTIMIZATION[vardeps] += "DEBUG_BUILD"
 
 ##################################################################
meta/conf/documentation.conf +1 -1
index 4d2a707563..c2c96ecf1e 100644
@@ -125,7 +125,7 @@ D[doc] = "The destination directory."
 DATE[doc] = "The date the build was started using YMD format."
 DATETIME[doc] = "The date and time the build was started."
 DEBUG_BUILD[doc] = "Specifies to build packages with debugging information. This influences the value of the SELECTED_OPTIMIZATION variable."
-DEBUG_OPTIMIZATION[doc] = "The options to pass in TARGET_CFLAGS and CFLAGS when compiling a system for debugging. This variable defaults to '-O -fno-omit-frame-pointer ${DEBUG_FLAGS} -pipe'."
+DEBUG_OPTIMIZATION[doc] = "The options to pass in TARGET_CFLAGS and CFLAGS when compiling a system for debugging. This variable defaults to '-Og -fno-omit-frame-pointer ${DEBUG_FLAGS} -pipe'."
 DEFAULT_PREFERENCE[doc] = "Specifies a weak bias for recipe selection priority."
 DEPENDS[doc] = "Lists a recipe's build-time dependencies (i.e. other recipe files)."
 DEPLOY_DIR[doc] = "Points to the general area that the OpenEmbedded build system uses to place images, packages, SDKs and other output files that are ready to be used outside of the build system."
Signature · 1 line
2.21.0
author
#1 lore raw

PATCH v2 2/5 glibc: Disable Werror when building with debug options

Since compiler does not optimize away a lot of stuff we end up with Werrors e.g.

./sysdeps/ieee754/flt-32/s_log1pf.c: In function '__log1pf':
../sysdeps/ieee754/flt-32/s_log1pf.c:114:22: error: 'c' may be used uninitialized in this function [-Werror=maybe-uninitialized]

  114 |        + (k * ln2_lo + c))) - f);
      |          ~~~~~~~~~~~~^~~~

which otherwise wont happen, so lets build with warnings-as-errors disabled in debug mode

given we disable werror, now we don't have to restrict user to compile without -O0

---
v2: Rebased

 meta/recipes-core/glibc/glibc.inc     | 9 ---------
 meta/recipes-core/glibc/glibc_2.29.bb | 1 +
 2 files changed, 1 insertion(+), 9 deletions(-)
meta/recipes-core/glibc/glibc.inc +0 -9
index b550abd877..252fd56c13 100644
@@ -2,15 +2,6 @@ require glibc-common.inc
 require glibc-ld.inc
 require glibc-testing.inc
 
-python () {
-    opt_effective = "-O"
-    for opt in d.getVar('SELECTED_OPTIMIZATION').split():
-        if opt in ("-O0", "-O", "-O1", "-O2", "-O3", "-Os"):
-            opt_effective = opt
-    if opt_effective == "-O0":
-        bb.fatal("%s can't be built with %s, try -O1 instead" % (d.getVar('PN'), opt_effective))
-}
-
 DEPENDS = "virtual/${TARGET_PREFIX}gcc libgcc-initial linux-libc-headers"
 
 PROVIDES = "virtual/libc"
meta/recipes-core/glibc/glibc_2.29.bb +1 -0
index c3e969d2f8..4577350eae 100644
@@ -85,6 +85,7 @@ EXTRA_OECONF = "--enable-kernel=${OLDEST_KERNEL} \
                 --disable-crypt \
                 --with-default-link \
                 --enable-nscd \
+                ${@bb.utils.contains_any('SELECTED_OPTIMIZATION', '-O0 -Og', '--disable-werror', '', d)} \
                 ${GLIBCPIE} \
                 ${GLIBC_EXTRA_OECONF}"
 
Signature · 1 line
2.21.0
author
#2 lore raw

PATCH 3/5 bitbake.conf: Drop -fno-omit-frame-pointer

In reply to Khem Raj

Let -Og decide the best debugging experience

---
 meta/conf/bitbake.conf       | 4 ++--
 meta/conf/documentation.conf | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)
meta/conf/bitbake.conf +2 -2
index 85aab98462..f1540a0acf 100644
@@ -610,10 +610,10 @@ DEBUG_FLAGS ?= "-g -feliminate-unused-debug-types ${DEBUG_PREFIX_MAP}"
 
 # Disabled until the option works properly -feliminate-dwarf2-dups
 FULL_OPTIMIZATION = "-O2 -pipe ${DEBUG_FLAGS}"
-DEBUG_OPTIMIZATION = "-Og -fno-omit-frame-pointer ${DEBUG_FLAGS} -pipe"
+DEBUG_OPTIMIZATION = "-Og ${DEBUG_FLAGS} -pipe"
 SELECTED_OPTIMIZATION = "${@d.getVar(oe.utils.vartrue('DEBUG_BUILD', 'DEBUG_OPTIMIZATION', 'FULL_OPTIMIZATION', d))}"
 SELECTED_OPTIMIZATION[vardeps] += "FULL_OPTIMIZATION DEBUG_OPTIMIZATION DEBUG_BUILD"
-BUILD_OPTIMIZATION = "${@oe.utils.vartrue('DEBUG_BUILD', '-Og -g -feliminate-unused-debug-types -fno-omit-frame-pointer', '-O2', d)} -pipe"
+BUILD_OPTIMIZATION = "${@oe.utils.vartrue('DEBUG_BUILD', '-Og -g -feliminate-unused-debug-types', '-O2', d)} -pipe"
 BUILD_OPTIMIZATION[vardeps] += "DEBUG_BUILD"
 
 ##################################################################
meta/conf/documentation.conf +1 -1
index c2c96ecf1e..550df20b0f 100644
@@ -125,7 +125,7 @@ D[doc] = "The destination directory."
 DATE[doc] = "The date the build was started using YMD format."
 DATETIME[doc] = "The date and time the build was started."
 DEBUG_BUILD[doc] = "Specifies to build packages with debugging information. This influences the value of the SELECTED_OPTIMIZATION variable."
-DEBUG_OPTIMIZATION[doc] = "The options to pass in TARGET_CFLAGS and CFLAGS when compiling a system for debugging. This variable defaults to '-Og -fno-omit-frame-pointer ${DEBUG_FLAGS} -pipe'."
+DEBUG_OPTIMIZATION[doc] = "The options to pass in TARGET_CFLAGS and CFLAGS when compiling a system for debugging. This variable defaults to '-Og ${DEBUG_FLAGS} -pipe'."
 DEFAULT_PREFERENCE[doc] = "Specifies a weak bias for recipe selection priority."
 DEPENDS[doc] = "Lists a recipe's build-time dependencies (i.e. other recipe files)."
 DEPLOY_DIR[doc] = "Points to the general area that the OpenEmbedded build system uses to place images, packages, SDKs and other output files that are ready to be used outside of the build system."
Signature · 1 line
2.21.0
author
#3 lore raw

PATCH 4/5 perf: Set libunwind dir explicitly to point into staging sysroot

In reply to Khem Raj

This helps it find the unwind library in sysroot always and not look around and confuse with host

---
 meta/recipes-kernel/perf/perf.bb | 1 +
 1 file changed, 1 insertion(+)
meta/recipes-kernel/perf/perf.bb +1 -0
index 515a78b859..9120766858 100644
@@ -80,6 +80,7 @@ EXTRA_OEMAKE = '\
     NO_GTK2=1 \
     ${PACKAGECONFIG_CONFARGS} \
     TMPDIR="${B}" \
+    LIBUNWIND_DIR=${STAGING_EXECPREFIXDIR} \
 '
 
 EXTRA_OEMAKE += "\
Signature · 1 line
2.21.0
author
#4 lore raw

PATCH 5/5 musl: Fix out of bounds data access in dlopen

In reply to Khem Raj
---
 .../musl/musl/out_of_bounds_read.patch        | 20 +++++++++++++++++++
 meta/recipes-core/musl/musl_git.bb            |  1 +
 2 files changed, 21 insertions(+)
 create mode 100644 meta/recipes-core/musl/musl/out_of_bounds_read.patch
meta/recipes-core/musl/musl/out_of_bounds_read.patch new file +20 -0
new file mode 100644
index 0000000000..a681cc284e
@@ -0,0 +1,20 @@
+Fix out of bounds read
+
+self->dtv hasn't been extended yet
+
+Upstream-Status: Pending
+Signed-off-by: Khem Raj <[email protected]>
+
+diff --git a/ldso/dynlink.c b/ldso/dynlink.c
+index e2c3259f..b23ea0df 100644
+--- a/ldso/dynlink.c
++++ b/ldso/dynlink.c
+@@ -1374,7 +1376,7 @@ static void install_new_tls(void)
+ 	}
+ 	/* Install new dtls into the enlarged, uninstalled dtv copies. */
+ 	for (p=head; ; p=p->next) {
+-		if (!p->tls_id || self->dtv[p->tls_id]) continue;
++		if (p->tls_id <= old_cnt) continue;
+ 		unsigned char *mem = p->new_tls;
+ 		for (j=0; j<i; j++) {
+ 			unsigned char *new = mem;
meta/recipes-core/musl/musl_git.bb +1 -0
index f1052278c8..6a72b7d3bc 100644
@@ -15,6 +15,7 @@ PV = "${BASEVER}+git${SRCPV}"
 SRC_URI = "git://git.musl-libc.org/musl \
            file://0001-Make-dynamic-linker-a-relative-symlink-to-libc.patch \
            file://0002-ldso-Use-syslibdir-and-libdir-as-default-pathes-to-l.patch \
+           file://out_of_bounds_read.patch \
           "
 
 S = "${WORKDIR}/git"
Signature · 1 line
2.21.0