[llvm-commits] [llvm] r132132 - /llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp

Rafael Espindola rafael.espindola at gmail.com
Thu May 26 11:59:54 PDT 2011


Author: rafael
Date: Thu May 26 13:59:54 2011
New Revision: 132132

URL: http://llvm.org/viewvc/llvm-project?rev=132132&view=rev
Log:
Fix LTO builds with xcode 4.

Modified:
    llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp

Modified: llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp?rev=132132&r1=132131&r2=132132&view=diff
==============================================================================
--- llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp (original)
+++ llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp Thu May 26 13:59:54 2011
@@ -1588,8 +1588,18 @@
   while (!Stream.AtEndOfStream()) {
     unsigned Code = Stream.ReadCode();
 
-    if (Code != bitc::ENTER_SUBBLOCK)
+    if (Code != bitc::ENTER_SUBBLOCK) {
+
+      // The ranlib in xcode 4 will align archive members by appending newlines to the
+      // end of them. If this file size is a multiple of 4 but not 8, we have to read and
+      // ignore these final 4 bytes :-(
+      if (Stream.GetAbbrevIDWidth() == 2 && Code == 2 &&
+          Stream.Read(6) == 2 && Stream.Read(24) == 0xa0a0a &&
+	  Stream.AtEndOfStream())
+        return false;
+
       return Error("Invalid record at top-level");
+    }
 
     unsigned BlockID = Stream.ReadSubBlockID();
 





More information about the llvm-commits mailing list