Skip to content

Commit

Permalink
When deduplicating linkopts, visit them in order consistent with comm…
Browse files Browse the repository at this point in the history
…andline

Otherwise we get incorrect linkopts ordering.

PiperOrigin-RevId: 689966300
Change-Id: I156fd7f6389b0928df7d051ce8eda973c6d2fc68
  • Loading branch information
googlewalt authored and copybara-github committed Oct 26, 2024
1 parent ea477ac commit 492d158
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/main/starlark/builtins_bzl/common/objc/compilation_support.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -887,14 +887,21 @@ def _register_configuration_specific_link_actions_with_cpp_variables(
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,
Expand Down Expand Up @@ -968,8 +975,7 @@ def _dedup_link_flags(flags, seen_flags = {}):

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(
Expand Down

0 comments on commit 492d158

Please sign in to comment.