Skip to content

Commit

Permalink
Ensure command line linkopts are added to cgo link flags (bazel-contr…
Browse files Browse the repository at this point in the history
…ib#2926)

rules_go seems to be ignoring --linkopt (and --copt/--cxxopt) when
resolving command line flags.

These flags are accessible through the "cpp" fragment and are not
expanded by get_memory_inefficient_command_line as they are not part
of the toolchain.
  • Loading branch information
chancila authored Aug 21, 2021
1 parent 3d45a1f commit 1f156d8
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions go/private/context.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -647,7 +647,7 @@ def _cgo_context_data_impl(ctx):
feature_configuration = feature_configuration,
action_name = CPP_LINK_EXECUTABLE_ACTION_NAME,
variables = ld_executable_variables,
),
) + ctx.fragments.cpp.linkopts,
_LINKER_OPTIONS_BLACKLIST,
)
env.update(cc_common.get_environment_variables(
Expand Down Expand Up @@ -688,9 +688,10 @@ def _cgo_context_data_impl(ctx):
feature_configuration = feature_configuration,
action_name = CPP_LINK_DYNAMIC_LIBRARY_ACTION_NAME,
variables = ld_dynamic_lib_variables,
),
) + ctx.fragments.cpp.linkopts,
_LINKER_OPTIONS_BLACKLIST,
)

env.update(cc_common.get_environment_variables(
feature_configuration = feature_configuration,
action_name = CPP_LINK_DYNAMIC_LIBRARY_ACTION_NAME,
Expand Down

0 comments on commit 1f156d8

Please sign in to comment.