[LLD] [COFF] Add /debug: options nodwarf and nosymtab (#75180)

These allow tweaking what gets implied by /debug and /debug:dwarf.

GitOrigin-RevId: e36535d4bebadfbcfea34aa369743aafc43dcf6c
diff --git a/COFF/Driver.cpp b/COFF/Driver.cpp
index f9abc8c..4f11aff 100644
--- a/COFF/Driver.cpp
+++ b/COFF/Driver.cpp
@@ -1652,9 +1652,13 @@
         config->writeSymtab = true;
         config->warnLongSectionNames = false;
         doGC = false;
+      } else if (s == "nodwarf") {
+        config->includeDwarfChunks = false;
       } else if (s == "symtab") {
         config->writeSymtab = true;
         doGC = false;
+      } else if (s == "nosymtab") {
+        config->writeSymtab = false;
       } else {
         error("/debug: unknown option: " + s);
       }
diff --git a/test/COFF/debug-dwarf.test b/test/COFF/debug-dwarf.test
index eacf363..c52e7c6 100644
--- a/test/COFF/debug-dwarf.test
+++ b/test/COFF/debug-dwarf.test
@@ -25,3 +25,8 @@
 # RUN: rm -f %t.pdb
 # RUN: lld-link /debug:full,dwarf /entry:main /out:%t.exe %p/Inputs/ret42.obj
 # RUN: ls %t.pdb
+
+# Check that /debug /debug:full,nodwarf creates %t.pdb.
+# RUN: rm -f %t.pdb
+# RUN: lld-link /debug:full,nodwarf /entry:main /out:%t.exe %p/Inputs/ret42.obj
+# RUN: ls %t.pdb
diff --git a/test/COFF/sort-debug.test b/test/COFF/sort-debug.test
index bbe2ecd..30cad39 100644
--- a/test/COFF/sort-debug.test
+++ b/test/COFF/sort-debug.test
@@ -7,6 +7,10 @@
 # RUN: llvm-readobj --sections %t.exe | FileCheck -check-prefix=NODEBUG %s
 # RUN: lld-link /debug:symtab /out:%t.exe /entry:main %t.obj
 # RUN: llvm-readobj --sections %t.exe | FileCheck -check-prefix=NODEBUG %s
+# RUN: lld-link /debug:full,nodwarf /out:%t.exe /entry:main %t.obj
+# RUN: llvm-readobj --sections %t.exe | FileCheck -check-prefix=NODEBUG %s
+# RUN: lld-link /debug:full /debug:nodwarf /out:%t.exe /entry:main %t.obj
+# RUN: llvm-readobj --sections %t.exe | FileCheck -check-prefix=NODEBUG %s
 
 # CHECK: Name: .text
 # CHECK: Name: .reloc
diff --git a/test/COFF/symtab.test b/test/COFF/symtab.test
index f657543..45e8ed3 100644
--- a/test/COFF/symtab.test
+++ b/test/COFF/symtab.test
@@ -10,6 +10,8 @@
 
 # RUN: lld-link /debug /out:%t.exe /entry:main %t.obj %p/Inputs/std64.lib
 # RUN: llvm-readobj --symbols %t.exe | FileCheck -check-prefix=NO %s
+# RUN: lld-link /debug:dwarf,nosymtab /out:%t.exe /entry:main %t.obj %p/Inputs/std64.lib
+# RUN: llvm-readobj --symbols %t.exe | FileCheck -check-prefix=NO %s
 
 # CHECK:      Symbols [
 # CHECK-NEXT:   Symbol {