Skip to content

Commit f5b45a6

Browse files
committed
[dsymutil] Emit a warning instead of an error when using fat64 header (llvm#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 (cherry picked from commit f7261e9)
1 parent 119bd56 commit f5b45a6

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
@@ -839,15 +839,15 @@ int dsymutil_main(int argc, char **argv, const llvm::ToolContext &) {
839839
return EXIT_FAILURE;
840840

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

852852
// First we compute the right offset where the first architecture will
853853
// fit followin the 32 bit universal header. The 32 bit universal header
@@ -866,13 +866,15 @@ int dsymutil_main(int argc, char **argv, const llvm::ToolContext &) {
866866
if (!stat)
867867
break;
868868
if (FileOffset > UINT32_MAX) {
869-
WithColor::error()
870-
<< formatv("the universal binary has a slice with a starting "
871-
"offset ({0:x}) that exceeds 4GB and will produce "
872-
"an invalid Mach-O file. Use the -fat64 flag to "
873-
"generate a universal binary with a 64-bit header "
874-
"but note that not all tools support this format.",
875-
FileOffset);
869+
Fat64 = true;
870+
WithColor::warning() << formatv(
871+
"the universal binary has a slice with a starting offset "
872+
"({0:x}) that exceeds 4GB. To avoid producing an invalid "
873+
"Mach-O file, a universal binary with a 64-bit header will be "
874+
"generated, which may not be supported by older tools. Use the "
875+
"-fat64 flag to force a 64-bit header and silence this "
876+
"warning.",
877+
FileOffset);
876878
return EXIT_FAILURE;
877879
}
878880
FileOffset += stat->getSize();

0 commit comments

Comments
 (0)