mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2024-12-14 11:39:35 +00:00
[COFF] Clean up debug option handling
/debug and /debug:dwarf are orthogonal. An object file can contain both CodeView and DWARF debug info, so the combination of /debug:dwarf and /debug should generate both DWARF and a PDB, rather than /debug:dwarf always suppressing PDB creation. /nopdb is now redundant and can be removed. /debug /nopdb was previously used to support DWARF, but specifying /debug:dwarf is entirely equivalent to that combination now. Differential Revision: https://reviews.llvm.org/D41310 llvm-svn: 320896
This commit is contained in:
parent
81bbf74265
commit
a1f6fba4d1
@ -818,8 +818,10 @@ void LinkerDriver::link(ArrayRef<const char *> ArgsArr) {
|
||||
}
|
||||
|
||||
// Handle /pdb
|
||||
if (auto *Arg = Args.getLastArg(OPT_pdb))
|
||||
Config->PDBPath = Arg->getValue();
|
||||
bool ShouldCreatePDB = Args.hasArg(OPT_debug, OPT_debug_ghash);
|
||||
if (ShouldCreatePDB)
|
||||
if (auto *Arg = Args.getLastArg(OPT_pdb))
|
||||
Config->PDBPath = Arg->getValue();
|
||||
|
||||
// Handle /noentry
|
||||
if (Args.hasArg(OPT_noentry)) {
|
||||
@ -1145,15 +1147,11 @@ void LinkerDriver::link(ArrayRef<const char *> ArgsArr) {
|
||||
}
|
||||
|
||||
// Put the PDB next to the image if no /pdb flag was passed.
|
||||
if (Config->Debug && Config->PDBPath.empty()) {
|
||||
if (ShouldCreatePDB && Config->PDBPath.empty()) {
|
||||
Config->PDBPath = Config->OutputFile;
|
||||
sys::path::replace_extension(Config->PDBPath, ".pdb");
|
||||
}
|
||||
|
||||
// Disable PDB generation if the user requested it.
|
||||
if (Args.hasArg(OPT_nopdb, OPT_debug_dwarf))
|
||||
Config->PDBPath = "";
|
||||
|
||||
// Set default image base if /base is not given.
|
||||
if (Config->ImageBase == uint64_t(-1))
|
||||
Config->ImageBase = getDefaultImageBase();
|
||||
|
@ -120,7 +120,6 @@ def help_q : Flag<["/?", "-?"], "">, Alias<help>;
|
||||
def debug_ghash : F<"debug:ghash">;
|
||||
def debug_dwarf : F<"debug:dwarf">;
|
||||
def export_all_symbols : F<"export-all-symbols">;
|
||||
def nopdb : F<"nopdb">, HelpText<"Disable PDB generation for DWARF users">;
|
||||
def lldmingw : F<"lldmingw">;
|
||||
def msvclto : F<"msvclto">;
|
||||
def output_def : Joined<["/", "-"], "output-def:">;
|
||||
|
19
lld/test/COFF/debug-dwarf.test
Normal file
19
lld/test/COFF/debug-dwarf.test
Normal file
@ -0,0 +1,19 @@
|
||||
# Check that /debug creates %t.pdb.
|
||||
# RUN: rm -f %t.pdb
|
||||
# RUN: lld-link /debug /entry:main /out:%t.exe %p/Inputs/ret42.obj
|
||||
# RUN: ls %t.pdb
|
||||
|
||||
# Check that /debug:dwarf does not create %t.pdb.
|
||||
# RUN: rm -f %t.pdb
|
||||
# RUN: lld-link /debug:dwarf /entry:main /out:%t.exe %p/Inputs/ret42.obj
|
||||
# RUN: not ls %t.pdb
|
||||
|
||||
# Check that /debug:dwarf /debug creates %t.pdb.
|
||||
# RUN: rm -f %t.pdb
|
||||
# RUN: lld-link /debug:dwarf /debug /entry:main /out:%t.exe %p/Inputs/ret42.obj
|
||||
# RUN: ls %t.pdb
|
||||
|
||||
# Check that /debug:dwarf /pdb:%t.pdb does not create %t.pdb.
|
||||
# RUN: rm -f %t.pdb
|
||||
# RUN: lld-link /debug:dwarf /pdb:%t.pdb /entry:main /out:%t.exe %p/Inputs/ret42.obj
|
||||
# RUN: not ls %t.pdb
|
@ -1,14 +0,0 @@
|
||||
# Check that /debug creates %t.pdb.
|
||||
# RUN: rm -f %t.pdb
|
||||
# RUN: lld-link /debug /entry:main /out:%t.exe %p/Inputs/ret42.obj
|
||||
# RUN: ls %t.pdb
|
||||
|
||||
# Check that /debug /nopdb does not create %t.pdb.
|
||||
# RUN: rm -f %t.pdb
|
||||
# RUN: lld-link /debug /nopdb /entry:main /out:%t.exe %p/Inputs/ret42.obj
|
||||
# RUN: not ls %t.pdb
|
||||
|
||||
# Check that /debug /nopdb /pdb:%t.pdb does not create %t.pdb.
|
||||
# RUN: rm -f %t.pdb
|
||||
# RUN: lld-link /debug /nopdb /pdb:%t.pdb /entry:main /out:%t.exe %p/Inputs/ret42.obj
|
||||
# RUN: not ls %t.pdb
|
Loading…
Reference in New Issue
Block a user