Skip to content

Commit 6b21b77

Browse files
detcopybara-github
authored andcommitted
Revert "Fixes incorrect install names on darwin platforms"
This reverts commit b06f495. Also had to add a missing mnemonic function call parameter to `getDynamicLibrarySoname`. Copy-pasted the parameter from the other use of that function in the codebase. Tested manually with a custom toolchain and there is also a test from the reverted code. Fixes bazelbuild#15214 Closes bazelbuild#15261. PiperOrigin-RevId: 446662219
1 parent 1727361 commit 6b21b77

File tree

2 files changed

+20
-35
lines changed

2 files changed

+20
-35
lines changed

src/main/java/com/google/devtools/build/lib/rules/cpp/CppLinkActionBuilder.java

+4-1
Original file line numberDiff line numberDiff line change
@@ -820,7 +820,10 @@ public CppLinkAction build() throws InterruptedException, RuleErrorException {
820820
getLinkType().linkerOrArchiver().equals(LinkerOrArchiver.LINKER),
821821
configuration.getBinDirectory(repositoryName).getExecPath(),
822822
output.getExecPathString(),
823-
output.getRootRelativePath().getBaseName(),
823+
SolibSymlinkAction.getDynamicLibrarySoname(
824+
output.getRootRelativePath(),
825+
/* preserveName= */ false,
826+
actionConstructionContext.getConfiguration().getMnemonic()),
824827
linkType.equals(LinkTargetType.DYNAMIC_LIBRARY),
825828
paramFile != null ? paramFile.getExecPathString() : null,
826829
thinltoParamFile != null ? thinltoParamFile.getExecPathString() : null,

src/test/shell/bazel/cpp_darwin_integration_test.sh

+16-34
Original file line numberDiff line numberDiff line change
@@ -124,59 +124,41 @@ EOF
124124
}
125125

126126
function test_cc_test_with_explicit_install_name() {
127-
mkdir -p cpp/install_name
128-
cat > cpp/install_name/BUILD <<EOF
127+
mkdir -p cpp
128+
cat > cpp/BUILD <<EOF
129129
cc_library(
130130
name = "foo",
131131
srcs = ["foo.cc"],
132-
)
133-
cc_binary(
134-
name = "libbar.so",
135-
srcs = ["bar.cc"],
136-
linkshared = 1,
137-
)
138-
cc_binary(
139-
name = "libbaz.dylib",
140-
srcs = ["baz.cc"],
141-
linkshared = 1,
132+
hdrs = ["foo.h"],
142133
)
143134
cc_test(
144135
name = "test",
145-
srcs = ["test.cc", ":libbar.so", ":libbaz.dylib"],
136+
srcs = ["test.cc"],
146137
deps = [":foo"],
147138
)
148139
EOF
149-
cat > cpp/install_name/foo.cc <<EOF
150-
int foo() { return 2; }
140+
cat > cpp/foo.h <<EOF
141+
int foo();
151142
EOF
152-
cat > cpp/install_name/bar.cc <<EOF
153-
int bar() { return 12; }
143+
cat > cpp/foo.cc <<EOF
144+
int foo() { return 0; }
154145
EOF
155-
cat > cpp/install_name/baz.cc <<EOF
156-
int baz() { return 42; }
157-
EOF
158-
cat > cpp/install_name/test.cc <<EOF
159-
int foo();
160-
int bar();
161-
int baz();
146+
cat > cpp/test.cc <<EOF
147+
#include "cpp/foo.h"
162148
int main() {
163-
int result = foo() + bar() + baz();
164-
if (result == 56) {
165-
return 0;
166-
} else {
167-
return result;
168-
}
149+
return foo();
169150
}
170151
EOF
171152

172-
bazel test --incompatible_macos_set_install_name //cpp/install_name:test || \
173-
fail "bazel test //cpp/install_name:test failed"
153+
bazel test --incompatible_macos_set_install_name //cpp:test || \
154+
fail "bazel test //cpp:test failed"
174155
# Ensure @rpath is correctly set in the binary.
175-
./bazel-bin/cpp/install_name/test || \
156+
./bazel-bin/cpp/test || \
176157
fail "//cpp:test workspace execution failed, expected return 0, got $?"
177158
cd bazel-bin
178-
./cpp/install_name/test || \
159+
./cpp/test || \
179160
fail "//cpp:test execution failed, expected 0, but $?"
180161
}
181162

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

0 commit comments

Comments
 (0)