[LLVMbugs] [Bug 14905] New: cmake+shared installation on Darwin needs install_name_tool pass

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Thu Jan 10 13:15:47 PST 2013


http://llvm.org/bugs/show_bug.cgi?id=14905

             Bug #: 14905
           Summary: cmake+shared installation on Darwin needs
                    install_name_tool pass
           Product: Build scripts
           Version: trunk
          Platform: Macintosh
        OS/Version: MacOS X
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: cmake
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: fang at csl.cornell.edu
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified


The cmake+shared built shared libraries and executables have been incorrectly
installed since cmake was born.  Simply copying the built binaries to the
install location does not work without having to set other ld/dyld related
environment variables.  The following post-install script is necessary to fix
up dependent shared library paths in binaries (fairly standard recipe for
cmake-built packages).  
(libtool does this correctly at install-time)

I've been using this for a few years, but never bothered to report it before,
as it is more of a deficiency in cmake.
The script can also be trivially modified to work on DESTDIR-staged builds.

========== install-shared.sh ==========
#!/bin/sh -ev
prefix=/usr/local/wherever
make -j1 install/fast

pushd $prefix/lib
for f in *.dylib *.so
do
        if test ! -L $f
        then
        install_name_tool -id "$prefix/lib/$f" "$f"
        case $f in
        *.dylib) filt="sed 1,2d" ;;
        *.so) filt="sed 1d" ;;
        esac
        deplibs=`otool -L $f | $filt | awk '{print $1;}' | tr '\n' ' '`
        for d in $deplibs
        do
        # prefix absolute paths to llvm/clang's lib installation
        case $d in
        /*) ;;
        *) install_name_tool -change "$d" "$prefix/lib/$d" $f ;;
        esac
        done
        fi
done
popd
pushd $prefix/bin
for f in *
do
        if test ! -L $f
        then
        deplibs=`otool -L $f | sed 1d | awk '{print $1;}' | tr '\n' ' '`
        for d in $deplibs
        do
        # consider substituting with relative @executable_path/../lib ?
        case $d in
        /*) ;;
        @*) ;;
        *) install_name_tool -change "$d" "$prefix/lib/$d" $f ;;
        esac
        done
        fi
done
popd

-- 
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