[PATCH] D112594: [lld-macho] Implement -S
Vincent Lee via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 26 21:46:33 PDT 2021
thevinster created this revision.
Herald added a subscriber: dang.
Herald added a reviewer: gkm.
Herald added a project: lld-macho.
Herald added a reviewer: lld-macho.
thevinster edited the summary of this revision.
thevinster published this revision for review.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
There are a couple internal builds that require the use of this flag.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D112594
Files:
lld/MachO/Config.h
lld/MachO/Driver.cpp
lld/MachO/InputFiles.cpp
lld/MachO/Options.td
lld/MachO/SyntheticSections.cpp
lld/test/MachO/stabs.s
Index: lld/test/MachO/stabs.s
===================================================================
--- lld/test/MachO/stabs.s
+++ lld/test/MachO/stabs.s
@@ -53,13 +53,18 @@
## Check that we emit relative path to object files in OSO entries
## when -oso_prefix <path> is used.
# RUN: cd %t && %lld -lSystem test.o foo.o no-debug.o -oso_prefix "%t" -o %t/test-rel
-# RUN: dsymutil -s %t/test-rel | grep 'N_OSO' | FileCheck %s -D#TEST_TIME=0x10 -D#FOO_TIME=0x20 --check-prefix=REL-PATH
+# RUN: dsymutil -s %t/test-rel | grep 'N_OSO' | FileCheck %s -D#TEST_TIME=0x10 -D#FOO_TIME=0x20 --check-prefix=REL-PATH
# RUN: cd %t && %lld -lSystem test.o foo.o no-debug.o -oso_prefix "." -o %t/test-rel-dot
-# RUN: dsymutil -s %t/test-rel-dot | grep 'N_OSO' | FileCheck %s -D#TEST_TIME=0x10 -D#FOO_TIME=0x20 --check-prefix=REL-DOT
+# RUN: dsymutil -s %t/test-rel-dot | grep 'N_OSO' | FileCheck %s -D#TEST_TIME=0x10 -D#FOO_TIME=0x20 --check-prefix=REL-DOT
## Set HOME to %t (for ~ to expand to)
# RUN: cd %t && env HOME=%t %lld -lSystem test.o foo.o no-debug.o -oso_prefix "~" -o %t/test-rel-tilde
# RUN: dsymutil -s %t/test-rel-tilde | grep 'N_OSO' | FileCheck %s -D#TEST_TIME=0x10 -D#FOO_TIME=0x20 --check-prefix=REL-PATH
+## Check that we don't emit DWARF or stabs when -S is used
+# RUN: cd %t && %lld -lSystem test.o foo.o no-debug.o -S -o %t/test-no-debug
+## grep returns an exit code of 1 if it cannot match the intended pattern. We
+## expect to not find any entries which requires the exit code to be negated.
+# RUN: llvm-nm -ap %t/test-no-debug | not grep -e ' - '
# RUN: cd %t && %lld -lSystem test.o foo.a no-debug.o -o %t/test
# RUN: (llvm-objdump --section-headers %t/test; dsymutil -s %t/test) | \
@@ -77,7 +82,7 @@
# CHECK: (N_SO ) 00 0000 0000000000000000 '/tmp/test.cpp'
# CHECK-NEXT: (N_OSO ) 03 0001 [[#%.16x,TEST_TIME]] '[[DIR]]/test.o'
# REL-PATH: (N_OSO ) 03 0001 [[#%.16x,TEST_TIME]] '/test.o'
-# REL-DOT: (N_OSO ) 03 0001 [[#%.16x,TEST_TIME]] 'test.o'
+# REL-DOT: (N_OSO ) 03 0001 [[#%.16x,TEST_TIME]] 'test.o'
# CHECK-NEXT: (N_STSYM ) [[#%.2d,MORE_DATA_ID + 1]] 0000 [[#%.16x,STATIC:]] '_static_var'
# CHECK-NEXT: (N_FUN ) [[#%.2d,TEXT_ID + 1]] 0000 [[#%.16x,MAIN:]] '_main'
# CHECK-NEXT: (N_FUN ) 00 0000 0000000000000006{{$}}
Index: lld/MachO/SyntheticSections.cpp
===================================================================
--- lld/MachO/SyntheticSections.cpp
+++ lld/MachO/SyntheticSections.cpp
@@ -876,6 +876,9 @@
}
void SymtabSection::emitStabs() {
+ if (config->omitDebugInfo)
+ return;
+
for (const std::string &s : config->astPaths) {
StabsEntry astStab(N_AST);
astStab.strx = stringTableSection.addString(s);
Index: lld/MachO/Options.td
===================================================================
--- lld/MachO/Options.td
+++ lld/MachO/Options.td
@@ -557,7 +557,6 @@
def S : Flag<["-"], "S">,
HelpText<"Strip debug information (STABS or DWARF) from the output">,
- Flags<[HelpHidden]>,
Group<grp_symtab>;
def x : Flag<["-"], "x">,
HelpText<"Exclude non-global symbols from the output symbol table">,
Index: lld/MachO/InputFiles.cpp
===================================================================
--- lld/MachO/InputFiles.cpp
+++ lld/MachO/InputFiles.cpp
@@ -836,6 +836,9 @@
}
void ObjFile::parseDebugInfo() {
+ if (config->omitDebugInfo)
+ return;
+
std::unique_ptr<DwarfObject> dObj = DwarfObject::create(this);
if (!dObj)
return;
Index: lld/MachO/Driver.cpp
===================================================================
--- lld/MachO/Driver.cpp
+++ lld/MachO/Driver.cpp
@@ -1170,6 +1170,7 @@
args.hasArg(OPT_print_dylib_search) || getenv("RC_TRACE_DYLIB_SEARCHING");
config->printEachFile = args.hasArg(OPT_t);
config->printWhyLoad = args.hasArg(OPT_why_load);
+ config->omitDebugInfo = args.hasArg(OPT_S);
config->outputType = getOutputType(args);
if (const Arg *arg = args.getLastArg(OPT_bundle_loader)) {
if (config->outputType != MH_BUNDLE)
Index: lld/MachO/Config.h
===================================================================
--- lld/MachO/Config.h
+++ lld/MachO/Config.h
@@ -121,6 +121,7 @@
bool timeTraceEnabled = false;
bool dataConst = false;
bool dedupLiterals = true;
+ bool omitDebugInfo = false;
uint32_t headerPad;
uint32_t dylibCompatibilityVersion = 0;
uint32_t dylibCurrentVersion = 0;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D112594.382524.patch
Type: text/x-patch
Size: 4643 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211027/b4889bf4/attachment-0001.bin>
More information about the llvm-commits
mailing list