diff options
author | Ben Gamari <ben@smart-cactus.org> | 2016-05-23 15:32:12 +0200 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2016-05-23 17:23:49 +0200 |
commit | 9bb277269ec020f138fe70a65f5972466113ab61 (patch) | |
tree | a283447f9931ddd0b462dc23945cbe51127a785e /compiler/utils/Binary.hs | |
parent | 785b38ff4326f3cd9cf2097bf9967e7fd66995cd (diff) | |
download | haskell-9bb277269ec020f138fe70a65f5972466113ab61.tar.gz |
Revert "compiler/iface: compress .hi files"
This appears to cause validation issues on,
TEST="T11108 T9071 T11076 T7600 T7672 T8329 T10420 T10322 T8308 T4114a
T4114c T10602 T10110 T9204 T2435 T9838 T4114d T10233 T8696 T1735 T5281
T6056 T10134 T9580 T6018 T9762 T8103"
With compiler panics of the form,
Compile failed (status 256) errors were:
ghc: panic! (the 'impossible' happened)
(GHC version 8.1.20160523 for x86_64-unknown-linux):
Binary.readBinMem: decompression failed
CallStack (from HasCallStack):
error, called at compiler/utils/Binary.hs:192:16 in ghc:Binary
Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug
This reverts commit d9cb7a8a94daa4d20aa042cd053e20b491315633.
Diffstat (limited to 'compiler/utils/Binary.hs')
-rw-r--r-- | compiler/utils/Binary.hs | 37 |
1 files changed, 19 insertions, 18 deletions
diff --git a/compiler/utils/Binary.hs b/compiler/utils/Binary.hs index 684cdc6bc4..8800d98f9c 100644 --- a/compiler/utils/Binary.hs +++ b/compiler/utils/Binary.hs @@ -66,19 +66,18 @@ import FastMutInt import Fingerprint import BasicTypes import SrcLoc -import qualified LZ4 as LZ4 import Foreign import Data.Array import Data.ByteString (ByteString) -import qualified Data.ByteString as B import qualified Data.ByteString.Internal as BS import qualified Data.ByteString.Unsafe as BS import Data.IORef import Data.Char ( ord, chr ) import Data.Time import Data.Typeable -import Control.Monad ( when, liftM ) +import Control.Monad ( when ) +import System.IO as IO import System.IO.Unsafe ( unsafeInterleaveIO ) import System.IO.Error ( mkIOError, eofErrorType ) import GHC.Real ( Ratio(..) ) @@ -177,27 +176,29 @@ isEOFBin (BinMem _ ix_r sz_r _) = do writeBinMem :: BinHandle -> FilePath -> IO () writeBinMem (BinMem _ ix_r _ arr_r) fn = do + h <- openBinaryFile fn WriteMode arr <- readIORef arr_r ix <- readFastMutInt ix_r - let bs = LZ4.compress $ BS.fromForeignPtr arr 0 ix - case bs of - Nothing -> error "Binary.writeBinMem: compression failed" - Just x -> B.writeFile fn x + withForeignPtr arr $ \p -> hPutBuf h p ix + hClose h readBinMem :: FilePath -> IO BinHandle -- Return a BinHandle with a totally undefined State readBinMem filename = do - bs <- liftM LZ4.decompress (B.readFile filename) - case bs of - Nothing -> error "Binary.readBinMem: decompression failed" - Just x -> do - let (arr, ix, size) = BS.toForeignPtr x - arr_r <- newIORef arr - ix_r <- newFastMutInt - writeFastMutInt ix_r ix - sz_r <- newFastMutInt - writeFastMutInt sz_r size - return (BinMem noUserData ix_r sz_r arr_r) + h <- openBinaryFile filename ReadMode + filesize' <- hFileSize h + let filesize = fromIntegral filesize' + arr <- mallocForeignPtrBytes (filesize*2) + count <- withForeignPtr arr $ \p -> hGetBuf h p filesize + when (count /= filesize) $ + error ("Binary.readBinMem: only read " ++ show count ++ " bytes") + hClose h + arr_r <- newIORef arr + ix_r <- newFastMutInt + writeFastMutInt ix_r 0 + sz_r <- newFastMutInt + writeFastMutInt sz_r filesize + return (BinMem noUserData ix_r sz_r arr_r) fingerprintBinMem :: BinHandle -> IO Fingerprint fingerprintBinMem (BinMem _ ix_r _ arr_r) = do |