When deduplicating linkopts, visit them in order consistent with commandline
Otherwise we get incorrect linkopts ordering.
PiperOrigin-RevId: 689966300
Change-Id: I156fd7f6389b0928df7d051ce8eda973c6d2fc68
diff --git a/src/main/starlark/builtins_bzl/common/objc/compilation_support.bzl b/src/main/starlark/builtins_bzl/common/objc/compilation_support.bzl
index c6e5497..b6802f1 100644
--- a/src/main/starlark/builtins_bzl/common/objc/compilation_support.bzl
+++ b/src/main/starlark/builtins_bzl/common/objc/compilation_support.bzl
@@ -887,14 +887,21 @@
replace_libs,
)
- (cc_linking_context, seen_flags) = _create_deduped_linkopts_linking_context(ctx.label, cc_linking_context)
-
prefixed_attr_linkopts = [
"-Wl,%s" % linkopt
for linkopt in attr_linkopts
]
- (_, user_link_flags, _) = _dedup_link_flags(extra_link_args + prefixed_attr_linkopts, seen_flags)
+ seen_flags = {}
+ (_, user_link_flags, seen_flags) = _dedup_link_flags(
+ extra_link_args + prefixed_attr_linkopts,
+ seen_flags,
+ )
+ (cc_linking_context, _) = _create_deduped_linkopts_linking_context(
+ ctx.label,
+ cc_linking_context,
+ seen_flags,
+ )
cc_common.link(
name = name,
@@ -968,8 +975,7 @@
return (same, new_flags, seen_flags)
-def _create_deduped_linkopts_linking_context(owner, cc_linking_context):
- seen_flags = {}
+def _create_deduped_linkopts_linking_context(owner, cc_linking_context, seen_flags):
linker_inputs = []
for linker_input in cc_linking_context.linker_inputs.to_list():
(same, new_flags, seen_flags) = _dedup_link_flags(