Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding gc_linopts to command line flag #3342

Merged
merged 4 commits into from
Nov 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ go_config(
"//go/private:is_compilation_mode_dbg": "//go/private:always_true",
"//conditions:default": "//go/config:debug",
}),
gc_linkopts = "//go/config:gc_linkopts",
gotags = "//go/config:tags",
linkmode = "//go/config:linkmode",
msan = "//go/config:msan",
Expand Down
6 changes: 6 additions & 0 deletions go/config/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@ string_flag(
visibility = ["//visibility:public"],
)

string_list_flag(
name = "gc_linkopts",
build_setting_default = [],
visibility = ["//visibility:public"],
)

string_list_flag(
name = "tags",
build_setting_default = [],
Expand Down
2 changes: 2 additions & 0 deletions go/private/actions/link.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ def emit_link(

if go.coverage_enabled:
extldflags.append("--coverage")
gc_linkopts = list(gc_linkopts)
gc_linkopts.extend(go.mode.gc_linkopts)
gc_linkopts, extldflags = _extract_extldflags(gc_linkopts, extldflags)
builder_args = go.builder_args(go, "link")
tool_args = go.tool_args(go)
Expand Down
5 changes: 5 additions & 0 deletions go/private/context.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -817,6 +817,7 @@ def _go_config_impl(ctx):
strip = ctx.attr.strip[BuildSettingInfo].value,
debug = ctx.attr.debug[BuildSettingInfo].value,
linkmode = ctx.attr.linkmode[BuildSettingInfo].value,
gc_linkopts = ctx.attr.gc_linkopts[BuildSettingInfo].value,
tags = ctx.attr.gotags[BuildSettingInfo].value,
stamp = ctx.attr.stamp,
cover_format = ctx.attr.cover_format[BuildSettingInfo].value,
Expand Down Expand Up @@ -854,6 +855,10 @@ go_config = rule(
mandatory = True,
providers = [BuildSettingInfo],
),
"gc_linkopts": attr.label(
mandatory = True,
providers = [BuildSettingInfo],
),
"gotags": attr.label(
mandatory = True,
providers = [BuildSettingInfo],
Expand Down
2 changes: 2 additions & 0 deletions go/private/mode.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ def get_mode(ctx, go_toolchain, cgo_context_info, go_config_info):
if pure and msan:
fail("msan instrumentation can't be enabled when cgo is disabled. Check that pure is not set to \"off\" and a C/C++ toolchain is configured.")

gc_linkopts = list(go_config_info.gc_linkopts) if go_config_info else []
tags = list(go_config_info.tags) if go_config_info else []
if "gotags" in ctx.var:
tags.extend(ctx.var["gotags"].split(","))
Expand All @@ -106,6 +107,7 @@ def get_mode(ctx, go_toolchain, cgo_context_info, go_config_info):
msan = msan,
pure = pure,
link = linkmode,
gc_linkopts = gc_linkopts,
strip = strip,
stamp = stamp,
debug = debug,
Expand Down