Skip to content
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

[DebugInfo] Support for DWARF 4/5 and fix of issues related to -gdwarf-X options #3

Merged
merged 1 commit into from
Oct 9, 2020
Merged
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
42 changes: 24 additions & 18 deletions clang/lib/Driver/ToolChains/ClassicFlang.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -327,28 +327,34 @@ void ClassicFlang::ConstructJob(Compilation &C, const JobAction &JA,
LowerCmdArgs.push_back("0x8");
}

// -g should produce DWARFv2
for (auto Arg : Args.filtered(options::OPT_g_Flag)) {
Arg->claim();
CommonCmdArgs.push_back("-x");
CommonCmdArgs.push_back("120");
CommonCmdArgs.push_back("0x200");
}
// Last argument of -g/-gdwarfX should be taken.
Arg *GArg = Args.getLastArg(options::OPT_g_Flag);
Arg *GDwarfArg = Args.getLastArg(options::OPT_gdwarf_2,
options::OPT_gdwarf_3,
options::OPT_gdwarf_4,
options::OPT_gdwarf_5);

if (GArg || GDwarfArg) {

for (auto Arg : Args.filtered(options::OPT_g_Flag, options::OPT_gdwarf_2,
options::OPT_gdwarf_3, options::OPT_gdwarf_4,
options::OPT_gdwarf_5)) {
Arg->claim();
}

// -gdwarf-2
for (auto Arg : Args.filtered(options::OPT_gdwarf_2)) {
Arg->claim();
CommonCmdArgs.push_back("-x");
CommonCmdArgs.push_back("120");
CommonCmdArgs.push_back("0x200");
}

// -gdwarf-3
for (auto Arg : Args.filtered(options::OPT_gdwarf_3)) {
Arg->claim();
CommonCmdArgs.push_back("-x");
CommonCmdArgs.push_back("120");
CommonCmdArgs.push_back("0x4000");
if (!GDwarfArg) // -g without -gdwarf-X produces default (DWARFv4)
CommonCmdArgs.push_back("0x1000000");
else if (GDwarfArg->getOption().matches(options::OPT_gdwarf_2)) // -gdwarf-2
CommonCmdArgs.push_back("0x200");
else if (GDwarfArg->getOption().matches(options::OPT_gdwarf_3)) // -gdwarf-3
CommonCmdArgs.push_back("0x4000");
else if (GDwarfArg->getOption().matches(options::OPT_gdwarf_4)) // -gdwarf-4
CommonCmdArgs.push_back("0x1000000");
else if (GDwarfArg->getOption().matches(options::OPT_gdwarf_5)) // -gdwarf-5
CommonCmdArgs.push_back("0x2000000");
}

// -Mipa has no effect
Expand Down