[CMake] Installation corrupts library on OS X

Clinton Stimpson clinton at elemtech.com
Tue Oct 14 14:06:27 EDT 2014


On Tuesday, October 14, 2014 10:19:41 AM Peter Eastman wrote:
> Hi Clint,
> 
> You're absolutely right:
> 
> $ otool -l libOpenMMAmoebaCUDA.dylib | grep -A2 LC_RPATH
>           cmd LC_RPATH
>       cmdsize 32
>          path /usr/local/cuda/lib (offset 12)
> --
>           cmd LC_RPATH
>       cmdsize 32
>          path /usr/local/cuda/lib (offset 12)
> 
> I'll try to figure out where the duplicate is coming from and see if that
> fixes it.
> 
> I'd be glad to report this to Apple, but I can't figure out how to reproduce
> the problem without using CMake.  I tried using install_name_tool to
> directly change all the paths myself, and that worked fine.  It didn't
> produce the problem.  Is CMake doing something different from just a series
> of calls to "install_name_tool -change" and "install_name_tool -id"?
> 
> Peter

Here's a simple way to reproduce from the command line:

echo "void foo() {}" > lib.c
gcc -dynamiclib -o libtest.dylib -Wl,-rpath,/usr/lib -Wl,-rpath,/usr/lib lib.c
install_name_tool -delete_rpath /usr/lib libtest.dylib
otool -L libtest.dylib
  # gives me the error: "load command 13 size zero (can't advance to other 
load commands)"

At install time, CMake will call "install_name_tool -delete_rpath ... " as 
needed.

I can't get into Apple's bug tracker.  I don't know why.  When I try to log 
in, it comes back with a generic error and it asks me to email them with 
details about the error.

When I do the same on Linux, the GNU linker will consolidate the duplicate 
paths.

Thanks!

Clint


> 
> On Oct 13, 2014, at 7:33 PM, clinton at elemtech.com wrote:
> > Yeah, I think you have duplicate LC_RPATH load commands.  In that case,
> > your binaries can be corrupted by install_name_tool during "make
> > install." To check if that is your case, you can run this on the binary
> > before installation to see if you have duplicates. otool -l app | grep
> > -A2 LC_RPATH
> > 
> > If the duplicates come from your own linker flags such as,
> > -Wl,-rpath,/some/path, you may need to remove those. Otherwise, it would
> > help if you can provide a minimal test case to reproduce the problem.
> > 
> > It would also help if someone could report this corruption by
> > install_name_tool bug to Apple.  You are the second to come to this
> > mailing list about this bug.
> > 
> > Clint

-- 
Clinton Stimpson
Elemental Technologies, Inc
Computational Simulation Software, LLC
www.csimsoft.com


More information about the CMake mailing list