From c8b7065f61b75cab17b3b39c5091aa8de14f0aa8 Mon Sep 17 00:00:00 2001 From: Rosen Penev Date: Thu, 24 Feb 2022 20:27:34 -0800 Subject: [PATCH] tools/mklibs: update to 0.1.45 Refresh 2to3 patch. Upstream partially did this against some older python version. This is still needed. Refreshed other patches to be python3 safe. Remove uClibc patches as only musl is present now. Refresh others. Signed-off-by: Rosen Penev --- tools/mklibs/Makefile | 4 +- .../patches/002-disable_symbol_checks.patch | 4 +- tools/mklibs/patches/003-no_copy.patch | 6 +- tools/mklibs/patches/005-duplicate_syms.patch | 2 +- tools/mklibs/patches/006-uclibc_init.patch | 14 -- tools/mklibs/patches/007-gc_sections.patch | 2 +- .../patches/008-uclibc_libgcc_link.patch | 2 +- .../009-uclibc_libpthread_symbols.patch | 63 ----- .../mklibs/patches/011-remove_multiarch.patch | 2 +- tools/mklibs/patches/100-apply-2to3.patch | 225 ++---------------- 10 files changed, 37 insertions(+), 287 deletions(-) delete mode 100644 tools/mklibs/patches/006-uclibc_init.patch delete mode 100644 tools/mklibs/patches/009-uclibc_libpthread_symbols.patch diff --git a/tools/mklibs/Makefile b/tools/mklibs/Makefile index 7c9ffffbad..efa912bf6d 100644 --- a/tools/mklibs/Makefile +++ b/tools/mklibs/Makefile @@ -7,11 +7,11 @@ include $(TOPDIR)/rules.mk PKG_NAME:=mklibs -PKG_VERSION:=0.1.44 +PKG_VERSION:=0.1.45 PKG_SOURCE:=$(PKG_NAME)_$(PKG_VERSION).tar.xz PKG_SOURCE_URL:=@DEBIAN/pool/main/m/mklibs/ -PKG_HASH:=3af0b6bd35e5b6fc58d8b68827fbae2ff6b7e20dd2b238ccb9b49d84722066c2 +PKG_HASH:=dd92a904b3942566f713fe536cd77dd1a5cfc62243c0e0bc6bb5d866e37422f3 HOST_FIXUP:=autoreconf diff --git a/tools/mklibs/patches/002-disable_symbol_checks.patch b/tools/mklibs/patches/002-disable_symbol_checks.patch index e18dfa8e55..96ca7a5f83 100644 --- a/tools/mklibs/patches/002-disable_symbol_checks.patch +++ b/tools/mklibs/patches/002-disable_symbol_checks.patch @@ -5,7 +5,7 @@ for name in unresolved: if not needed_symbols[name].weak: - raise Exception("Unresolvable symbol %s" % name) -+ print "WARNING: Unresolvable symbol %s" % name ++ print("WARNING: Unresolvable symbol %s" % name) break previous_pass_unresolved = unresolved @@ -14,7 +14,7 @@ if not name in symbol_provider: if not needed_symbols[name].weak: - raise Exception("No library provides non-weak %s" % name) -+ print "WARNING: Unresolvable symbol %s" % name ++ print("WARNING: Unresolvable symbol %s" % name) else: lib = symbol_provider[name] library_symbols_used[lib].add(library_symbols[lib][name]) diff --git a/tools/mklibs/patches/003-no_copy.patch b/tools/mklibs/patches/003-no_copy.patch index 75beccf82e..bc1ae8d73d 100644 --- a/tools/mklibs/patches/003-no_copy.patch +++ b/tools/mklibs/patches/003-no_copy.patch @@ -32,11 +32,11 @@ - dest_path + "/" + so_file_name + "-so", - dest_path + "/" + so_file_name + "-so-stripped") ## DEBUG - debug(DEBUG_VERBOSE, so_file, "\t", `os.stat(so_file)[ST_SIZE]`) + debug(DEBUG_VERBOSE, so_file, "\t", str(os.stat(so_file)[ST_SIZE])) debug(DEBUG_VERBOSE, dest_path + "/" + so_file_name + "-so", "\t", - `os.stat(dest_path + "/" + so_file_name + "-so")[ST_SIZE]`) + str(os.stat(dest_path + "/" + so_file_name + "-so")[ST_SIZE])) - debug(DEBUG_VERBOSE, dest_path + "/" + so_file_name + "-so-stripped", -- "\t", `os.stat(dest_path + "/" + so_file_name + "-so-stripped")[ST_SIZE]`) +- "\t", str(os.stat(dest_path + "/" + so_file_name + "-so-stripped")[ST_SIZE])) # Finalising libs and cleaning up -for lib in regexpfilter(os.listdir(dest_path), "(.*)-so-stripped$"): diff --git a/tools/mklibs/patches/005-duplicate_syms.patch b/tools/mklibs/patches/005-duplicate_syms.patch index b0fdab7b10..2627203fab 100644 --- a/tools/mklibs/patches/005-duplicate_syms.patch +++ b/tools/mklibs/patches/005-duplicate_syms.patch @@ -23,7 +23,7 @@ for name in needed_symbols: - if not name in symbol_provider: - if not needed_symbols[name].weak: -- print "WARNING: Unresolvable symbol %s" % name +- print("WARNING: Unresolvable symbol %s" % name) - else: - lib = symbol_provider[name] - library_symbols_used[lib].add(library_symbols[lib][name]) diff --git a/tools/mklibs/patches/006-uclibc_init.patch b/tools/mklibs/patches/006-uclibc_init.patch deleted file mode 100644 index da83340fe4..0000000000 --- a/tools/mklibs/patches/006-uclibc_init.patch +++ /dev/null @@ -1,14 +0,0 @@ ---- a/src/mklibs -+++ b/src/mklibs -@@ -604,6 +604,11 @@ while 1: - extra_post_obj.append(sysroot + libc_extras_dir + "/sofini.o") - symbols.add(ProvidedSymbol('__dso_handle', None, None, True)) - -+ if soname in ("libc.so.0"): -+ symbols.add(ProvidedSymbol('__uClibc_init', None, None, True)) -+ symbols.add(ProvidedSymbol('__uClibc_fini', None, None, True)) -+ extra_flags.append("-Wl,-init,__uClibc_init") -+ - map_file = find_pic_map(library) - if map_file: - extra_flags.append("-Wl,--version-script=" + map_file) diff --git a/tools/mklibs/patches/007-gc_sections.patch b/tools/mklibs/patches/007-gc_sections.patch index 2fdf4034da..3d098ae426 100644 --- a/tools/mklibs/patches/007-gc_sections.patch +++ b/tools/mklibs/patches/007-gc_sections.patch @@ -1,6 +1,6 @@ --- a/src/mklibs +++ b/src/mklibs -@@ -616,7 +616,7 @@ while 1: +@@ -611,7 +611,7 @@ while 1: # compile in only used symbols cmd = [] cmd.extend(gcc_options) diff --git a/tools/mklibs/patches/008-uclibc_libgcc_link.patch b/tools/mklibs/patches/008-uclibc_libgcc_link.patch index 34cd9d3ab3..a221278d2a 100644 --- a/tools/mklibs/patches/008-uclibc_libgcc_link.patch +++ b/tools/mklibs/patches/008-uclibc_libgcc_link.patch @@ -22,7 +22,7 @@ symbols.update(library_symbols_used[library]) -@@ -623,9 +621,10 @@ while 1: +@@ -618,9 +616,10 @@ while 1: cmd.append(pic_file) cmd.extend(extra_post_obj) cmd.extend(extra_flags) diff --git a/tools/mklibs/patches/009-uclibc_libpthread_symbols.patch b/tools/mklibs/patches/009-uclibc_libpthread_symbols.patch deleted file mode 100644 index 0d4d3e95aa..0000000000 --- a/tools/mklibs/patches/009-uclibc_libpthread_symbols.patch +++ /dev/null @@ -1,63 +0,0 @@ ---- a/src/mklibs -+++ b/src/mklibs -@@ -173,9 +173,10 @@ def undefined_symbols(obj): - return result - - class ProvidedSymbol(Symbol): -- def __init__(self, name, version, library, default_version): -+ def __init__(self, name, version, library, default_version, weak): - super(ProvidedSymbol, self).__init__(name, version, library) - self.default_version = default_version -+ self.weak = weak - - def base_names(self): - ret = [] -@@ -216,11 +217,15 @@ def provided_symbols(obj): - if version_string.lower() not in ('base', 'none'): - version = version_string - -+ weak = False -+ if weak_string.lower() == 'true': -+ weak = True -+ - default_version = False - if default_version_string.lower() == 'true': - default_version = True - -- result.append(ProvidedSymbol(name, version, library, default_version)) -+ result.append(ProvidedSymbol(name, version, library, default_version, weak)) - - return result - -@@ -509,6 +514,9 @@ while 1: - debug(DEBUG_SPAM, "present_symbols adding %s" % symbol) - names = symbol.base_names() - for name in names: -+ if name in present_symbols: -+ if symbol.library != present_symbols[name].library: -+ needed_symbols[name] = UndefinedSymbol(name, True, symbol.version, symbol.library) - present_symbols[name] = symbol - - # are we finished? -@@ -600,12 +608,16 @@ while 1: - # may segfault in ptmalloc_init due to undefined weak reference - extra_pre_obj.append(sysroot + libc_extras_dir + "/soinit.o") - extra_post_obj.append(sysroot + libc_extras_dir + "/sofini.o") -- symbols.add(ProvidedSymbol('__dso_handle', None, None, True)) -+ symbols.add(ProvidedSymbol('__dso_handle', None, None, True, True)) - -- if soname in ("libc.so.0"): -- symbols.add(ProvidedSymbol('__uClibc_init', None, None, True)) -- symbols.add(ProvidedSymbol('__uClibc_fini', None, None, True)) -- extra_flags.append("-Wl,-init,__uClibc_init") -+ if soname == "libc.so.0": -+ symbols.add(ProvidedSymbol('__uClibc_init', None, None, True, True)) -+ symbols.add(ProvidedSymbol('__uClibc_fini', None, None, True, True)) -+ extra_pre_obj.append("-Wl,-init,__uClibc_init") -+ -+ if soname == "libpthread.so.0": -+ symbols.add(ProvidedSymbol('__pthread_initialize_minimal_internal', None, None, True, True)) -+ extra_flags.append("-Wl,-z,nodelete,-z,initfirst,-init=__pthread_initialize_minimal_internal") - - map_file = find_pic_map(library) - if map_file: diff --git a/tools/mklibs/patches/011-remove_multiarch.patch b/tools/mklibs/patches/011-remove_multiarch.patch index 23e45cc12c..8c0bfdf1a0 100644 --- a/tools/mklibs/patches/011-remove_multiarch.patch +++ b/tools/mklibs/patches/011-remove_multiarch.patch @@ -1,6 +1,6 @@ --- a/src/mklibs +++ b/src/mklibs -@@ -274,6 +274,7 @@ def extract_soname(so_file): +@@ -269,6 +269,7 @@ def extract_soname(so_file): return "" def multiarch(paths): diff --git a/tools/mklibs/patches/100-apply-2to3.patch b/tools/mklibs/patches/100-apply-2to3.patch index 9f2ae6c438..dcacbab205 100644 --- a/tools/mklibs/patches/100-apply-2to3.patch +++ b/tools/mklibs/patches/100-apply-2to3.patch @@ -1,10 +1,10 @@ --- a/src/mklibs +++ b/src/mklibs -@@ -57,18 +57,18 @@ debuglevel = DEBUG_NORMAL +@@ -57,17 +57,17 @@ debuglevel = DEBUG_NORMAL def debug(level, *msg): if debuglevel >= level: -- print string.join(msg) +- print(string.join(msg)) + print(' '.join(msg)) # return a list of lines of output of the command @@ -15,82 +15,22 @@ output = pipe.read().strip() status = pipe.close() if status is not None and os.WEXITSTATUS(status) != 0: -- print "Command failed with status", os.WEXITSTATUS(status), ":", \ -- command, string.join(args) -- print "With output:", output -+ print("Command failed with status", os.WEXITSTATUS(status), ":", \ + print("Command failed with status", os.WEXITSTATUS(status), ":", \ +- command, string.join(args)) + command, ' '.join(args)) -+ print("With output:", output) + print("With output:", output) sys.exit(1) return [i for i in output.split('\n') if i] - -@@ -204,7 +204,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 Exception("Cannot find lib" + obj) -+ raise Exception("Cannot find lib " + obj) - library = extract_soname(obj) - - output = command("mklibs-readelf", "--print-symbols-provided", obj) -@@ -297,27 +297,27 @@ def usage(was_err): - outfd = sys.stderr - else: - outfd = sys.stdout -- print >> outfd, "Usage: mklibs [OPTION]... -d DEST FILE ..." -- print >> outfd, "Make a set of minimal libraries for FILE(s) in DEST." -- print >> outfd, "" -- print >> outfd, " -d, --dest-dir DIRECTORY create libraries in DIRECTORY" -- print >> outfd, " -D, --no-default-lib omit default libpath (", ':'.join(default_lib_path), ")" -- print >> outfd, " -L DIRECTORY[:DIRECTORY]... add DIRECTORY(s) to the library search path" -- print >> outfd, " -l LIBRARY add LIBRARY always" -- print >> outfd, " --ldlib LDLIB use LDLIB for the dynamic linker" -- print >> outfd, " --libc-extras-dir DIRECTORY look for libc extra files in DIRECTORY" -- print >> outfd, " --target TARGET prepend TARGET- to the gcc and binutils calls" -- print >> outfd, " --root ROOT search in ROOT for library rpaths" -- print >> outfd, " --sysroot ROOT prepend ROOT to all paths for libraries" -- print >> outfd, " --gcc-options OPTIONS pass OPTIONS to gcc" -- print >> outfd, " --libdir DIR use DIR (e.g. lib64) in place of lib in default paths" -- print >> outfd, " -v, --verbose explain what is being done" -- print >> outfd, " -h, --help display this help and exit" -+ print("Usage: mklibs [OPTION]... -d DEST FILE ...", file=outfd) -+ print("Make a set of minimal libraries for FILE(s) in DEST.", file=outfd) -+ print("", file=outfd) -+ print(" -d, --dest-dir DIRECTORY create libraries in DIRECTORY", file=outfd) +@@ -296,7 +296,7 @@ def usage(was_err): + print("Make a set of minimal libraries for FILE(s, file=outfd) in DEST.", file=outfd) + print("" , file=outfd) + print(" -d, --dest-dir DIRECTORY create libraries in DIRECTORY", file=outfd) +- print(" -D, --no-default-lib omit default libpath (", ':'.join(default_lib_path, file=outfd), ", file=outfd)", file=outfd) + print(" -D, --no-default-lib omit default libpath (", ':'.join(default_lib_path), ")", file=outfd) -+ print(" -L DIRECTORY[:DIRECTORY]... add DIRECTORY(s) to the library search path", file=outfd) -+ print(" -l LIBRARY add LIBRARY always", file=outfd) -+ print(" --ldlib LDLIB use LDLIB for the dynamic linker", file=outfd) -+ print(" --libc-extras-dir DIRECTORY look for libc extra files in DIRECTORY", file=outfd) -+ print(" --target TARGET prepend TARGET- to the gcc and binutils calls", file=outfd) -+ print(" --root ROOT search in ROOT for library rpaths", file=outfd) -+ print(" --sysroot ROOT prepend ROOT to all paths for libraries", file=outfd) -+ print(" --gcc-options OPTIONS pass OPTIONS to gcc", file=outfd) -+ print(" --libdir DIR use DIR (e.g. lib64) in place of lib in default paths", file=outfd) -+ print(" -v, --verbose explain what is being done", file=outfd) -+ print(" -h, --help display this help and exit", file=outfd) - sys.exit(was_err) - - def version(vers): -- print "mklibs: version ",vers -- print "" -+ print("mklibs: version ",vers) -+ print("") - - #################### main #################### - ## Usage: ./mklibs.py [OPTION]... -d DEST FILE ... -@@ -368,8 +368,8 @@ script_pattern = re.compile("^#!\s*/") - - try: - optlist, proglist = getopt.getopt(sys.argv[1:], opts, longopts) --except getopt.GetoptError, msg: -- print >> sys.stderr, msg -+except getopt.GetoptError as msg: -+ print(msg, file=sys.stderr) - usage(1) - - for opt, arg in optlist: -@@ -377,7 +377,7 @@ for opt, arg in optlist: + print(" -L DIRECTORY[:DIRECTORY]... add DIRECTORY(s, file=outfd) to the library search path", file=outfd) + print(" -l LIBRARY add LIBRARY always", file=outfd) + print(" --ldlib LDLIB use LDLIB for the dynamic linker", file=outfd) +@@ -372,7 +372,7 @@ for opt, arg in optlist: if debuglevel < DEBUG_SPAM: debuglevel = debuglevel + 1 elif opt == "-L": @@ -99,7 +39,7 @@ elif opt in ("-d", "--dest-dir"): dest_path = arg elif opt in ("-D", "--no-default-lib"): -@@ -396,17 +396,17 @@ for opt, arg in optlist: +@@ -391,7 +391,7 @@ for opt, arg in optlist: elif opt in ("-l",): force_libs.append(arg) elif opt == "--gcc-options": @@ -108,19 +48,7 @@ elif opt == "--libdir": libdir = arg elif opt in ("--help", "-h"): -- usage(0) -+ usage(0) - sys.exit(0) - elif opt in ("--version", "-V"): - version(vers) - sys.exit(0) - else: -- print "WARNING: unknown option: " + opt + "\targ: " + arg -+ print("WARNING: unknown option: " + opt + "\targ: " + arg) - - if include_default_lib_path == "yes": - lib_path.extend([a.replace("/lib/", "/" + libdir + "/") for a in default_lib_path]) -@@ -424,22 +424,22 @@ if ldlib == "LDLIB": +@@ -419,17 +419,17 @@ if ldlib == "LDLIB": objects = {} # map from inode to filename for prog in proglist: inode = os.stat(prog)[ST_INO] @@ -141,45 +69,20 @@ output = command("mklibs-readelf", "--print-interp", obj) if output: ldlib = output.pop() -- if ldlib: -- break -+ if ldlib: -+ break - - if not ldlib: - sys.exit("E: Dynamic linker not found, aborting.") -@@ -454,10 +454,10 @@ for obj in sorted(objects.values()): - for rpath_elem in rpath_val: - if not rpath_elem in lib_rpath: - if debuglevel >= DEBUG_VERBOSE: -- print "Adding rpath " + rpath_elem + " for " + obj -+ print("Adding rpath " + rpath_elem + " for " + obj) - lib_rpath.append(rpath_elem) - else: -- print "warning: " + obj + " may need rpath, but --root not specified" -+ print("warning: " + obj + " may need rpath, but --root not specified") - - lib_path.extend(lib_rpath) - -@@ -465,12 +465,12 @@ passnr = 1 - available_libs = [] - previous_pass_unresolved = set() +@@ -462,9 +462,9 @@ previous_pass_unresolved = set() while 1: -- debug(DEBUG_NORMAL, "I: library reduction pass", `passnr`) -+ debug(DEBUG_NORMAL, "I: library reduction pass", repr(passnr)) + debug(DEBUG_NORMAL, "I: library reduction pass", str(passnr)) if debuglevel >= DEBUG_VERBOSE: -- print "Objects:", +- print("Objects:",) - for obj in sorted([x[string.rfind(x, '/') + 1:] for x in objects.values()]): -- print obj, -- print +- print(obj,) + print("Objects:", end=' ') + for obj in sorted([x[x.rfind('/') + 1:] for x in list(objects.values())]): + print(obj, end=' ') -+ print() + print() passnr = passnr + 1 - # Gather all already reduced libraries and treat them as objects as well -@@ -479,7 +479,7 @@ while 1: +@@ -474,7 +474,7 @@ while 1: obj = dest_path + "/" + lib small_libs.append(obj) inode = os.stat(obj)[ST_INO] @@ -188,7 +91,7 @@ debug(DEBUG_SPAM, obj, "is hardlink to", objects[inode]) else: objects[inode] = obj -@@ -509,7 +509,7 @@ while 1: +@@ -504,7 +504,7 @@ while 1: present_symbols = {} checked_libs = small_libs checked_libs.extend(available_libs) @@ -197,70 +100,8 @@ for lib in checked_libs: for symbol in provided_symbols(lib): debug(DEBUG_SPAM, "present_symbols adding %s" % symbol) -@@ -529,8 +529,8 @@ while 1: - unresolved.add(name) - num_unresolved = num_unresolved + 1 - -- debug (DEBUG_NORMAL, `len(needed_symbols)`, "symbols,", -- `num_unresolved`, "unresolved") -+ debug (DEBUG_NORMAL, repr(len(needed_symbols)), "symbols,", -+ repr(num_unresolved), "unresolved") - - if num_unresolved == 0: - break -@@ -539,7 +539,7 @@ while 1: - # No progress in last pass. Verify all remaining symbols are weak. - for name in unresolved: - if not needed_symbols[name].weak: -- print "WARNING: Unresolvable symbol %s" % name -+ print("WARNING: Unresolvable symbol %s" % name) - break - - previous_pass_unresolved = unresolved -@@ -641,9 +641,9 @@ while 1: - command(target + "gcc", *cmd) - - ## DEBUG -- debug(DEBUG_VERBOSE, so_file, "\t", `os.stat(so_file)[ST_SIZE]`) -+ debug(DEBUG_VERBOSE, so_file, "\t", repr(os.stat(so_file)[ST_SIZE])) - debug(DEBUG_VERBOSE, dest_path + "/" + so_file_name + "-so", "\t", -- `os.stat(dest_path + "/" + so_file_name + "-so")[ST_SIZE]`) -+ repr(os.stat(dest_path + "/" + so_file_name + "-so")[ST_SIZE])) - - # Finalising libs and cleaning up - for lib in regexpfilter(os.listdir(dest_path), "(.*)-so$"): -@@ -680,4 +680,4 @@ if not os.access(dest_path + "/" + ld_fu - command(target + "objcopy", "--strip-unneeded -R .note -R .comment", - ld_file, dest_path + "/" + ld_full_path) - --os.chmod(dest_path + "/" + ld_full_path, 0755) -+os.chmod(dest_path + "/" + ld_full_path, 0o755) --- a/src/mklibs-copy +++ b/src/mklibs-copy -@@ -51,9 +51,9 @@ def command(command, *args): - output = pipe.read().strip() - status = pipe.close() - if status is not None and os.WEXITSTATUS(status) != 0: -- print "Command failed with status", os.WEXITSTATUS(status), ":", \ -- command, ' '.join(args) -- print "With output:", output -+ print("Command failed with status", os.WEXITSTATUS(status), ":", \ -+ command, ' '.join(args)) -+ print("With output:", output) - sys.exit(1) - return output.split('\n') - -@@ -134,8 +134,8 @@ def multiarch(paths): - return paths - - def version(vers): -- print "mklibs: version ",vers -- print "" -+ print("mklibs: version ",vers) -+ print("") - - # Clean the environment - vers="0.12" @@ -159,7 +159,7 @@ if include_default_lib_path: objects = {} # map from inode to filename for prog in proglist: @@ -270,23 +111,15 @@ logger.debug("%s is a hardlink to %s", prog, objects[inode]) elif so_pattern.match(prog): logger.debug("%s is a library", prog) -@@ -169,12 +169,12 @@ for prog in proglist: +@@ -169,7 +169,7 @@ for prog in proglist: logger.debug("%s is no ELF", prog) if not ldlib: - for obj in objects.values(): + for obj in list(objects.values()): output = command("mklibs-readelf", "-i", obj) -- for x in output: -+ for x in output: - ldlib = x -- if ldlib: -- break -+ if ldlib: -+ break - - if not ldlib: - sys.exit("E: Dynamic linker not found, aborting.") + for x in output: + ldlib = x @@ -182,7 +182,7 @@ if not ldlib: logger.info('Using %s as dynamic linker', ldlib) @@ -319,9 +152,3 @@ libraries.update(library_depends(obj)) if libraries == previous_pass_libraries: -@@ -272,4 +272,4 @@ if not os.access(dest_path + "/" + ld_fu - command(target + "objcopy", "--strip-unneeded -R .note -R .comment", - ld_file, dest_path + "/" + ld_full_path) - --os.chmod(dest_path + "/" + ld_full_path, 0755) -+os.chmod(dest_path + "/" + ld_full_path, 0o755)