DynamoRIO / DynamoRIO/drmemory
mac: link problems with libstrace_test.client.dylib finding drsyscall due to relative load path from cmake
- Dominant language
- C
- Stars
- 2.7k
- Forks
- 290
- PR merge metrics
- No merged PRs in 30d
Description
_From [bruen...@google.com](https://code.google.com/u/109494838902877177630/) on March 17, 2014 15:41:40_
xref issue #1375 -- but the INSTALL_NAME_DIR only applies on the exports and the test client links w/ the build-dir lib
I tried this:
LINK_FLAGS "-install_name @rpath/libdrsyscall.dylib")
but still no "@rpath/":
# otool -l tests/libstrace_test.client.dylib
cmd LC_LOAD_DYLIB
cmdsize 44
name libdrsyscall.dylib (offset 24)
I think it's b/c cmake's own -install_name goes _after_ LINK_FLAGS.
# otool -l ./drmf/lib32/debug/libdrsyscall.dylib | grep -A 2 ID_DY
cmd LC_ID_DYLIB
cmdsize 44
name libdrsyscall.dylib (offset 24)
(I later discovered that "otool -D" prints just the ID_DYLIB name for us)
this is INSTALL_NAME_DIR at work:
# otool -D ~/dr/git/exports/lib32/libdrinjectlib.dylib
name @rpath/libdrinjectlib.dylib (offset 24)
so why does this have an absolute path?
# otool -D dynamorio/lib32/libdrinjectlib.dylib
/.../drmemory/git/build_x86_dbg/dynamorio/lib32/libdrinjectlib.dylib
# otool -l dynamorio/bin32/drrun
cmd LC_LOAD_DYLIB
cmdsize 108
name /.../drmemory/git/build_x86_dbg/dynamorio/lib32/libdrinjectlib.dylib
A lot of people complain about relative paths on install: http://answers.opencv.org/question/4134/cmake-install_name_tool-absolute-path-for-library/ But here I didn't install libdrsyscall.
Analyzing my built libs -- it looks like all DR clients have relative.
So what are we doing to make cmake use relative? Looking cmake sources I
didn't find the code that does it.
Compare non-client:
/usr/bin/cc -m32 -g -Wall -Werror -Wno-strict-aliasing -mmacosx-version-min=10.7 -fvisibility=hidden -dynamiclib -Wl,-headerpad_max_install_names -o libsuppress-mod-bar.dylib -install_name /.../drmemory/git/build_x86_dbg/tests/libsuppress-mod-bar.dylib CMakeFiles/suppress-mod-bar.dir/suppress-mod-bar.c.o
To client:
/usr/bin/cc -m32 -dynamiclib -Wl,-headerpad_max_install_names -Wl,-rpath,'@loader_path/../dynamorio/lib32/debug' -m32 -m32 -g -Wall -Werror -Wno-strict-aliasing -mmacosx-version-min=10.7 -fvisibility=hidden -DX86_32 -DMACOS -DDR_REG_ENUM_COMPATIBILITY -DDR_FAST_IR -std=gnu99 -DUSE_VISIBILITY_ATTRIBUTES -fPIC -shared -Wl,-rpath,'@loader_path/../drmf/lib32/debug' -Wl,-rpath,'@loader_path/../dynamorio/ext/lib32/debug' -o ../libstrace_test.client.dylib -install_name libstrace_test.client.dylib CMakeFiles/strace_test.client.dir/strace_client.c.o ../../dynamorio/lib32/debug/libdynamorio.dylib ../../drmf/lib32/debug/libdrsyscall.dylib ../../dynamorio/ext/lib32/debug/libdrmgr.dylib ../../dynamorio/lib32/debug/libdynamorio.dylib
Workaround for now:
# cp drmf/lib32/debug/libdrsyscall.0.9.239.dylib dynamorio/ext/lib32/debug/
_Original issue: http://code.google.com/p/drmemory/issues/detail?id=1478_
Contributor guide
Assessment
This issue has not been assessed yet.