[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#335930: mklibs: Substantial reduction of command line for linker call



Package: mklibs
Version: 0.1.18
Severity: wishlist
Tags: patch

The patch below creates a tempfile with a linker script to replace all the
-u options with EXTERN(<symbol>) statements in the gcc call for library
recompilation.

During a build of libc6 for the d-i gtk frontend, this reduces the length
of the command line from over 6000 characters to just over 1000.
Command line length could cause script failure in extreme cases.

Further command line reduction would be possible by moving more options to
the linker script (prime candidate: the -L options).

--- /usr/bin/mklibs     2005-10-22 21:33:43.000000000 +0200
+++ util/mklibs 2005-10-26 00:04:59.000000000 +0200
@@ -47,6 +47,7 @@
 import os
 import glob
 import getopt
+import tempfile
 from stat import *

 DEBUG_NORMAL  = 1
@@ -493,11 +494,18 @@
             map_file = find_pic_map(library)
             if map_file:
                 extra_flags = extra_flags + " -Wl,--version-script=" + map_file
-            # compile in only used symbols
+            # create linker script with symbols to be treated as EXTERN
+            (ls_fd, ls_fn) = tempfile.mkstemp('.mklibs')
+            os.close(ls_fd)
+            ls_fh=open(ls_fn, 'w')
+            for a in symbols:
+                ls_fh.write('EXTERN(' + a + ')\n')
+            ls_fh.close()
+            # compile in only used symbols using the linker script
             command(target + "gcc",
                 "-nostdlib -nostartfiles -shared -Wl,-soname=" + soname,\
-                ' '.join(["-u%s" % a for a in symbols]), \
+                ls_fn, \
                 "-o", dest_path + "/" + so_file_name + "-so", \
                 extra_pre_obj, \
                 pic_file, \
                 extra_post_obj, \
@@ -505,6 +513,8 @@
                 "-lgcc", \
                 ' '.join(["-L%s" % a for a in [dest_path] + lib_path]), \
                 library_depends_gcc_libnames(so_file))
+            # delete linker script
+            os.unlink(ls_fn)
             # strip result
             command(target + "objcopy", "--strip-unneeded -R .note -R .comment",
                       dest_path + "/" + so_file_name + "-so",

Attachment: pgpX77A9SzVHs.pgp
Description: PGP signature


Reply to: