diff --git a/lld/MachO/Config.h b/lld/MachO/Config.h --- a/lld/MachO/Config.h +++ b/lld/MachO/Config.h @@ -227,6 +227,7 @@ llvm::SmallVector mllvmOpts; bool zeroModTime = true; + bool disableUuid = false; llvm::StringRef osoPrefix; diff --git a/lld/MachO/Driver.cpp b/lld/MachO/Driver.cpp --- a/lld/MachO/Driver.cpp +++ b/lld/MachO/Driver.cpp @@ -1640,6 +1640,7 @@ config->ltoDebugPassManager = args.hasArg(OPT_lto_debug_pass_manager); config->csProfileGenerate = args.hasArg(OPT_cs_profile_generate); config->csProfilePath = args.getLastArgValue(OPT_cs_profile_path); + config->disableUuid = args.hasArg(OPT_no_uuid); for (const Arg *arg : args.filtered(OPT_alias)) { config->aliasedSymbols.push_back( diff --git a/lld/MachO/Options.td b/lld/MachO/Options.td --- a/lld/MachO/Options.td +++ b/lld/MachO/Options.td @@ -791,7 +791,6 @@ Group; def no_uuid : Flag<["-"], "no_uuid">, HelpText<"Do not generate the LC_UUID load command">, - Flags<[HelpHidden]>, Group; def root_safe : Flag<["-"], "root_safe">, HelpText<"Set the MH_ROOT_SAFE bit in the mach-o header">, diff --git a/lld/MachO/Writer.cpp b/lld/MachO/Writer.cpp --- a/lld/MachO/Writer.cpp +++ b/lld/MachO/Writer.cpp @@ -813,8 +813,10 @@ llvm_unreachable("unhandled output file type"); } - uuidCommand = make(); - in.header->addLoadCommand(uuidCommand); + if (!config->disableUuid) { + uuidCommand = make(); + in.header->addLoadCommand(uuidCommand); + } if (useLCBuildVersion(config->platformInfo)) in.header->addLoadCommand(make(config->platformInfo)); @@ -1264,7 +1266,8 @@ writeSections(); applyOptimizationHints(); buildFixupChains(); - writeUuid(); + if (!config->disableUuid) + writeUuid(); writeCodeSignature(); if (auto e = buffer->commit()) diff --git a/lld/test/MachO/uuid.s b/lld/test/MachO/uuid.s --- a/lld/test/MachO/uuid.s +++ b/lld/test/MachO/uuid.s @@ -16,6 +16,9 @@ # RUN: llvm-dwarfdump --uuid %t/c | awk '{print $2}' > %t/uuidc # RUN: cmp %t/uuida %t/uuidc +## Test disabling UUID generation +# RUN: %lld -lSystem %t/test.o -o %t/d -no_uuid +# RUN: llvm-dwarfdump --uuid %t/d | count 0 # CHECK: 4C4C44{{([[:xdigit:]]{2})}}-5555-{{([[:xdigit:]]{4})}}-A1{{([[:xdigit:]]{2})}}-{{([[:xdigit:]]{12})}}