diff options
author | Mark Hatle <mark.hatle@kernel.crashing.org> | 2020-02-07 14:20:08 -0600 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2020-02-08 13:20:02 +0000 |
commit | 38a754214a84ddfd27e537babf2bf5d992371b67 (patch) | |
tree | 24ba06d7106bb8287b59be3874ddd0193351df47 /meta | |
parent | dae03ec7e801dd4dc781de582ba169a0fc580739 (diff) | |
download | poky-38a754214a84ddfd27e537babf2bf5d992371b67.tar.gz |
package.bbclass: Support stripping and debug copy of static libraries
By default, we won't copy and strip static libraries. However, this
functionality can be useful in some cases where people are doing
development on the target, and don't generally want the larger debug
capable static libraries. To enable the new functionality set:
PACKAGE_DEBUG_STATIC_SPLIT = '1'
Add a new function splitstaticdebuginfo. Thus function will copy the
unmodified static library into the specific debug directory location.
By keeping an unmodified version, it is possible for a user trying
to debug something to use -L /usr/lib/.debug-static and their existing
build commands to switch from stripped to full debug versions.
The PACKAGE_DEBUG_SPLIT_STYLE will select between two different
approaches, /usr/lib/debug-static or <path>/.debug-static.
Additionally you can now choose to strip static libraries to conserve
space. If either 'PACKAGE_DEBUG_STATIC_SPLIT' or 'PACKAGE_STRIP_STATIC'
is set to 1, the static library will be stripped. (This is not on by
default, as it could make diagnosing static library usage difficult in
some cases.)
Add to insane.bbclass a skip to the staticdev warning for the specific
-dbg package versions.
(From OE-Core rev: 17fa66c8199d73f0b59b2b3e609075933bf1e74b)
Signed-off-by: Mark Hatle <mark.hatle@kernel.crashing.org>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta')
-rw-r--r-- | meta/classes/insane.bbclass | 2 | ||||
-rw-r--r-- | meta/classes/package.bbclass | 67 | ||||
-rw-r--r-- | meta/conf/bitbake.conf | 2 |
3 files changed, 66 insertions, 5 deletions
diff --git a/meta/classes/insane.bbclass b/meta/classes/insane.bbclass index 795c7b9212..7425b8cbd5 100644 --- a/meta/classes/insane.bbclass +++ b/meta/classes/insane.bbclass | |||
@@ -182,7 +182,7 @@ def package_qa_check_staticdev(path, name, d, elf, messages): | |||
182 | libgcc.a, libgcov.a will be skipped in their packages | 182 | libgcc.a, libgcov.a will be skipped in their packages |
183 | """ | 183 | """ |
184 | 184 | ||
185 | if not name.endswith("-pic") and not name.endswith("-staticdev") and not name.endswith("-ptest") and path.endswith(".a") and not path.endswith("_nonshared.a"): | 185 | if not name.endswith("-pic") and not name.endswith("-staticdev") and not name.endswith("-ptest") and path.endswith(".a") and not path.endswith("_nonshared.a") and not '/usr/lib/debug-static/' in path and not '/.debug-static/' in path: |
186 | package_qa_add_message(messages, "staticdev", "non -staticdev package contains static .a library: %s path '%s'" % \ | 186 | package_qa_add_message(messages, "staticdev", "non -staticdev package contains static .a library: %s path '%s'" % \ |
187 | (name, package_qa_clean_path(path,d))) | 187 | (name, package_qa_clean_path(path,d))) |
188 | 188 | ||
diff --git a/meta/classes/package.bbclass b/meta/classes/package.bbclass index 7080d63287..1efc396ac6 100644 --- a/meta/classes/package.bbclass +++ b/meta/classes/package.bbclass | |||
@@ -416,6 +416,49 @@ def splitdebuginfo(file, dvar, debugdir, debuglibdir, debugappend, debugsrcdir, | |||
416 | 416 | ||
417 | return (file, sources) | 417 | return (file, sources) |
418 | 418 | ||
419 | def splitstaticdebuginfo(file, dvar, debugstaticdir, debugstaticlibdir, debugstaticappend, debugsrcdir, d): | ||
420 | # Unlike the function above, there is no way to split a static library | ||
421 | # two components. So to get similar results we will copy the unmodified | ||
422 | # static library (containing the debug symbols) into a new directory. | ||
423 | # We will then strip (preserving symbols) the static library in the | ||
424 | # typical location. | ||
425 | # | ||
426 | # return a mapping of files:debugsources | ||
427 | |||
428 | import stat | ||
429 | import shutil | ||
430 | |||
431 | src = file[len(dvar):] | ||
432 | dest = debugstaticlibdir + os.path.dirname(src) + debugstaticdir + "/" + os.path.basename(src) + debugstaticappend | ||
433 | debugfile = dvar + dest | ||
434 | sources = [] | ||
435 | |||
436 | # Copy the file... | ||
437 | bb.utils.mkdirhier(os.path.dirname(debugfile)) | ||
438 | #bb.note("Copy %s -> %s" % (file, debugfile)) | ||
439 | |||
440 | dvar = d.getVar('PKGD') | ||
441 | |||
442 | newmode = None | ||
443 | if not os.access(file, os.W_OK) or os.access(file, os.R_OK): | ||
444 | origmode = os.stat(file)[stat.ST_MODE] | ||
445 | newmode = origmode | stat.S_IWRITE | stat.S_IREAD | ||
446 | os.chmod(file, newmode) | ||
447 | |||
448 | # We need to extract the debug src information here... | ||
449 | if debugsrcdir: | ||
450 | sources = source_info(file, d) | ||
451 | |||
452 | bb.utils.mkdirhier(os.path.dirname(debugfile)) | ||
453 | |||
454 | # Copy the unmodified item to the debug directory | ||
455 | shutil.copy2(file, debugfile) | ||
456 | |||
457 | if newmode: | ||
458 | os.chmod(file, origmode) | ||
459 | |||
460 | return (file, sources) | ||
461 | |||
419 | def copydebugsources(debugsrcdir, sources, d): | 462 | def copydebugsources(debugsrcdir, sources, d): |
420 | # The debug src information written out to sourcefile is further processed | 463 | # The debug src information written out to sourcefile is further processed |
421 | # and copied to the destination here. | 464 | # and copied to the destination here. |
@@ -916,25 +959,37 @@ python split_and_strip_files () { | |||
916 | if d.getVar('PACKAGE_DEBUG_SPLIT_STYLE') == 'debug-file-directory': | 959 | if d.getVar('PACKAGE_DEBUG_SPLIT_STYLE') == 'debug-file-directory': |
917 | # Single debug-file-directory style debug info | 960 | # Single debug-file-directory style debug info |
918 | debugappend = ".debug" | 961 | debugappend = ".debug" |
962 | debugstaticappend = "" | ||
919 | debugdir = "" | 963 | debugdir = "" |
964 | debugstaticdir = "" | ||
920 | debuglibdir = "/usr/lib/debug" | 965 | debuglibdir = "/usr/lib/debug" |
966 | debugstaticlibdir = "/usr/lib/debug-static" | ||
921 | debugsrcdir = "/usr/src/debug" | 967 | debugsrcdir = "/usr/src/debug" |
922 | elif d.getVar('PACKAGE_DEBUG_SPLIT_STYLE') == 'debug-without-src': | 968 | elif d.getVar('PACKAGE_DEBUG_SPLIT_STYLE') == 'debug-without-src': |
923 | # Original OE-core, a.k.a. ".debug", style debug info, but without sources in /usr/src/debug | 969 | # Original OE-core, a.k.a. ".debug", style debug info, but without sources in /usr/src/debug |
924 | debugappend = "" | 970 | debugappend = "" |
971 | debugstaticappend = "" | ||
925 | debugdir = "/.debug" | 972 | debugdir = "/.debug" |
973 | debugstaticdir = "/.debug-static" | ||
926 | debuglibdir = "" | 974 | debuglibdir = "" |
975 | debugstaticlibdir = "" | ||
927 | debugsrcdir = "" | 976 | debugsrcdir = "" |
928 | elif d.getVar('PACKAGE_DEBUG_SPLIT_STYLE') == 'debug-with-srcpkg': | 977 | elif d.getVar('PACKAGE_DEBUG_SPLIT_STYLE') == 'debug-with-srcpkg': |
929 | debugappend = "" | 978 | debugappend = "" |
979 | debugstaticappend = "" | ||
930 | debugdir = "/.debug" | 980 | debugdir = "/.debug" |
981 | debugstaticdir = "/.debug-static" | ||
931 | debuglibdir = "" | 982 | debuglibdir = "" |
983 | debugstaticlibdir = "" | ||
932 | debugsrcdir = "/usr/src/debug" | 984 | debugsrcdir = "/usr/src/debug" |
933 | else: | 985 | else: |
934 | # Original OE-core, a.k.a. ".debug", style debug info | 986 | # Original OE-core, a.k.a. ".debug", style debug info |
935 | debugappend = "" | 987 | debugappend = "" |
988 | debugstaticappend = "" | ||
936 | debugdir = "/.debug" | 989 | debugdir = "/.debug" |
990 | debugstaticdir = "/.debug-static" | ||
937 | debuglibdir = "" | 991 | debuglibdir = "" |
992 | debugstaticlibdir = "" | ||
938 | debugsrcdir = "/usr/src/debug" | 993 | debugsrcdir = "/usr/src/debug" |
939 | 994 | ||
940 | # | 995 | # |
@@ -1051,8 +1106,11 @@ python split_and_strip_files () { | |||
1051 | results = oe.utils.multiprocess_launch(splitdebuginfo, list(elffiles), d, extraargs=(dvar, debugdir, debuglibdir, debugappend, debugsrcdir, d)) | 1106 | results = oe.utils.multiprocess_launch(splitdebuginfo, list(elffiles), d, extraargs=(dvar, debugdir, debuglibdir, debugappend, debugsrcdir, d)) |
1052 | 1107 | ||
1053 | if debugsrcdir and not targetos.startswith("mingw"): | 1108 | if debugsrcdir and not targetos.startswith("mingw"): |
1054 | for file in staticlibs: | 1109 | if (d.getVar('PACKAGE_DEBUG_STATIC_SPLIT') == '1'): |
1055 | results.append( (file, source_info(file, d, fatal=False)) ) | 1110 | results = oe.utils.multiprocess_launch(splitstaticdebuginfo, staticlibs, d, extraargs=(dvar, debugstaticdir, debugstaticlibdir, debugstaticappend, debugsrcdir, d)) |
1111 | else: | ||
1112 | for file in staticlibs: | ||
1113 | results.append( (file,source_info(file, d)) ) | ||
1056 | 1114 | ||
1057 | sources = set() | 1115 | sources = set() |
1058 | for r in results: | 1116 | for r in results: |
@@ -1121,6 +1179,9 @@ python split_and_strip_files () { | |||
1121 | sfiles.append((file, elf_file, strip)) | 1179 | sfiles.append((file, elf_file, strip)) |
1122 | for f in kernmods: | 1180 | for f in kernmods: |
1123 | sfiles.append((f, 16, strip)) | 1181 | sfiles.append((f, 16, strip)) |
1182 | if (d.getVar('PACKAGE_STRIP_STATIC') == '1' or d.getVar('PACKAGE_DEBUG_STATIC_SPLIT') == '1'): | ||
1183 | for f in staticlibs: | ||
1184 | sfiles.append((f, 16, strip)) | ||
1124 | 1185 | ||
1125 | oe.utils.multiprocess_launch(oe.package.runstrip, sfiles, d) | 1186 | oe.utils.multiprocess_launch(oe.package.runstrip, sfiles, d) |
1126 | 1187 | ||
@@ -1188,7 +1249,7 @@ python populate_packages () { | |||
1188 | dir = os.sep | 1249 | dir = os.sep |
1189 | for f in (files + dirs): | 1250 | for f in (files + dirs): |
1190 | path = "." + os.path.join(dir, f) | 1251 | path = "." + os.path.join(dir, f) |
1191 | if "/.debug/" in path or path.endswith("/.debug"): | 1252 | if "/.debug/" in path or "/.debug-static/" in path or path.endswith("/.debug"): |
1192 | debug.append(path) | 1253 | debug.append(path) |
1193 | 1254 | ||
1194 | for pkg in packages: | 1255 | for pkg in packages: |
diff --git a/meta/conf/bitbake.conf b/meta/conf/bitbake.conf index 8b4621f9b9..954c06b313 100644 --- a/meta/conf/bitbake.conf +++ b/meta/conf/bitbake.conf | |||
@@ -325,7 +325,7 @@ FILES_${PN}-staticdev = "${libdir}/*.a ${base_libdir}/*.a ${libdir}/${BPN}/*.a" | |||
325 | SECTION_${PN}-staticdev = "devel" | 325 | SECTION_${PN}-staticdev = "devel" |
326 | RDEPENDS_${PN}-staticdev = "${PN}-dev (= ${EXTENDPKGV})" | 326 | RDEPENDS_${PN}-staticdev = "${PN}-dev (= ${EXTENDPKGV})" |
327 | 327 | ||
328 | FILES_${PN}-dbg = "/usr/lib/debug /usr/src/debug" | 328 | FILES_${PN}-dbg = "/usr/lib/debug /usr/lib/debug-static /usr/src/debug" |
329 | SECTION_${PN}-dbg = "devel" | 329 | SECTION_${PN}-dbg = "devel" |
330 | ALLOW_EMPTY_${PN}-dbg = "1" | 330 | ALLOW_EMPTY_${PN}-dbg = "1" |
331 | 331 | ||