cc_test on OS X fails due to dynamic linker issues
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/).
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.
don't we have a e2e that exercises cc_test on darwin?
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.
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.