Skip to content

Commit f317ce2

Browse files
committed
[lld-macho] Implement -no_uuid
Since UUID generation in lld is fast this is rarely used but it can be helpful to avoid temporary issues like llvm#63961 Differential Revision: https://reviews.llvm.org/D155735
1 parent b9a599c commit f317ce2

File tree

5 files changed

+11
-4
lines changed

5 files changed

+11
-4
lines changed

lld/MachO/Config.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,7 @@ struct Configuration {
227227
llvm::SmallVector<llvm::StringRef, 0> mllvmOpts;
228228

229229
bool zeroModTime = true;
230+
bool generateUuid = true;
230231

231232
llvm::StringRef osoPrefix;
232233

lld/MachO/Driver.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1640,6 +1640,7 @@ bool link(ArrayRef<const char *> argsArr, llvm::raw_ostream &stdoutOS,
16401640
config->ltoDebugPassManager = args.hasArg(OPT_lto_debug_pass_manager);
16411641
config->csProfileGenerate = args.hasArg(OPT_cs_profile_generate);
16421642
config->csProfilePath = args.getLastArgValue(OPT_cs_profile_path);
1643+
config->generateUuid = !args.hasArg(OPT_no_uuid);
16431644

16441645
for (const Arg *arg : args.filtered(OPT_alias)) {
16451646
config->aliasedSymbols.push_back(

lld/MachO/Options.td

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -791,7 +791,6 @@ def allow_sub_type_mismatches : Flag<["-"], "allow_sub_type_mismatches">,
791791
Group<grp_rare>;
792792
def no_uuid : Flag<["-"], "no_uuid">,
793793
HelpText<"Do not generate the LC_UUID load command">,
794-
Flags<[HelpHidden]>,
795794
Group<grp_rare>;
796795
def root_safe : Flag<["-"], "root_safe">,
797796
HelpText<"Set the MH_ROOT_SAFE bit in the mach-o header">,

lld/MachO/Writer.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -813,8 +813,10 @@ template <class LP> void Writer::createLoadCommands() {
813813
llvm_unreachable("unhandled output file type");
814814
}
815815

816-
uuidCommand = make<LCUuid>();
817-
in.header->addLoadCommand(uuidCommand);
816+
if (config->generateUuid) {
817+
uuidCommand = make<LCUuid>();
818+
in.header->addLoadCommand(uuidCommand);
819+
}
818820

819821
if (useLCBuildVersion(config->platformInfo))
820822
in.header->addLoadCommand(make<LCBuildVersion>(config->platformInfo));
@@ -1264,7 +1266,8 @@ void Writer::writeOutputFile() {
12641266
writeSections();
12651267
applyOptimizationHints();
12661268
buildFixupChains();
1267-
writeUuid();
1269+
if (config->generateUuid)
1270+
writeUuid();
12681271
writeCodeSignature();
12691272

12701273
if (auto e = buffer->commit())

lld/test/MachO/uuid.s

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616
# RUN: llvm-dwarfdump --uuid %t/c | awk '{print $2}' > %t/uuidc
1717
# RUN: cmp %t/uuida %t/uuidc
1818

19+
## Test disabling UUID generation
20+
# RUN: %lld -lSystem %t/test.o -o %t/d -no_uuid
21+
# RUN: llvm-dwarfdump --uuid %t/d | count 0
1922

2023
# CHECK: 4C4C44{{([[:xdigit:]]{2})}}-5555-{{([[:xdigit:]]{4})}}-A1{{([[:xdigit:]]{2})}}-{{([[:xdigit:]]{12})}}
2124

0 commit comments

Comments
 (0)