summaryrefslogtreecommitdiffstats
path: root/meta/classes/package.bbclass
diff options
context:
space:
mode:
authorMark Hatle <mark.hatle@kernel.crashing.org>2020-02-07 20:20:08 (GMT)
committerRichard Purdie <richard.purdie@linuxfoundation.org>2020-02-08 13:20:02 (GMT)
commit38a754214a84ddfd27e537babf2bf5d992371b67 (patch)
tree24ba06d7106bb8287b59be3874ddd0193351df47 /meta/classes/package.bbclass
parentdae03ec7e801dd4dc781de582ba169a0fc580739 (diff)
downloadpoky-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/classes/package.bbclass')
-rw-r--r--meta/classes/package.bbclass67
1 files changed, 64 insertions, 3 deletions
diff --git a/meta/classes/package.bbclass b/meta/classes/package.bbclass
index 7080d63..1efc396 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
419def 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
419def copydebugsources(debugsrcdir, sources, d): 462def 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: