[lld] [LLD] [COFF] Add /debug: options nodwarf and nosymtab (PR #75180)
Martin Storsjö via llvm-commits
llvm-commits at lists.llvm.org
Fri Dec 15 10:10:29 PST 2023
https://github.com/mstorsjo updated https://github.com/llvm/llvm-project/pull/75180
>From 46c3616cb29f89fea8bfe020f294cfabe2fdfc38 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Martin=20Storsj=C3=B6?= <martin at martin.st>
Date: Tue, 7 Nov 2023 00:39:02 +0200
Subject: [PATCH] [LLD] [COFF] Add /debug: options nodwarf and nosymtab
These allow tweaking what gets implied by /debug and /debug:dwarf.
---
lld/COFF/Driver.cpp | 4 ++++
lld/test/COFF/debug-dwarf.test | 5 +++++
lld/test/COFF/sort-debug.test | 4 ++++
lld/test/COFF/symtab.test | 2 ++
4 files changed, 15 insertions(+)
diff --git a/lld/COFF/Driver.cpp b/lld/COFF/Driver.cpp
index f9abc8cda1b8d2..4f11affb35ed3e 100644
--- a/lld/COFF/Driver.cpp
+++ b/lld/COFF/Driver.cpp
@@ -1652,9 +1652,13 @@ void LinkerDriver::linkerMain(ArrayRef<const char *> argsArr) {
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/lld/test/COFF/debug-dwarf.test b/lld/test/COFF/debug-dwarf.test
index eacf363b41af4a..c52e7c6067fa78 100644
--- a/lld/test/COFF/debug-dwarf.test
+++ b/lld/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/lld/test/COFF/sort-debug.test b/lld/test/COFF/sort-debug.test
index bbe2ecd0efd8df..30cad394665489 100644
--- a/lld/test/COFF/sort-debug.test
+++ b/lld/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/lld/test/COFF/symtab.test b/lld/test/COFF/symtab.test
index f65754335a97ef..45e8ed39737a46 100644
--- a/lld/test/COFF/symtab.test
+++ b/lld/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 {
More information about the llvm-commits
mailing list