aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZach Yu <zachyu@google.com>2023-06-28 16:08:19 -0700
committerZach Yu <zachyu@google.com>2023-06-28 16:08:19 -0700
commit7a994feaaa48414a7b0f7f17e0bd01448facd388 (patch)
treed881b68d8d376d5de8b6e9efe3678e667c952ef7
parent00435af7efc989eea0153ca9dd1846462465ab53 (diff)
downloadbazel-7a994feaaa48414a7b0f7f17e0bd01448facd388.tar.gz
Set "install name" when linking macOS dylibs.
This would allow tests to run. However, the "install names" would be mangled by Bazel, and may require unmangling if releasing such a dylib. Bug: 274512969 Change-Id: Ib0e97e30b385a7945e049c87c1a81431bf527143
-rw-r--r--toolchains/cc/mac_clang/features.bzl24
1 files changed, 24 insertions, 0 deletions
diff --git a/toolchains/cc/mac_clang/features.bzl b/toolchains/cc/mac_clang/features.bzl
index d8c2bb05..934bd074 100644
--- a/toolchains/cc/mac_clang/features.bzl
+++ b/toolchains/cc/mac_clang/features.bzl
@@ -86,6 +86,29 @@ rpath_feature = feature(
],
)
+# https://github.com/bazelbuild/bazel/issues/7415
+set_install_name_feature = feature(
+ name = "set_install_name",
+ enabled = True,
+ flag_sets = [
+ flag_set(
+ actions = [
+ ACTION_NAMES.cpp_link_dynamic_library,
+ ACTION_NAMES.cpp_link_nodeps_dynamic_library,
+ ],
+ flag_groups = [
+ flag_group(
+ flags = [
+ "-install_name",
+ "@rpath/%{runtime_solib_name}",
+ ],
+ expand_if_available = "runtime_solib_name",
+ ),
+ ],
+ ),
+ ],
+)
+
# https://cs.opensource.google/bazel/bazel/+/master:src/main/java/com/google/devtools/build/lib/rules/cpp/CppActionConfigs.java;l=653;drc=6d03a2ecf25ad596446c296ef1e881b60c379812
libraries_to_link_feature = feature(
name = "libraries_to_link",
@@ -249,6 +272,7 @@ def _cc_features_impl(ctx):
shared_flag_feature,
linkstamps_feature,
output_execpath_feature,
+ set_install_name_feature,
rpath_feature,
lib_search_paths_feature,
get_toolchain_lib_search_paths_feature(import_config),