[LLVMbugs] [Bug 10241] New: Shell scripts generated by llvm-ld attempt to dynamically load archives

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Fri Jul 1 06:48:46 PDT 2011


           Summary: Shell scripts generated by llvm-ld attempt to
                    dynamically load archives
           Product: new-bugs
           Version: 2.9
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: new bugs
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: srk31 at srcf.ucam.org
                CC: llvmbugs at cs.uiuc.edu

When looking up a library name in sys::Path returns an archive, llvm-ld will
happily generate a shell script containing a -load= argument to lli for that
archive. This fails at run-time, because archives cannot be dynamically loaded.

To reproduce: same as bug 10240 <http://llvm.org/bugs/show_bug.cgi?id=10240>.
In general, passing using -l to link any library will trigger the bug if that
library's only appearance in the library search path is as an archive. I'm
seeing this on an x86-64 FC13 machine, but guess it's an issue for any system
that uses archives.

The following quick fix seems to sort it out. The problem is that the
FindLibrary call can return an archive, but this code only wants shared

--- tools/llvm-ld/llvm-ld.cpp
+++ tools/llvm-ld/llvm-ld.cpp.patched-3 2011-07-01 14:35:47.000000000 +0100
@@ -465,7 +465,7 @@
     if (FullLibraryPath.isEmpty())
       FullLibraryPath = sys::Path::FindLibrary(*i);
-    if (!FullLibraryPath.isEmpty())
+    if (!FullLibraryPath.isEmpty() && FullLibraryPath.isDynamicLibrary())
       Out2.os() << "    -load=" << FullLibraryPath.str() << " \\\n";
   Out2.os() << "    "  << BitcodeOutputFilename << " ${1+\"$@\"}\n";

I'm not actually sure why the FindLibrary call is there, since the preceding
chunk of code is all about locating the input libraries (and is careful to
exclude non-shared-objects). But it might make sense if sys::Path includes some
directories that aren't in LibPaths.

Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.

More information about the llvm-bugs mailing list