Hi, I've mentioned previously I've used “MKLIBS = mklibs-copy” to build g-i images, because I was facing some mklibs failures in X modules.
The first patch aims at fixing the way mklibs is throwing python exceptions. The second patch makes it possible to use that instead (meaning some library reduction can happen, as opposed to using mklibs-copy): MKLIBS = mklibs -X /usr/lib/xorg/modules AFAICT (please keep in mind I'm quite new to this), the issue was that an X module was needing some symbols available in another X module, without referencing it (I guess one plugin gets access to the other plugin's symbols through the Xorg binary itself). Comments welcome. Mraw, KiBi.
Modernize exception raising. Raising string exceptions is deprecated, turn strings into proper Exception objects. --- a/packages/mklibs/src/mklibs.py +++ b/packages/mklibs/src/mklibs.py @@ -85,7 +85,7 @@ def regexpfilter(list, regexp, groupnr = 1): def elf_header(obj): if not os.access(obj, os.F_OK): - raise "Cannot find lib: " + obj + raise Exception("Cannot find lib: " + obj) output = command("mklibs-readelf", "--print-elf-header", obj) s = [int(i) for i in output[0].split()] return {'class': s[0], 'data': s[1], 'machine': s[2], 'flags': s[3]} @@ -93,21 +93,21 @@ def elf_header(obj): # Return a set of rpath strings for the passed object def rpath(obj): if not os.access(obj, os.F_OK): - raise "Cannot find lib: " + obj + raise Exception("Cannot find lib: " + obj) output = command("mklibs-readelf", "--print-rpath", obj) return [root + "/" + x for x in output] # Return a set of libraries the passed objects depend on. def library_depends(obj): if not os.access(obj, os.F_OK): - raise "Cannot find lib: " + obj + raise Exception("Cannot find lib: " + obj) return command("mklibs-readelf", "--print-needed", obj) # Return a list of libraries the passed objects depend on. The # libraries are in "-lfoo" format suitable for passing to gcc. def library_depends_gcc_libnames(obj): if not os.access(obj, os.F_OK): - raise "Cannot find lib: " + obj + raise Exception("Cannot find lib: " + obj) libs = library_depends(obj) ret = [] for i in libs: @@ -139,7 +139,7 @@ class UndefinedSymbol(Symbol): # Return undefined symbols in an object as a set of tuples (name, weakness) def undefined_symbols(obj): if not os.access(obj, os.F_OK): - raise "Cannot find lib" + obj + raise Exception("Cannot find lib" + obj) output = command("mklibs-readelf", "--print-symbols-undefined", obj) @@ -194,7 +194,7 @@ class ProvidedSymbol(Symbol): # Return a set of symbols provided by a library def provided_symbols(obj): if not os.access(obj, os.F_OK): - raise "Cannot find lib" + obj + raise Exception("Cannot find lib" + obj) library = extract_soname(obj) output = command("mklibs-readelf", "--print-symbols-provided", obj) @@ -500,7 +500,7 @@ while 1: # No progress in last pass. Verify all remaining symbols are weak. for name in unresolved: if not needed_symbols[name].weak: - raise "Unresolvable symbol %s" % name + raise Exception("Unresolvable symbol %s" % name) break previous_pass_unresolved = unresolved @@ -535,7 +535,7 @@ while 1: for name in needed_symbols: if not name in symbol_provider: if not needed_symbols[name].weak: - raise "No library provides non-weak %s" % name + raise Exception("No library provides non-weak %s" % name) else: lib = symbol_provider[name] library_symbols_used[lib].add(library_symbols[lib][name])
Add support for excluding some DSO based on filename patterns. --- a/packages/mklibs/src/mklibs.py +++ b/packages/mklibs/src/mklibs.py @@ -302,6 +302,8 @@ def version(vers): ## --target Use as prefix for gcc or binutils calls ## ## -d, --dest-dir DIRECTORY Create libraries in DIRECTORY. +## +## -X pattern1[,pattern2,...] Exclude shared objects with patternX in their names. ## ## Required arguments for long options are also mandatory for the short options. @@ -310,7 +312,7 @@ vers="0.12" os.environ['LC_ALL'] = "C" # Argument parsing -opts = "L:DnvVhd:r:l:" +opts = "L:DnvVhd:r:l:X:" longopts = ["no-default-lib", "dry-run", "verbose", "version", "help", "dest-dir=", "ldlib=", "libc-extras-dir=", "target=", "root=", "sysroot=", "gcc-options=", "libdir="] @@ -332,6 +334,7 @@ force_libs = [] gcc_options = [] so_pattern = re.compile("((lib|ld).*)\.so(\..+)*") script_pattern = re.compile("^#!\s*/") +exclude_dsos = [] try: optlist, proglist = getopt.getopt(sys.argv[1:], opts, longopts) @@ -372,6 +375,8 @@ for opt, arg in optlist: elif opt in ("--version", "-V"): version(vers) sys.exit(0) + elif opt == "-X": + exclude_dsos.extend(arg.split(",")) else: print "WARNING: unknown option: " + opt + "\targ: " + arg @@ -458,6 +463,12 @@ while 1: needed_symbols = {} libraries = set(force_libs) for obj in objects.values(): + matches = [x for x in exclude_dsos if obj.find(x)!=-1] + if len(matches) > 0: + debug(DEBUG_VERBOSE, "Object: SKIPPED: %s" % obj) + debug(DEBUG_VERBOSE, " due to exclude pattern: %s" % matches[0]) + continue + for symbol in undefined_symbols(obj): # Some undefined symbols in libthread_db are defined in # the application that uses it. __gnu_local_gp is defined
signature.asc
Description: Digital signature