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

Re: mklibs patch: fix invalid library search path



> If mklibs is called with both --root and --sysroot specified, and> for a library found in rpath, mklibs searches this library in
> <sysroot>/<root>/<rpath> which is an invalid path.  Since <root>
> already points to an absolute directory on host, we should not
> add <sysroot> prefix to it.  Here is a mklibs patch for this issue.
> 
> Lei
> 
> 
> * Fix invalid search path for rpath libraries
> 
> diff --git a/src/mklibs b/src/mklibs
> index ef15147..71ef4da 100755
> --- a/src/mklibs
> +++ b/src/mklibs
> @@ -233,6 +233,9 @@ def find_lib(lib):
>      for path in lib_path:
>          if os.access(sysroot + path + "/" + lib, os.F_OK):
>              return sysroot + path + "/" + lib
> +    for path in lib_rpath:
> +        if os.access(path + "/" + lib, os.F_OK):
> +            return path + "/" + lib
> 
>      return ""
> 
> @@ -447,8 +450,6 @@ for obj in objects.values():
>          else:
>              print "warning: " + obj + " may need rpath, but --root not specified"
> 
> -lib_path.extend(lib_rpath)
> -
>  passnr = 1
>  available_libs = []
>  previous_pass_unresolved = set()

Perhaps I've missed something... There are other uses of lib_path in mklibs not
adjusted by this patch. Those will no longer see any rpaths, so you've
changed the set of paths handled at various points, is that intentional?

Here's my cut at the same patch:

Joe

	* src/mklibs: Don't include lib_rpath in lib_path. Update use
	sites of lib_path to handle lib_rpath separately.
        (find_lib, find_pic, find_pic_map): Add handling of lib_rpath.

Index: src/mklibs
===================================================================
--- src/mklibs	(revision 399065)
+++ src/mklibs	(working copy)
@@ -233,6 +233,9 @@ def find_lib(lib):
     for path in lib_path:
         if os.access(sysroot + path + "/" + lib, os.F_OK):
             return sysroot + path + "/" + lib
+    for path in lib_rpath:
+        if os.access(path + "/" + lib, os.F_OK):
+            return path + "/" + lib
 
     return ""
 
@@ -243,6 +246,10 @@ def find_pic(lib):
         for file in glob.glob(sysroot + path + "/" + base_name + "_pic.a"):
             if os.access(file, os.F_OK):
                 return resolve_link(file)
+    for path in lib_rpath:
+        for file in glob.glob(path + "/" + base_name + "_pic.a"):
+            if os.access(file, os.F_OK):
+                return resolve_link(file)
     return ""
 
 # Find a PIC .map file for the library
@@ -252,6 +259,10 @@ def find_pic_map(lib):
         for file in glob.glob(sysroot + path + "/" + base_name + "_pic.map"):
             if os.access(file, os.F_OK):
                 return resolve_link(file)
+    for path in lib_rpath:
+        for file in glob.glob(path + "/" + base_name + "_pic.map"):
+            if os.access(file, os.F_OK):
+                return resolve_link(file)
     return ""
 
 soname_cache = {}
@@ -464,8 +475,6 @@ for obj in objects.values():
         else:
             print "warning: " + obj + " may need rpath, but --root not specified"
 
-lib_path.extend(lib_rpath)
-
 passnr = 1
 available_libs = []
 previous_pass_unresolved = set()
@@ -559,7 +568,7 @@ while 1:
         path = find_lib(library)
         if not path:
             sys.exit("Library not found: " + library + " in path: "
-                    + ':'.join(lib_path))
+                    + ':'.join(lib_path) + ':'.join(lib_rpath))
         symbols = provided_symbols(path)
         library_symbols[library] = {}
         library_symbols_used[library] = set()
@@ -640,6 +656,7 @@ while 1:
             cmd.extend(extra_flags)
             cmd.append("-lgcc")
             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 + "/")]])
+            cmd.extend(["-L%s" % a for a in lib_rpath])
             cmd.append(library_depends_gcc_libnames(so_file))
             command(target + "gcc", *cmd)
 




Reply to: