Skip to content

Commit 38b8a8d

Browse files
skruegerfacebook-github-bot
authored andcommitted
Replace CompileArgsfile#input_args with cmd_form to materialize dependent Artifacts
Summary: Replace the usage of `CompileArgsfile#input_args` `CompileArgsfile#cmd_form` to materialize dependent `Artifact`s of the subtargets `[argsfiles]` and `[xcode-argsfiles]` to save memory and simplify. `CompileArgsfile#cmd_form` stores all the dependent `Artifact`s of `CompileArgsfile#file`, so `CompileArgsfile#input_args` is redundant.This results in less retained memory usage in analysis (based off `buck2 profile analysis --recursive --mode heap-summary-retained $TARGET`) because `CompileArgsfile` is smaller. Reviewed By: christycylee Differential Revision: D75712066 fbshipit-source-id: 42a787ea3632624c39a3845560f66e4adcd8ed0a
1 parent 9e3f087 commit 38b8a8d

File tree

3 files changed

+6
-8
lines changed

3 files changed

+6
-8
lines changed

prelude/apple/swift/swift_compilation.bzl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -842,7 +842,6 @@ def _compile_with_argsfile(
842842
argsfile = CompileArgsfile(
843843
file = argsfile,
844844
cmd_form = argsfile_cmd_form,
845-
input_args = [shared_flags],
846845
args = shell_quoted_args,
847846
args_without_file_prefix_args = shared_flags,
848847
)

prelude/cxx/argsfiles.bzl

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ CompileArgsfile = record(
1313
file = field(Artifact),
1414
# This argsfile as a command form that would use the argsfile (includes dependent inputs).
1515
cmd_form = field(cmd_args),
16-
# Input args necessary for the argsfile to reference.
17-
input_args = field(list[cmd_args]),
1816
# Args as written to the argsfile (with shell quoting applied).
1917
args = field(cmd_args),
2018
# Args aggregated for the argsfile excluding file prefix args (excludes shell quoting).
@@ -35,7 +33,11 @@ def get_argsfiles_output(ctx: AnalysisContext, argsfile_by_ext: dict[str, Compil
3533
for _, argsfile in argsfile_by_ext.items():
3634
argsfiles.append(argsfile.file)
3735
argsfile_names.append(cmd_args(argsfile.file, ignore_artifacts = True))
38-
dependent_outputs.extend(argsfile.input_args)
36+
37+
# To materialize the dependent `Artifact`s of `CompileArgsfile#file`,
38+
# `CompileArgsfile#cmd_form` is returned in `DefaultInfo#other_outputs`,
39+
# because it tracks the dependents through the `cmd_args` API.
40+
dependent_outputs.append(argsfile.cmd_form)
3941

4042
argsfiles_summary = ctx.actions.write(summary_name, cmd_args(argsfile_names))
4143

prelude/cxx/compile.bzl

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1129,7 +1129,6 @@ def _mk_argsfiles(
11291129
return CompileArgsfile(
11301130
file = argsfile,
11311131
cmd_form = cmd_form,
1132-
input_args = input_args,
11331132
args = args,
11341133
args_without_file_prefix_args = args_without_file_prefix_args,
11351134
)
@@ -1186,15 +1185,13 @@ def _mk_header_units_argsfile(
11861185
# TODO(nml): Tag args with headers_tag.tag_artifacts() once -MD -MF reports correct
11871186
# usage of PCMs.
11881187
args.add(preprocessor.set.project_as_args("header_units_args"))
1189-
input_args = [args]
11901188
file_args = cmd_args(args, quote = "shell")
11911189
argsfile, _ = ctx.actions.write(file_name, file_args, allow_args = True)
1192-
cmd_form = cmd_args(argsfile, format = "@{}", hidden = input_args)
1190+
cmd_form = cmd_args(argsfile, format = "@{}", hidden = file_args)
11931191

11941192
return CompileArgsfile(
11951193
file = argsfile,
11961194
cmd_form = cmd_form,
1197-
input_args = input_args,
11981195
args = file_args,
11991196
args_without_file_prefix_args = args,
12001197
)

0 commit comments

Comments
 (0)