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

Add 'gc_goopts' flag to command line to allow gc_goopts to propagate #3340

Merged
merged 29 commits into from
Nov 18, 2022
Merged
Show file tree
Hide file tree
Changes from 27 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
6d2095c
Added 'defines' command line flag to allow options to propagate to a …
LWarrens Nov 2, 2022
d6e5f83
go/config: Added 'defines' command line flag to allow options to prop…
LWarrens Nov 2, 2022
7d1b36d
go/config: added defines references and fixed docs
LWarrens Nov 3, 2022
ca9e113
update comment
LWarrens Nov 3, 2022
e9efba9
fix error in go source definition
LWarrens Nov 3, 2022
16e1e47
call defines from input parameter
LWarrens Nov 4, 2022
943b2af
update defines definitions
LWarrens Nov 7, 2022
04535da
changed definitions in context.bzl
LWarrens Nov 7, 2022
a021cd7
make defines field for gosource in archive into a tuple; depset requi…
LWarrens Nov 7, 2022
e9e38d9
use extend semantics for gc_goopts list in compilepkg
LWarrens Nov 7, 2022
d93bd9d
go/config: cmd line propagating goopts added
LWarrens Nov 11, 2022
d82d461
remove debug statements
LWarrens Nov 15, 2022
4ba8d5a
reverted deleted proto attribute
LWarrens Nov 15, 2022
b078f8f
ref tool_args directly
LWarrens Nov 15, 2022
6bdd059
remove compile comment; still doesn't appear to process gcflags
LWarrens Nov 15, 2022
074602f
changed cmd line references to 'gc_goopts_global' to 'gc_goopts'
LWarrens Nov 15, 2022
410c546
use mode instead of GoContextInfo to store gc_goopts
LWarrens Nov 16, 2022
c88873d
use mode instead of GoContextInfo to store gc_goopts
LWarrens Nov 16, 2022
380cdf6
handle null case for empty go config and gc_goopts
LWarrens Nov 16, 2022
3c36014
handle null case for empty go config and gc_goopts
LWarrens Nov 16, 2022
294dab3
make gc_goopts a string_list
LWarrens Nov 16, 2022
5404e6a
remove unused buildsettinginfo reference
LWarrens Nov 16, 2022
e79333c
fix lint errors using buildifier relevant to changes
LWarrens Nov 16, 2022
530bcb9
Adding gc_linopts to command line flag (#3342)
linzhp Nov 7, 2022
13b2cda
fix lint errors using buildifier relevant to changes
LWarrens Nov 16, 2022
f2c1da5
Adding gc_linopts to command line flag (#3342)
linzhp Nov 7, 2022
aa084fc
fix lint errors using buildifier relevant to changes
LWarrens Nov 16, 2022
caf1f64
remove unused ref to gc_goopts in go_context func
LWarrens Nov 17, 2022
9f5def0
fixing potential type error and taking advantage of mode guaranteeing…
LWarrens Nov 17, 2022
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_goopts = "//go/config:gc_goopts",
gc_linkopts = "//go/config:gc_linkopts",
gotags = "//go/config:tags",
linkmode = "//go/config:linkmode",
Expand Down
6 changes: 6 additions & 0 deletions go/config/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,9 @@ filegroup(
srcs = glob(["**"]),
visibility = ["//visibility:public"],
)

string_list_flag(
name = "gc_goopts",
build_setting_default = [],
visibility = ["//visibility:public"],
)
2 changes: 2 additions & 0 deletions go/private/actions/compilepkg.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@ def emit_compilepkg(
args.add("-testfilter", testfilter)

LWarrens marked this conversation as resolved.
Show resolved Hide resolved
gc_flags = list(gc_goopts)
if go.mode.gc_goopts:
gc_flags.extend(go.mode.gc_goopts)
asm_flags = []
if go.mode.race:
gc_flags.append("-race")
Expand Down
8 changes: 7 additions & 1 deletion go/private/context.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,7 @@ def go_context(ctx, attr = None):
stdlib = None
coverdata = None
nogo = None
gc_goopts = None
LWarrens marked this conversation as resolved.
Show resolved Hide resolved
if hasattr(attr, "_go_context_data"):
go_context_data = _flatten_possibly_transitioned_attr(attr._go_context_data)
if CgoContextInfo in go_context_data:
Expand Down Expand Up @@ -516,7 +517,7 @@ def go_context(ctx, attr = None):
stamp = mode.stamp,
label = ctx.label,
cover_format = mode.cover_format,

gc_goopts = gc_goopts,
# Action generators
archive = toolchain.actions.archive,
asm = toolchain.actions.asm,
Expand Down Expand Up @@ -821,6 +822,7 @@ def _go_config_impl(ctx):
tags = ctx.attr.gotags[BuildSettingInfo].value,
stamp = ctx.attr.stamp,
cover_format = ctx.attr.cover_format[BuildSettingInfo].value,
gc_goopts = ctx.attr.gc_goopts[BuildSettingInfo].value,
amd64 = ctx.attr.amd64,
)]

Expand Down Expand Up @@ -868,6 +870,10 @@ go_config = rule(
mandatory = True,
providers = [BuildSettingInfo],
),
"gc_goopts": attr.label(
mandatory = True,
providers = [BuildSettingInfo],
),
"amd64": attr.string(),
},
provides = [GoConfigInfo],
Expand Down
4 changes: 4 additions & 0 deletions go/private/mode.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ def mode_string(mode):
result.append("stripped")
if not result or not mode.link == LINKMODE_NORMAL:
result.append(mode.link)
if mode.gc_goopts:
result.append(mode.gc_goopts)
return "_".join(result)

def _ternary(*values):
Expand Down Expand Up @@ -83,6 +85,7 @@ def get_mode(ctx, go_toolchain, cgo_context_info, go_config_info):
amd64 = go_config_info.amd64 if go_config_info else None
goos = go_toolchain.default_goos if getattr(ctx.attr, "goos", "auto") == "auto" else ctx.attr.goos
goarch = go_toolchain.default_goarch if getattr(ctx.attr, "goarch", "auto") == "auto" else ctx.attr.goarch
gc_goopts = go_config_info.gc_goopts if go_config_info else ""

# TODO(jayconrod): check for more invalid and contradictory settings.
if pure and race:
Expand Down Expand Up @@ -116,6 +119,7 @@ def get_mode(ctx, go_toolchain, cgo_context_info, go_config_info):
tags = tags,
cover_format = cover_format,
amd64 = amd64,
gc_goopts = gc_goopts,
)

def installsuffix(mode):
Expand Down