Skip to content

Add an option to disable DWARF skeleton CU breadcrumbs for Clang #23779

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 1 commit into from
Apr 4, 2019
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
11 changes: 8 additions & 3 deletions include/swift/AST/IRGenOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,14 +104,17 @@ class IRGenOptions {
/// Which sanitizer is turned on.
OptionSet<SanitizerKind> Sanitizers;

/// Path prefixes that should be rewritten in debug info.
PathRemapper DebugPrefixMap;

/// What level of debug info to generate.
IRGenDebugInfoLevel DebugInfoLevel : 2;

/// What type of debug info to generate.
IRGenDebugInfoFormat DebugInfoFormat : 2;

/// Path prefixes that should be rewritten in debug info.
PathRemapper DebugPrefixMap;
/// Whether to leave DWARF breadcrumbs pointing to imported Clang modules.
unsigned DisableClangModuleSkeletonCUs : 1;

/// Whether we're generating IR for the JIT.
unsigned UseJIT : 1;
Expand Down Expand Up @@ -227,7 +230,9 @@ class IRGenOptions {
Verify(true), OptMode(OptimizationMode::NotSet),
Sanitizers(OptionSet<SanitizerKind>()),
DebugInfoLevel(IRGenDebugInfoLevel::None),
DebugInfoFormat(IRGenDebugInfoFormat::None), UseJIT(false),
DebugInfoFormat(IRGenDebugInfoFormat::None),
DisableClangModuleSkeletonCUs(false),
UseJIT(false),
IntegratedREPL(false), DisableLLVMOptzns(false),
DisableSwiftSpecificLLVMOptzns(false), DisableLLVMSLPVectorizer(false),
DisableFPElim(true), Playground(false), EmitStackPromotionChecks(false),
Expand Down
4 changes: 4 additions & 0 deletions include/swift/Option/FrontendOptions.td
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,10 @@ def disable_playground_transform : Flag<["-"], "disable-playground-transform">,
def pc_macro : Flag<["-"], "pc-macro">,
HelpText<"Apply the 'program counter simulation' macro">;

def no_clang_module_breadcrumbs : Flag<["-"], "no-clang-module-breadcrumbs">,
HelpText<"Don't emit DWARF skeleton CUs for imported Clang modules. "
"Use this when building a redistributable static archive.">;

def use_jit : Flag<["-"], "use-jit">,
HelpText<"Register Objective-C classes as if the JIT were in use">;

Expand Down
3 changes: 3 additions & 0 deletions lib/Frontend/CompilerInvocation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1002,6 +1002,9 @@ static bool ParseIRGenArgs(IRGenOptions &Opts, ArgList &Args,

Opts.ModuleName = FrontendOpts.ModuleName;

if (Args.hasArg(OPT_no_clang_module_breadcrumbs))
Opts.DisableClangModuleSkeletonCUs = true;

if (Args.hasArg(OPT_use_jit))
Opts.UseJIT = true;

Expand Down
23 changes: 13 additions & 10 deletions lib/IRGen/IRGenDebugInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -640,16 +640,19 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
std::string RemappedIncludePath = DebugPrefixMap.remapPath(IncludePath);

// For Clang modules / PCH, create a Skeleton CU pointing to the PCM/PCH.
bool CreateSkeletonCU = !ASTFile.empty();
bool IsRootModule = !Parent;
if (CreateSkeletonCU && IsRootModule) {
llvm::DIBuilder DIB(M);
DIB.createCompileUnit(IGM.ObjCInterop ? llvm::dwarf::DW_LANG_ObjC
: llvm::dwarf::DW_LANG_C99,
DIB.createFile(Name, RemappedIncludePath),
TheCU->getProducer(), true, StringRef(), 0, ASTFile,
llvm::DICompileUnit::FullDebug, Signature);
DIB.finalize();
if (!Opts.DisableClangModuleSkeletonCUs) {
bool CreateSkeletonCU = !ASTFile.empty();
bool IsRootModule = !Parent;
if (CreateSkeletonCU && IsRootModule) {
llvm::DIBuilder DIB(M);
DIB.createCompileUnit(IGM.ObjCInterop ? llvm::dwarf::DW_LANG_ObjC
: llvm::dwarf::DW_LANG_C99,
DIB.createFile(Name, RemappedIncludePath),
TheCU->getProducer(), true, StringRef(), 0,
ASTFile, llvm::DICompileUnit::FullDebug,
Signature);
DIB.finalize();
}
}

StringRef Sysroot = IGM.Context.SearchPathOpts.SDKPath;
Expand Down
7 changes: 7 additions & 0 deletions test/DebugInfo/ClangModuleBreadcrumbs.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
// RUN: %target-swift-frontend -emit-ir %s -g -I %S/Inputs \
// RUN: -Xcc -DFOO="foo" -Xcc -UBAR -o - | %FileCheck %s
//
// RUN: %target-swift-frontend -emit-ir %s -g -I %S/Inputs \
// RUN: -Xcc -DFOO="foo" -Xcc -UBAR -o - -no-clang-module-breadcrumbs \
// RUN: | %FileCheck %s --check-prefix=NONE
import ClangModule.SubModule
import OtherClangModule.SubModule

Expand All @@ -11,3 +15,6 @@ import OtherClangModule.SubModule
// CHECK: !DICompileUnit(language: DW_LANG_{{ObjC|C99}}, {{.*}} producer: "{{.*}}Swift
// CHECK-SAME: OtherClangModule
// CHECK-SAME: dwoId:

// NONE: DICompileUnit({{.*}}
// NONE-NOT: DICompileUnit({{.*}}ClangModule