Skip to content

Commit f7261e9

Browse files
authored
[dsymutil] Emit a warning instead of an error when using fat64 header (#118898)
Universal Mach-O files can't have an archicture slice that starts beyond the 4GB boundary. However, we support generating universal binaries with a fat64 header, but older tools may not understand this format. Currently, unless -fat64 is passed, dsymutil will error out when it encounters a slice that would exceeds the 4GB limit. Now that more tools (like LLDB and CoreSymbolication) understand the fat64 header format, this patch changes the default behavior to use the fat64 header and emits a warning instead. The warning can be silenced by passing the -fat64 flag. The goal is to eventually remove the warning altogether. rdar://140998416
1 parent c7caab2 commit f7261e9

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

llvm/tools/dsymutil/dsymutil.cpp

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -832,15 +832,15 @@ int dsymutil_main(int argc, char **argv, const llvm::ToolContext &) {
832832
return EXIT_FAILURE;
833833

834834
if (NeedsTempFiles) {
835-
const bool Fat64 = Options.LinkOpts.Fat64;
835+
bool Fat64 = Options.LinkOpts.Fat64;
836836
if (!Fat64) {
837837
// Universal Mach-O files can't have an archicture slice that starts
838838
// beyond the 4GB boundary. "lipo" can create a 64 bit universal
839-
// header, but not all tools can parse these files so we want to return
840-
// an error if the file can't be encoded as a file with a 32 bit
839+
// header, but older tools may not support these files so we want to
840+
// emit a warning if the file can't be encoded as a file with a 32 bit
841841
// universal header. To detect this, we check the size of each
842842
// architecture's skinny Mach-O file and add up the offsets. If they
843-
// exceed 4GB, then we return an error.
843+
// exceed 4GB, we emit a warning.
844844

845845
// First we compute the right offset where the first architecture will
846846
// fit followin the 32 bit universal header. The 32 bit universal header
@@ -859,13 +859,15 @@ int dsymutil_main(int argc, char **argv, const llvm::ToolContext &) {
859859
if (!stat)
860860
break;
861861
if (FileOffset > UINT32_MAX) {
862-
WithColor::error()
863-
<< formatv("the universal binary has a slice with a starting "
864-
"offset ({0:x}) that exceeds 4GB and will produce "
865-
"an invalid Mach-O file. Use the -fat64 flag to "
866-
"generate a universal binary with a 64-bit header "
867-
"but note that not all tools support this format.",
868-
FileOffset);
862+
Fat64 = true;
863+
WithColor::warning() << formatv(
864+
"the universal binary has a slice with a starting offset "
865+
"({0:x}) that exceeds 4GB. To avoid producing an invalid "
866+
"Mach-O file, a universal binary with a 64-bit header will be "
867+
"generated, which may not be supported by older tools. Use the "
868+
"-fat64 flag to force a 64-bit header and silence this "
869+
"warning.",
870+
FileOffset);
869871
return EXIT_FAILURE;
870872
}
871873
FileOffset += stat->getSize();

0 commit comments

Comments
 (0)