diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppLinkActionBuilder.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppLinkActionBuilder.java index 081f7de0e28eec..589ac39781ac83 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppLinkActionBuilder.java +++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppLinkActionBuilder.java @@ -852,7 +852,7 @@ public CppLinkAction build() throws EvalException, InterruptedException { output.getExecPathString(), SolibSymlinkAction.getDynamicLibrarySoname( output.getRootRelativePath(), - /* preserveName= */ false, + /* preserveName= */ linkType != LinkTargetType.NODEPS_DYNAMIC_LIBRARY, linkActionConstruction.getContext().getConfiguration().getMnemonic()), thinltoParamFile != null ? thinltoParamFile.getExecPathString() : null, toolchain, diff --git a/src/main/starlark/builtins_bzl/common/cc/link/cpp_link_action.bzl b/src/main/starlark/builtins_bzl/common/cc/link/cpp_link_action.bzl index 21401ccfbaae25..97be0fadcd5158 100644 --- a/src/main/starlark/builtins_bzl/common/cc/link/cpp_link_action.bzl +++ b/src/main/starlark/builtins_bzl/common/cc/link/cpp_link_action.bzl @@ -200,7 +200,7 @@ def link_action( cc_internal.dynamic_library_soname( actions, output.short_path, - False, + link_type != NODEPS_DYNAMIC_LIBRARY, ), interface_output.path if interface_output else None, thinlto_param_file.path if thinlto_param_file else None, diff --git a/src/test/shell/bazel/BUILD b/src/test/shell/bazel/BUILD index 55e583af7ceb42..ba52de66012b46 100644 --- a/src/test/shell/bazel/BUILD +++ b/src/test/shell/bazel/BUILD @@ -128,6 +128,7 @@ sh_test( ], tags = [ "no_windows", # darwin-specific test + "requires-network", # For Bzlmod ], ) diff --git a/src/test/shell/bazel/cpp_darwin_integration_test.sh b/src/test/shell/bazel/cpp_darwin_integration_test.sh index b1155e3778e1e3..9f648b24039ab6 100755 --- a/src/test/shell/bazel/cpp_darwin_integration_test.sh +++ b/src/test/shell/bazel/cpp_darwin_integration_test.sh @@ -139,6 +139,8 @@ EOF return 0 } +# TODO: This test passes vacuously as the default Unix toolchain doesn't use +# the set_install_name feature yet. function test_cc_test_with_explicit_install_name() { mkdir -p cpp cat > cpp/BUILD < cpp/foo.h < cpp/foo.cc < cpp/test.cc < MODULE.bazel < cpp/BUILD < cpp/foo.h <