From 6ed1173d9a3090387e51a6db712091b9f08afc33 Mon Sep 17 00:00:00 2001 From: Richard Howell Date: Thu, 10 Oct 2024 10:37:20 -0700 Subject: [PATCH] add dsym_uses_parallel_linker Summary: Add the `dsym_uses_parallel_linker` attribute to be able to enable parallel dSYM generation for improved performance and reduced output size. Reviewed By: maxovtsin Differential Revision: D64131359 fbshipit-source-id: 5dd85aa3435cbecc544e9947a086518dfa9bb433 --- prelude/apple/apple_dsym.bzl | 17 ++++++++++------- prelude/apple/apple_rules_impl_utility.bzl | 1 + 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/prelude/apple/apple_dsym.bzl b/prelude/apple/apple_dsym.bzl index 3bbf5180b914..f0726af1bea3 100644 --- a/prelude/apple/apple_dsym.bzl +++ b/prelude/apple/apple_dsym.bzl @@ -21,27 +21,30 @@ def get_apple_dsym(ctx: AnalysisContext, executable: Artifact, debug_info: list[ def get_apple_dsym_ext(ctx: AnalysisContext, executable: [ArgLike, Artifact], debug_info: list[ArgLike], action_identifier: str, output_path: str) -> Artifact: dsymutil = ctx.attrs._apple_toolchain[AppleToolchainInfo].dsymutil output = ctx.actions.declare_output(output_path, dir = True) - cmd = cmd_args( [ dsymutil, "--verify-dwarf={}".format(ctx.attrs._dsymutil_verify_dwarf), # Reproducers are not useful, we can reproduce from the action digest. "--reproducer=Off", - ] + ctx.attrs._dsymutil_extra_flags + [ - "-o", - output.as_output(), ], - executable, # Mach-O executables don't contain DWARF data. # Instead, they contain paths to the object files which themselves contain DWARF data. - # # So, those object files are needed for dsymutil to be to create the dSYM bundle. hidden = debug_info, ) + if ctx.attrs.dsym_uses_parallel_linker: + cmd.add("--linker=parallel") + cmd.add(ctx.attrs._dsymutil_extra_flags) + cmd.add( + [ + "-o", + output.as_output(), + executable, + ], + ) ctx.actions.run(cmd, category = "apple_dsym", identifier = action_identifier) - return output def get_apple_dsym_info_json(binary_dsyms: list[Artifact], dep_dsyms: list[Artifact]) -> dict[str, typing.Any]: diff --git a/prelude/apple/apple_rules_impl_utility.bzl b/prelude/apple/apple_rules_impl_utility.bzl index 48de586122b8..b1f14f0ec845 100644 --- a/prelude/apple/apple_rules_impl_utility.bzl +++ b/prelude/apple/apple_rules_impl_utility.bzl @@ -66,6 +66,7 @@ APPLE_VALIDATION_DEPS_ATTR_TYPE = attrs.set(attrs.dep(), sorted = True, default def apple_dsymutil_attrs(): return { + "dsym_uses_parallel_linker": attrs.bool(default = False), "_dsymutil_extra_flags": attrs.list(attrs.string()), "_dsymutil_verify_dwarf": attrs.string(), }