use target path to replace build ones in debugging info
v2 cover use target path to replace build ones in debugging info
The fix on gcc is quick and simple, almost has no side effect. Another ides is add new option to do path substitutions on gcc switches(just refer what '-fdebug-prefix-map=OLD=NEW' did), but it needs more modification and more risks introduced.
Changed in V2:
- Do not use '-gno-record-gcc-switches' to leave gcc switches in;
- Add gcc option '-gno-record-debug-prefix-map' to not record '-fdebug-prefix-map' to gcc command line switches in DWARF DW_AT_producer;
Test Steps:
vim local.conf
...
MACHINE ?= "qemux86-64"WARN_QA += "buildpaths"
require conf/multilib.conf
MULTILIBS = "multilib:lib32"
DEFAULTTUNE_virtclass-multilib-lib32 = "core2-32"
...
bitbake -k world
It fixed buidpath QA warning of 142 recipes (before 236, after 94) These newly added options does not work on native.(Which TARGET_CFLAGS have been overrided in native.bbclass)
When do the world build, mkelfimage compile failed which triggered by the newly added gcc option.
//Hongxu
The following changes since commit 3d2c0f5902cacf9d8544bf263b51ef0dd1a7218c:
cmake: update to 3.4.2 (2016-01-26 22:49:40 +0000)
are available in the git repository at:
git://git.openembedded.org/openembedded-core-contrib hongxu/fix-buildpath
http://cgit.openembedded.org/cgit.cgi/openembedded-core-contrib/log/?h=hongxu/fix-buildpath
Hongxu Jia (3):
base/bbclass: use target path as compile dir in debugging info gcc-5.3.inc/base.bbclass: add gcc option to not record
-fdebug-prefix-map to debugging info
mkelfimage: fix target cflags leaks to host
meta/classes/base.bbclass | 19 +++++++ meta/recipes-devtools/gcc/gcc-5.3.inc | 3 +- ...48-add-option-gno-record-debug-prefix-map.patch | 65 ++++++++++++++++++++++ meta/recipes-devtools/mkelfimage/mkelfimage_git.bb | 4 +- 4 files changed, 89 insertions(+), 2 deletions(-) create mode 100644 meta/recipes-devtools/gcc/gcc-5.3/0048-add-option-gno-record-debug-prefix-map.patch
Signature · 1 line
1.9.1
PATCH v2 1/3 base/bbclass: use target path as compile dir in debugging info
In debugging information, it uses target paths rather than build ones as compile dir.
...
-fdebug-prefix-map=old=new
When compiling files in directory old, record debugging information describing them as in new instead.
...
Compile without this fix:
objdump -g git/test.o
...
The Directory Table (offset 0x1b):
| 1 /buildarea/raid0/hjia/build-20160119-yocto-buildpath/tmp/sysroots/x86_64-linux/usr/lib/
i686-pokymllib32-linux.lib32-gcc-cross-initial-i686/gcc/i686-pokymllib32-linux/5.3.0/include
| 2 /buildarea/raid0/hjia/build-20160119-yocto-buildpath/tmp/sysroots/lib32-qemux86-64/usr/include/bits | 3 /buildarea/raid0/hjia/build-20160119-yocto-buildpath/tmp/sysroots/lib32-qemux86-64/usr/include
...
Compile with this fix:
objdump -g git/test.o
...
The Directory Table (offset 0x1b):
| 1 /usr/lib/i686-pokymllib32-linux.lib32-gcc-cross-initial-i686/gcc/i686-pokymllib32-linux/
5.3.0/include
| 2 /usr/include/bits | 3 /usr/include
...
[YOCTO #7058]
--- meta/classes/base.bbclass | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)
meta/classes/base.bbclass +18 -0
@@ -85,6 +85,24 @@ FILESPATH = "${@base_set_filespath(["${FILE_DIRNAME}/${BP}", "${FILE_DIRNAME}/${ # in the context of the location its used (:=) THISDIR = "${@os.path.dirname(d.getVar('FILE', True))}" +def debug_prefix_map(d): + opts = "" + if "-g" in (d.getVar("SELECTED_OPTIMIZATION", True) or "").split(): + targetsrc = "/usr/src/%s" % d.getVar("BPN", True) + for var in ["S", "B"]: + buildsrc = d.getVar(var, True) + opt = " -fdebug-prefix-map=%s=%s" % (buildsrc, targetsrc) + if opt not in opts: + opts += opt + + for var in ["STAGING_DIR_NATIVE", "STAGING_DIR_HOST"]: + buildinc = d.getVar(var, True) + opts += " -fdebug-prefix-map=%s=" % (buildinc) + + return opts + +TARGET_CFLAGS += "${@debug_prefix_map(d)}" + def extra_path_elements(d): path = "" elements = (d.getVar('EXTRANATIVEPATH', True) or "").split()
Signature · 1 line
1.9.1
PATCH v2 2/3 gcc-5.3.inc/base.bbclass: add gcc option to not record -fdebug-prefix-map to debugging info
In reply to Hongxu JiaAdd option '-gno-record-debug-prefix-map' and '-grecord-debug-prefix-map' for gcc. If '-gno-record-debug-prefix-map' is used, it does not record '-fdebug-prefix-map' to gcc command line switches in DWARF DW_AT_producer.
The patch could make sure the debugging informaion does not has TMPDIR and also leaves gcc switches in.
Compile without this fix:
objdump -g packages-split/lib32-glibc-dev/usr/lib/gcrt1.o
...
| <5f> DW_AT_producer : (indirect string, offset: 0x1b): GNU C99 5.3.0
-m32-march=core2 -mtune=core2 -msse3 -mfpmath=sse -mpreferred-stack-boundary=4 -g -O2 -std=gnu99 -fgnu89-inline -fdebug-prefix-map=/buildarea/raid0/hjia/buil d-20160127-yocto-buildpath-2/tmp/sysroots/lib32-qemux86-64= -feliminate-unused-debug-types -fmerge-all-constants -frounding-math -ftls-model=initial-exec
...
Compile with this fix:
objdump -g packages-split/lib32-glibc-dev/usr/lib/gcrt1.o
...
| <5f> DW_AT_producer : (indirect string, offset: 0xa1): GNU C99 5.3.0
-m32 -march=core2 -mtune=core2 -msse3 -mfpmath=sse -mpreferred-stack-boundary=4 -g -O2 -std=gnu99 -fgnu89-inline -feliminate-unused-debug-types -fmerge-all-constants -frounding-math -ftls-model=initial-exec
...
[YOCTO #7058]
--- meta/classes/base.bbclass | 1 + meta/recipes-devtools/gcc/gcc-5.3.inc | 3 +- ...48-add-option-gno-record-debug-prefix-map.patch | 65 ++++++++++++++++++++++ 3 files changed, 68 insertions(+), 1 deletion(-) create mode 100644 meta/recipes-devtools/gcc/gcc-5.3/0048-add-option-gno-record-debug-prefix-map.patch
meta/classes/base.bbclass +1 -0
@@ -99,6 +99,7 @@ def debug_prefix_map(d): buildinc = d.getVar(var, True) opts += " -fdebug-prefix-map=%s=" % (buildinc) + opts += " -gno-record-debug-prefix-map" return opts TARGET_CFLAGS += "${@debug_prefix_map(d)}"
meta/recipes-devtools/gcc/gcc-5.3.inc +2 -1
@@ -76,7 +76,8 @@ SRC_URI = "\ file://0044-Adding-mmusl-as-a-musl-libc-specifier-and-the-necess.patch \ file://0045-Support-for-arm-linux-musl.patch \ file://0046-Get-rid-of-ever-broken-fixincludes-on-musl.patch \ - file://0047-Fix-nios2-musl-build.patch \ + file://0047-Fix-nios2-musl-build.patch \ + file://0048-add-option-gno-record-debug-prefix-map.patch \ " BACKPORTS = ""
meta/recipes-devtools/gcc/gcc-5.3/0048-add-option-gno-record-debug-prefix-map.patch new file +65 -0
65 lines not on this page · raw message
Signature · 1 line
1.9.1
PATCH v2 3/3 mkelfimage: fix target cflags leaks to host
In reply to Hongxu JiaThe patch fix-makefile-to-find-libz.patch fixed native compile failure; for target compile, it incorrectly leaks CFLAGS to HOST_CFLAGS.
[YOCTO #3547]
--- meta/recipes-devtools/mkelfimage/mkelfimage_git.bb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
meta/recipes-devtools/mkelfimage/mkelfimage_git.bb +3 -1
@@ -14,8 +14,10 @@ DEPENDS += "zlib" SRC_URI = "git://review.coreboot.org/p/coreboot;protocol=http \ file://cross-compile.patch \ - file://fix-makefile-to-find-libz.patch \ " +SRC_URI_append_class-native = " \ + file://fix-makefile-to-find-libz.patch \ +" CLEANBROKEN = "1"
Signature · 1 line
1.9.1