mklibs: update to version 0.1.43
[openwrt/staging/nbd.git] / tools / mklibs / patches / 012-musl-libc-link.patch
diff --git a/tools/mklibs/patches/012-musl-libc-link.patch b/tools/mklibs/patches/012-musl-libc-link.patch
new file mode 100644 (file)
index 0000000..f1e6506
--- /dev/null
@@ -0,0 +1,25 @@
+--- a/src/mklibs
++++ b/src/mklibs
+@@ -605,6 +605,10 @@ 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.1"):
++                extra_pre_obj.append("-Wl,-Bsymbolic-functions -Wl,-e,_dlstart -Wl,--exclude-libs=ALL -Wl,--no-undefined  -Wl,--sort-section,alignment -Wl,--sort-common")
++                pic_file = "-Wl,--whole-archive " + pic_file + " -Wl,--no-whole-archive"
++
+             map_file = find_pic_map(library)
+             if map_file:
+                 extra_flags.append("-Wl,--version-script=" + map_file)
+@@ -619,8 +623,9 @@ while 1:
+             cmd.append(pic_file)
+             cmd.extend(extra_post_obj)
+             cmd.extend(extra_flags)
+-            cmd.extend(["-L%s" % a for a in [dest_path] + [sysroot + b for b in lib_path if sysroot == "" or b not in ("/" + libdir + "/", "/usr/" + libdir + "/")]])
+-            if soname != "libgcc_s.so.1":
++            if soname in ("libc.so.1"):
++                cmd.append("-lgcc_initial")
++            elif soname != "libgcc_s.so.1":
+                 cmd.append(library_depends_gcc_libnames(so_file))
+                 cmd.append(libgcc_link)
+             command(target + "gcc", *cmd)