Skip to content

Commit f51dca2

Browse files
authored
Merge pull request #9699 from swiftlang/cherrypick-swift/release/6.1-f7261e9bbe33
[🍒 swift/release/6.1] [dsymutil] Emit a warning instead of an error when using fat64 header (llvm#118898)
2 parents 119bd56 + f5b45a6 commit f51dca2

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)