Make the DWARF version emitted by the Swift compiler configurable.

Previously it was hardcoded to version 4 on all platforms.
This patch introduces a driver and frontend option -dwarf-version to configure it if needed.
This commit is contained in:
Adrian Prantl
2023-10-18 13:15:35 -07:00
parent d19fe381fa
commit a26bbb0baf
9 changed files with 76 additions and 6 deletions

View File

@@ -2472,7 +2472,6 @@ static bool ParseIRGenArgs(IRGenOptions &Opts, ArgList &Args,
Opts.DebugCompilationDir = std::string(cwd.str());
}
}
if (const Arg *A = Args.getLastArg(options::OPT_debug_info_format)) {
if (A->containsValue("dwarf"))
Opts.DebugInfoFormat = IRGenDebugInfoFormat::DWARF;
@@ -2502,6 +2501,16 @@ static bool ParseIRGenArgs(IRGenOptions &Opts, ArgList &Args,
: "-gdwarf_types");
}
if (auto A = Args.getLastArg(OPT_dwarf_version)) {
unsigned vers;
if (!StringRef(A->getValue()).getAsInteger(10, vers) && vers >= 2 &&
vers <= 5)
Opts.DWARFVersion = vers;
else
Diags.diagnose(SourceLoc(), diag::error_invalid_arg_value,
A->getAsString(Args), A->getValue());
}
for (auto A : Args.getAllArgValues(options::OPT_file_prefix_map)) {
auto SplitMap = StringRef(A).split('=');
Opts.FilePrefixMap.addMapping(SplitMap.first, SplitMap.second);