Skip to content

Commit 0acc73a

Browse files
committed
Update flag name to -debug-info-store-invocation.
1 parent 22ac700 commit 0acc73a

File tree

8 files changed

+18
-15
lines changed

8 files changed

+18
-15
lines changed

include/swift/Driver/ToolChain.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -197,9 +197,11 @@ class ToolChain {
197197
const llvm::opt::ArgList &args,
198198
StringRef extraEntry = "") const;
199199

200-
/// Specific toolchains should override this to indicate whether the
201-
/// compilation flags should be written into DWARF debug info.
202-
virtual bool usesDWARFDebugFlags() const { return false; }
200+
/// Specific toolchains should override this to provide additional conditions
201+
/// under which the compiler invocation should be written into debug info. For
202+
/// example, Darwin does this if the RC_DEBUG_OPTIONS environment variable is
203+
/// set to match the behavior of Clang.
204+
virtual bool shouldStoreInvocationInDebugInfo() const { return false; }
203205

204206
public:
205207
virtual ~ToolChain() = default;

include/swift/Option/FrontendOptions.td

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -486,7 +486,4 @@ def disable_verify_exclusivity : Flag<["-"], "disable-verify-exclusivity">,
486486
def enable_key_path_resilience : Flag<["-"], "enable-key-path-resilience">,
487487
HelpText<"Enable key path resilience.">;
488488

489-
def use_dwarf_debug_flags : Flag<["-"], "use-dwarf-debug-flags">,
490-
HelpText<"Write the compilation flags into the DWARF debug info.">;
491-
492489
} // end let Flags = [FrontendOption, NoDriverOption, HelpHidden]

include/swift/Option/Options.td

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -473,6 +473,10 @@ def verify_debug_info : Flag<["-"], "verify-debug-info">,
473473
Flags<[NoInteractiveOption, DoesNotAffectIncrementalBuild]>,
474474
HelpText<"Verify the binary representation of debug output.">;
475475

476+
def debug_info_store_invocation : Flag<["-"], "debug-info-store-invocation">,
477+
Flags<[FrontendOption]>,
478+
HelpText<"Emit the compiler invocation in the debug info.">;
479+
476480
// Assert configuration identifiers.
477481
def AssertConfig : Separate<["-"], "assert-config">,
478482
Flags<[FrontendOption]>,

lib/Driver/DarwinToolChains.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,7 @@ toolchains::Darwin::constructInvocation(const LinkJobAction &job,
452452
return II;
453453
}
454454

455-
bool toolchains::Darwin::usesDWARFDebugFlags() const {
455+
bool toolchains::Darwin::shouldStoreInvocationInDebugInfo() const {
456456
// This matches the behavior in Clang (see
457457
// clang/lib/driver/ToolChains/Darwin.cpp).
458458
if (const char *S = ::getenv("RC_DEBUG_OPTIONS"))

lib/Driver/ToolChains.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -360,9 +360,9 @@ ToolChain::constructInvocation(const CompileJobAction &job,
360360
Arguments.push_back("-index-system-modules");
361361
}
362362

363-
// Request whether the compilation flags should be written into DWARF info.
364-
if (usesDWARFDebugFlags()) {
365-
Arguments.push_back("-use-dwarf-debug-flags");
363+
if (context.Args.hasArg(options::OPT_debug_info_store_invocation) ||
364+
shouldStoreInvocationInDebugInfo()) {
365+
Arguments.push_back("-debug-info-store-invocation");
366366
}
367367

368368
return II;

lib/Driver/ToolChains.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class LLVM_LIBRARY_VISIBILITY Darwin : public ToolChain {
3030

3131
std::string findProgramRelativeToSwiftImpl(StringRef name) const override;
3232

33-
bool usesDWARFDebugFlags() const override;
33+
bool shouldStoreInvocationInDebugInfo() const override;
3434

3535
public:
3636
Darwin(const Driver &D, const llvm::Triple &Triple) : ToolChain(D, Triple) {}

lib/Frontend/CompilerInvocation.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -769,7 +769,7 @@ static bool ParseIRGenArgs(IRGenOptions &Opts, ArgList &Args,
769769
"unknown -g<kind> option");
770770

771771
if (Opts.DebugInfoKind > IRGenDebugInfoKind::LineTables) {
772-
if (Args.hasArg(options::OPT_use_dwarf_debug_flags)) {
772+
if (Args.hasArg(options::OPT_debug_info_store_invocation)) {
773773
ArgStringList RenderedArgs;
774774
for (auto A : Args)
775775
A->render(Args, RenderedArgs);

test/DebugInfo/compiler-flags.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
// Check that the sdk and resource dirs end up in the debug info if we pass the
22
// frontend flag. This tests the general functionality; we test the macosx
33
// specific toolchain logic in compiler-flags-macosx.swift.
4-
// RUN: %target-swiftc_driver %s -emit-ir -Xfrontend -use-dwarf-debug-flags -g -o - | %FileCheck %s
5-
// RUN: %target-swiftc_driver %s -emit-ir -Xfrontend -use-dwarf-debug-flags -sdk "/Weird Location/SDK" -g -o - | %FileCheck --check-prefix CHECK-EXPLICIT %s
4+
// RUN: %target-swiftc_driver %s -emit-ir -debug-info-store-invocation -g -o - | %FileCheck %s
5+
// RUN: %target-swiftc_driver %s -emit-ir -debug-info-store-invocation -sdk "/Weird Location/SDK" -g -o - | %FileCheck --check-prefix CHECK-EXPLICIT %s
66
// CHECK: !DICompileUnit({{.*}}producer: "{{(Apple )?Swift version [^"]+}}"
77
// CHECK-SAME: flags: "
88
// CHECK-NOT: "
@@ -15,6 +15,6 @@
1515
// CHECK-EXPLICIT-SAME: -resource-dir
1616

1717
// Check that we don't write temporary file names in the debug info
18-
// RUN: TMPDIR=abc/def %target-swift-frontend %s -I abc/def/xyz -g -emit-ir -use-dwarf-debug-flags -o - | %FileCheck --check-prefix CHECK-TEMP %s
18+
// RUN: TMPDIR=abc/def %target-swift-frontend %s -I abc/def/xyz -g -emit-ir -debug-info-store-invocation -o - | %FileCheck --check-prefix CHECK-TEMP %s
1919
// CHECK-TEMP: !DICompileUnit({{.*}} flags: "{{.*}} -I <temporary-file>
2020

0 commit comments

Comments
 (0)