Skip to content

Commit

Permalink
Swift: don't show non-user triggered warning for serialized debugging…
Browse files Browse the repository at this point in the history
… options

Summary: Ensure we don't trigger `serialize_debugging_options` warnings unnecessarily.

Reviewed By: manicaesar

Differential Revision: D63316586

fbshipit-source-id: d9f1d8763dc654baa495382a038f86fbf8a5ee66
  • Loading branch information
milend authored and facebook-github-bot committed Sep 24, 2024
1 parent 2cde646 commit d841c16
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
8 changes: 7 additions & 1 deletion apple/apple_common.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,13 @@ def _debug_artifacts_validators_arg():

def _serialize_debugging_options_arg():
return {
"serialize_debugging_options": attrs.bool(default = True),
# Need ability to distinguish between no value provided by users
# vs value explicitly set to `True` (in the latter case, we should
# show warning if value cannot be respected in mixed modules while
# in the former, we do not show a warning).
#
# Lack of value defaults to enabling serialized debugging options.
"serialize_debugging_options": attrs.option(attrs.bool(), default = None),
}

def _uses_explicit_modules_arg():
Expand Down
7 changes: 6 additions & 1 deletion apple/swift/swift_compilation.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -578,6 +578,11 @@ def _compile_with_argsfile(
# Swift correctly handles relative paths and we can utilize the relative argsfile for Xcode.
return CompileArgsfiles(relative = {extension: argsfile}, xcode = {extension: argsfile})

def _get_serialize_debugging_options_attr_value(ctx: AnalysisContext):
if ctx.attrs.serialize_debugging_options == None:
return True
return ctx.attrs.serialize_debugging_options

def _get_shared_flags(
ctx: AnalysisContext,
deps_providers: list,
Expand Down Expand Up @@ -657,7 +662,7 @@ def _get_shared_flags(
else:
cmd.add(["-enable-experimental-cxx-interop"])

serialize_debugging_options = ctx.attrs.serialize_debugging_options and (not explicit_modules_enabled) and (not objc_headers) and toolchain.prefix_serialized_debugging_options
serialize_debugging_options = _get_serialize_debugging_options_attr_value(ctx) and (not explicit_modules_enabled) and (not objc_headers) and toolchain.prefix_serialized_debugging_options
if serialize_debugging_options:
cmd.add([
"-Xfrontend",
Expand Down

0 comments on commit d841c16

Please sign in to comment.