summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKrishna Ersson <2743723+kersson@users.noreply.github.com>2023-09-19 09:05:41 -0700
committerGitHub <noreply@github.com>2023-09-19 09:05:41 -0700
commit9dada04856947bea40fc2620d1732f142ba91d41 (patch)
treef69773babeba953c695f7945dc0cc3f6e26b8371
parent3303a5b7f62af362a743f0ad7786dc4c82e012f7 (diff)
downloadbazelbuild-apple_support-9dada04856947bea40fc2620d1732f142ba91d41.tar.gz
Use `no_warn_duplicate_libraries` by default (#259)
Suppresses linker warnings like these, which are new with Xcode 15: ``` ld: warning: ignoring duplicate libraries: '-lm', '-lpthread', '-lz' ``` Relevant Slack conversations: - https://bazelbuild.slack.com/archives/C04DFUBQGSU/p1695063579429469 - https://bazelbuild.slack.com/archives/CD3QY5C2X/p1695063506152109 - https://bazelbuild.slack.com/archives/C04DFUBQGSU/p1689257981712829
-rw-r--r--crosstool/cc_toolchain_config.bzl22
1 files changed, 22 insertions, 0 deletions
diff --git a/crosstool/cc_toolchain_config.bzl b/crosstool/cc_toolchain_config.bzl
index 45efc72..040445c 100644
--- a/crosstool/cc_toolchain_config.bzl
+++ b/crosstool/cc_toolchain_config.bzl
@@ -30,6 +30,7 @@ load(
"variable_with_value",
"with_feature_set",
)
+load("@build_bazel_apple_support//lib:xcode_support.bzl", "xcode_support")
# TODO: Remove when we drop bazel 6.x support
_OBJC_ARCHIVE_ACTION_NAME = "objc-archive"
@@ -2456,6 +2457,26 @@ please file an issue at https://github.com/bazelbuild/apple_support/issues/new
],
)
+ # As of Xcode 15, linker warnings are emitted if duplicate `-l` options are
+ # present. Until such linkopts can be deduped by bazel itself, we disable
+ # these warnings.
+ no_warn_duplicate_libraries_feature = feature(
+ name = "no_warn_duplicate_libraries",
+ enabled = xcode_support.is_xcode_at_least_version(xcode_config, "15.0.0"),
+ flag_sets = [
+ flag_set(
+ actions = _DYNAMIC_LINK_ACTIONS,
+ flag_groups = [
+ flag_group(
+ flags = [
+ "-Wl,-no_warn_duplicate_libraries",
+ ],
+ ),
+ ],
+ ),
+ ],
+ )
+
features = [
# Marker features
feature(name = "archive_param_file"),
@@ -2535,6 +2556,7 @@ please file an issue at https://github.com/bazelbuild/apple_support/issues/new
ubsan_feature,
default_sanitizer_flags_feature,
treat_warnings_as_errors_feature,
+ no_warn_duplicate_libraries_feature,
]
if (ctx.attr.cpu == "darwin_x86_64" or