Skip to content

Commit 60590b1

Browse files
committed
[Remarks][Driver] Ask for line tables when remarks are enabled
Serialized remarks contain debug locations for each remark, by storing a file path, a line, and a column. Also, remarks support being embedded in a .dSYM bundle using a separate section in object files, that is found by `dsymutil` through the debug map. In order for tools to map addresses to source and display remarks in the source, we need line tables, and in order for `dsymutil` to find the object files containing the remark section, we need to keep the debug map around. Differential Revision: https://reviews.llvm.org/D71325
1 parent d5a43ce commit 60590b1

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

clang/lib/Driver/ToolChains/Clang.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3717,6 +3717,11 @@ static void RenderDebugOptions(const ToolChain &TC, const Driver &D,
37173717
// Adjust the debug info kind for the given toolchain.
37183718
TC.adjustDebugInfoKind(DebugInfoKind, Args);
37193719

3720+
// When emitting remarks, we need at least debug lines in the output.
3721+
if (shouldEmitRemarks(Args) &&
3722+
DebugInfoKind <= codegenoptions::DebugDirectivesOnly)
3723+
DebugInfoKind = codegenoptions::DebugLineTablesOnly;
3724+
37203725
RenderDebugEnablingArgs(Args, CmdArgs, DebugInfoKind, DWARFVersion,
37213726
DebuggerTuning);
37223727

clang/test/Driver/debug-options.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,12 @@
6464
// RUN: %clang -### -c -g %s -target arm64-apple-tvos9.0 2>&1 \
6565
// RUN: | FileCheck -check-prefix=G_STANDALONE \
6666
// RUN: -check-prefix=G_DWARF4 %s
67+
// RUN: %clang -### -c -fsave-optimization-record %s \
68+
// RUN: -target x86_64-apple-darwin 2>&1 \
69+
// RUN: | FileCheck -check-prefix=GLTO_ONLY %s
70+
// RUN: %clang -### -c -g -fsave-optimization-record %s \
71+
// RUN: -target x86_64-apple-darwin 2>&1 \
72+
// RUN: | FileCheck -check-prefix=G_STANDALONE %s
6773

6874
// FreeBSD.
6975
// RUN: %clang -### -c -g %s -target x86_64-pc-freebsd11.0 2>&1 \

0 commit comments

Comments
 (0)