Skip to content

[DebugInfo] Emit embedded swift into DW_AT_APPLE_flags #71962

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
Mar 1, 2024
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
9 changes: 8 additions & 1 deletion include/swift/AST/IRGenOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -602,7 +602,8 @@ class IRGenOptions {
}

std::string getDebugFlags(StringRef PrivateDiscriminator,
bool EnableCXXInterop) const {
bool EnableCXXInterop,
bool EnableEmbeddedSwift) const {
std::string Flags = DebugFlags;
if (!PrivateDiscriminator.empty()) {
if (!Flags.empty())
Expand All @@ -614,6 +615,12 @@ class IRGenOptions {
Flags += " ";
Flags += "-enable-experimental-cxx-interop";
}
if (EnableEmbeddedSwift) {
if (!Flags.empty())
Flags += " ";
Flags += "-enable-embedded-swift";
}

return Flags;
}

Expand Down
5 changes: 4 additions & 1 deletion lib/IRGen/IRGenDebugInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2357,9 +2357,12 @@ IRGenDebugInfoImpl::IRGenDebugInfoImpl(const IRGenOptions &Opts,

bool EnableCXXInterop =
IGM.getSILModule().getASTContext().LangOpts.EnableCXXInterop;
bool EnableEmbeddedSwift =
IGM.getSILModule().getASTContext().LangOpts.hasFeature(Feature::Embedded);
TheCU = DBuilder.createCompileUnit(
Lang, MainFile, Producer, Opts.shouldOptimize(),
Opts.getDebugFlags(PD, EnableCXXInterop), MajorRuntimeVersion, SplitName,
Opts.getDebugFlags(PD, EnableCXXInterop, EnableEmbeddedSwift),
MajorRuntimeVersion, SplitName,
Opts.DebugInfoLevel > IRGenDebugInfoLevel::LineTables
? llvm::DICompileUnit::FullDebug
: llvm::DICompileUnit::LineTablesOnly,
Expand Down
6 changes: 4 additions & 2 deletions lib/IRGen/IRGenModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,14 +122,16 @@ static clang::CodeGenerator *createClangCodeGenerator(ASTContext &Context,
CGO.DebugCompilationDir = Opts.DebugCompilationDir;
CGO.DwarfVersion = Opts.DWARFVersion;
CGO.DwarfDebugFlags =
Opts.getDebugFlags(PD, Context.LangOpts.EnableCXXInterop);
Opts.getDebugFlags(PD, Context.LangOpts.EnableCXXInterop,
Context.LangOpts.hasFeature(Feature::Embedded));
break;
case IRGenDebugInfoFormat::CodeView:
CGO.EmitCodeView = true;
CGO.DebugCompilationDir = Opts.DebugCompilationDir;
// This actually contains the debug flags for codeview.
CGO.DwarfDebugFlags =
Opts.getDebugFlags(PD, Context.LangOpts.EnableCXXInterop);
Opts.getDebugFlags(PD, Context.LangOpts.EnableCXXInterop,
Context.LangOpts.hasFeature(Feature::Embedded));
break;
}
if (!Opts.TrapFuncName.empty()) {
Expand Down
10 changes: 10 additions & 0 deletions test/DebugInfo/embedded.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// Check that the "-enable-embedded-swift" is stored as a flag in the
// Compile Unit.

// RUN: %target-swift-frontend -emit-ir -enable-experimental-feature Embedded -g %s -o - | %FileCheck %s

// REQUIRES: swift_in_compiler
// REQUIRES: executable_test
// REQUIRES: OS=macosx

// CHECK: !DICompileUnit({{.*}}flags: "-enable-embedded-swift"