Skip to content

Commit

Permalink
Revert "Fixes incorrect install names on darwin platforms"
Browse files Browse the repository at this point in the history
This reverts commit b06f495.
  • Loading branch information
det committed Apr 14, 2022
1 parent 76fac81 commit 6f7b174
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -820,7 +820,8 @@ public CppLinkAction build() throws InterruptedException, RuleErrorException {
getLinkType().linkerOrArchiver().equals(LinkerOrArchiver.LINKER),
configuration.getBinDirectory(repositoryName).getExecPath(),
output.getExecPathString(),
output.getRootRelativePath().getBaseName(),
SolibSymlinkAction.getDynamicLibrarySoname(
output.getRootRelativePath(), /* preserveName= */ false),
linkType.equals(LinkTargetType.DYNAMIC_LIBRARY),
paramFile != null ? paramFile.getExecPathString() : null,
thinltoParamFile != null ? thinltoParamFile.getExecPathString() : null,
Expand Down
50 changes: 16 additions & 34 deletions src/test/shell/bazel/cpp_darwin_integration_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -124,59 +124,41 @@ EOF
}

function test_cc_test_with_explicit_install_name() {
mkdir -p cpp/install_name
cat > cpp/install_name/BUILD <<EOF
mkdir -p cpp
cat > cpp/BUILD <<EOF
cc_library(
name = "foo",
srcs = ["foo.cc"],
)
cc_binary(
name = "libbar.so",
srcs = ["bar.cc"],
linkshared = 1,
)
cc_binary(
name = "libbaz.dylib",
srcs = ["baz.cc"],
linkshared = 1,
hdrs = ["foo.h"],
)
cc_test(
name = "test",
srcs = ["test.cc", ":libbar.so", ":libbaz.dylib"],
srcs = ["test.cc"],
deps = [":foo"],
)
EOF
cat > cpp/install_name/foo.cc <<EOF
int foo() { return 2; }
cat > cpp/foo.h <<EOF
int foo();
EOF
cat > cpp/install_name/bar.cc <<EOF
int bar() { return 12; }
cat > cpp/foo.cc <<EOF
int foo() { return 0; }
EOF
cat > cpp/install_name/baz.cc <<EOF
int baz() { return 42; }
EOF
cat > cpp/install_name/test.cc <<EOF
int foo();
int bar();
int baz();
cat > cpp/test.cc <<EOF
#include "cpp/foo.h"
int main() {
int result = foo() + bar() + baz();
if (result == 56) {
return 0;
} else {
return result;
}
return foo();
}
EOF

bazel test --incompatible_macos_set_install_name //cpp/install_name:test || \
fail "bazel test //cpp/install_name:test failed"
bazel test --incompatible_macos_set_install_name //cpp:test || \
fail "bazel test //cpp:test failed"
# Ensure @rpath is correctly set in the binary.
./bazel-bin/cpp/install_name/test || \
./bazel-bin/cpp/test || \
fail "//cpp:test workspace execution failed, expected return 0, got $?"
cd bazel-bin
./cpp/install_name/test || \
./cpp/test || \
fail "//cpp:test execution failed, expected 0, but $?"
}

run_suite "Tests for Bazel's C++ rules on Darwin"

0 comments on commit 6f7b174

Please sign in to comment.