From: Chris Lattner Date: Mon, 27 Sep 2004 16:59:06 +0000 (+0000) Subject: The system ranlib on darwin occasionally adds two extra newlines to the X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=56bc894d06b81fd27065ad73d69b1781d2fe4953;p=oota-llvm.git The system ranlib on darwin occasionally adds two extra newlines to the end of files, breaking the CFE build. As a gross hack around this, ignore any trailing garbage on bytecode files. Thanks to Brian for digging in and identifying the problem. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@16525 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Bytecode/Reader/Reader.cpp b/lib/Bytecode/Reader/Reader.cpp index 18780208e2b..d44003c73a1 100644 --- a/lib/Bytecode/Reader/Reader.cpp +++ b/lib/Bytecode/Reader/Reader.cpp @@ -2139,10 +2139,16 @@ void BytecodeReader::ParseBytecode(BufPtr Buf, unsigned Length, error("Expected Module Block! Type:" + utostr(Type) + ", Size:" + utostr(Size)); } - if (At + Size != MemEnd) { + + // It looks like the darwin ranlib program is broken, and adds trailing + // garbage to the end of some bytecode files. This hack allows the bc + // reader to ignore trailing garbage on bytecode files. + if (At + Size < MemEnd) + MemEnd = BlockEnd = At+Size; + + if (At + Size != MemEnd) error("Invalid Top Level Block Length! Type:" + utostr(Type) + ", Size:" + utostr(Size)); - } // Parse the module contents this->ParseModule();