Skip to content

Add frontend option -no-serialize-debugging-options #20555

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

Merged
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
7 changes: 4 additions & 3 deletions include/swift/Frontend/FrontendOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,10 @@ class FrontendOptions {
/// Indicates that the input(s) should be parsed as the Swift stdlib.
bool ParseStdlib = false;

/// If set, emitted module files will always contain options for the
/// debugger to use.
bool AlwaysSerializeDebuggingOptions = false;
/// When true, emitted module files will always contain options for the
/// debugger to use. When unset, the options will only be present if the
/// module appears to not be a public module.
Optional<bool> SerializeOptionsForDebugging;

/// If set, inserts instrumentation useful for testing the debugger.
bool DebuggerTestingTransform = false;
Expand Down
3 changes: 3 additions & 0 deletions include/swift/Option/FrontendOptions.td
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,9 @@ def print_clang_stats : Flag<["-"], "print-clang-stats">,

def serialize_debugging_options : Flag<["-"], "serialize-debugging-options">,
HelpText<"Always serialize options for debugging (default: only for apps)">;
def no_serialize_debugging_options :
Flag<["-"], "no-serialize-debugging-options">,
HelpText<"Never serialize options for debugging (default: only for apps)">;

def autolink_library : Separate<["-"], "autolink-library">,
HelpText<"Add dependent library">, Flags<[FrontendOption]>;
Expand Down
8 changes: 6 additions & 2 deletions lib/Frontend/ArgsToFrontendOptionsConverter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,12 @@ bool ArgsToFrontendOptionsConverter::convert(
if (const Arg *A = Args.getLastArg(OPT_module_link_name))
Opts.ModuleLinkName = A->getValue();

Opts.AlwaysSerializeDebuggingOptions |=
Args.hasArg(OPT_serialize_debugging_options);
if (const Arg *A = Args.getLastArg(OPT_serialize_debugging_options,
OPT_no_serialize_debugging_options)) {
Opts.SerializeOptionsForDebugging =
A->getOption().matches(OPT_serialize_debugging_options);
}

Opts.EnableSourceImport |= Args.hasArg(OPT_enable_source_import);
Opts.ImportUnderlyingModule |= Args.hasArg(OPT_import_underlying_module);
Opts.EnableParseableModuleInterface |=
Expand Down
2 changes: 1 addition & 1 deletion lib/Frontend/Frontend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ CompilerInvocation::computeSerializationOptions(const SupplementaryOutputPaths &
// so only serialize them if the module isn't going to be shipped to
// the public.
serializationOpts.SerializeOptionsForDebugging =
!moduleIsPublic || opts.AlwaysSerializeDebuggingOptions;
opts.SerializeOptionsForDebugging.getValueOr(!moduleIsPublic);

return serializationOpts;
}
Expand Down
4 changes: 4 additions & 0 deletions test/Serialization/search-paths.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
// RUN: %target-swift-frontend -emit-module -o %t -I %t/secret -F %t/Frameworks -Fsystem %t/SystemFrameworks -parse-as-library %S/Inputs/has_xref.swift -application-extension
// RUN: %target-swift-frontend %s -typecheck -I %t

// Make sure -no-serialize-debugging-options has the desired effect.
// RUN: %target-swift-frontend -emit-module -o %t -I %t/secret -F %t/Frameworks -Fsystem %t/SystemFrameworks -parse-as-library %S/Inputs/has_xref.swift -application-extension -no-serialize-debugging-options
// RUN: %target-swift-frontend %s -typecheck -I %t -verify -show-diagnostics-after-fatal

// Make sure we don't end up with duplicate search paths.
// RUN: %target-swiftc_driver -emit-module -o %t/has_xref.swiftmodule -I %t/secret -F %t/Frameworks -Fsystem %t/SystemFrameworks -parse-as-library %S/Inputs/has_xref.swift %S/../Inputs/empty.swift -Xfrontend -serialize-debugging-options
// RUN: %target-swift-frontend %s -typecheck -I %t
Expand Down