bazel icon indicating copy to clipboard operation
bazel copied to clipboard

cc_test on OS X fails due to dynamic linker issues

Open zrlk opened this issue 11 years ago • 4 comments

It appears that the cc_test rule on OS X isn't working. cc_test compiles test executables that link dynamically to .so libraries that live underneath bazel_out, e.g.:

dyld: Library not loaded: bazel-out/local_darwin-fastbuild/bin/kythe/cxx/common/libkythe_uri_testlib.so
  Referenced from: /private/var/tmp/_bazel_user/4047a92cde5c126a2747538e6c63dc38/kythe/bazel-out/local_darwin-fastbuild/bin/kythe/cxx/common/kythe_uri_test.runfiles/kythe/cxx/common/kythe_uri_test
  Reason: image not found

Since the test environment does not run in an environment where bazel-out exists, dyld fails. (There is a libkythe_uri_testlib.so in /private/var/tmp/_bazel_user/4047a92cde5c126a2747538e6c63dc38/kythe/bazel-out/local_darwin-fastbuild/bin/kythe/cxx/common).

Either these tests should be linked statically, or the paths to the dynamic libraries should use the special dyld @xxx/ prefixes (like @executable_path/).

zrlk avatar May 22 '15 00:05 zrlk

We are using @looader_path in https://github.com/google/bazel/blob/master/tools/cpp/osx_gcc_wrapper.sh but apparently we did something wrong because bazel-out path should be replaced.

damienmg avatar May 22 '15 09:05 damienmg

don't we have a e2e that exercises cc_test on darwin?

hanwen avatar May 22 '15 14:05 hanwen

We have https://github.com/google/bazel/blob/master/src/test/shell/bazel/bazel_example_test.sh#L31 but it is a simple case.

We have https://github.com/google/bazel/blob/master/src/test/shell/bazel/bazel_rules_test.sh#L154 that I created for loader path of OSX but it just exercise sh_binary run. Extends the test for cc_test would be a good idea though.

damienmg avatar May 22 '15 14:05 damienmg

Since you mentioned the wrapper script, I think this is a problem with our configuration; we're building with clang, not gcc, and weren't calling it through the wrapper. I'll re-open this issue if it turns out to be more than this. Sorry for the confusion.

zrlk avatar May 22 '15 17:05 zrlk