From 3206cccbdb97d4b22e92915508dc12c11b3d4c60 Mon Sep 17 00:00:00 2001 From: simonmar Date: Mon, 10 Nov 2003 11:23:54 +0000 Subject: [PATCH] [project @ 2003-11-10 11:23:54 by simonmar] Make 'ghc --show-iface' give a reasonable error message on old interface files again. We previously disabled the version check for --show-iface so that you could run --show-iface on a profiled interface file, but this disabled too much error checking. Really we just want to disable the 'way' check, not the whole version check. HEADS UP: interface format changed. Recompile libraries. --- ghc/compiler/iface/BinIface.hs | 23 ++++++++++++++++------- ghc/compiler/iface/MkIface.lhs | 4 ++-- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/ghc/compiler/iface/BinIface.hs b/ghc/compiler/iface/BinIface.hs index 255b86a..256033b 100644 --- a/ghc/compiler/iface/BinIface.hs +++ b/ghc/compiler/iface/BinIface.hs @@ -5,7 +5,7 @@ -- -- Binary interface file support. -module BinIface ( writeBinIface, readBinIface, v_IgnoreHiVersion ) where +module BinIface ( writeBinIface, readBinIface, v_IgnoreHiWay ) where #include "HsVersions.h" @@ -112,8 +112,9 @@ instance Binary ModIface where mi_insts = insts, mi_rules = rules, mi_rule_vers = rule_vers }) = do + put_ bh (show opt_HiVersion) build_tag <- readIORef v_Build_tag - put_ bh (show opt_HiVersion ++ build_tag) + put bh build_tag put_ bh pkg_name put_ bh (moduleName mod) put_ bh mod_vers @@ -131,16 +132,24 @@ instance Binary ModIface where get bh = do check_ver <- get bh - ignore_ver <- readIORef v_IgnoreHiVersion - build_tag <- readIORef v_Build_tag - let our_ver = show opt_HiVersion ++ build_tag - when (check_ver /= our_ver && not ignore_ver) $ + let our_ver = show opt_HiVersion + when (check_ver /= our_ver) $ -- use userError because this will be caught by readIface -- which will emit an error msg containing the iface module name. throwDyn (ProgramError ( "mismatched interface file versions: expected " ++ our_ver ++ ", found " ++ check_ver)) + check_way <- get bh + ignore_way <- readIORef v_IgnoreHiWay + build_tag <- readIORef v_Build_tag + when (not ignore_way && check_way /= build_tag) $ + -- use userError because this will be caught by readIface + -- which will emit an error msg containing the iface module name. + throwDyn (ProgramError ( + "mismatched interface file ways: expected " + ++ build_tag ++ ", found " ++ check_way)) + pkg_name <- get bh mod_name <- get bh @@ -181,7 +190,7 @@ instance Binary ModIface where mi_fix_fn = mkIfaceFixCache fixities, mi_ver_fn = mkIfaceVerCache decls }) -GLOBAL_VAR(v_IgnoreHiVersion, False, Bool) +GLOBAL_VAR(v_IgnoreHiWay, False, Bool) ------------------------------------------------------------------------- -- Types from: HscTypes diff --git a/ghc/compiler/iface/MkIface.lhs b/ghc/compiler/iface/MkIface.lhs index 7b405d9..e43b6df 100644 --- a/ghc/compiler/iface/MkIface.lhs +++ b/ghc/compiler/iface/MkIface.lhs @@ -218,7 +218,7 @@ import Outputable import DriverUtil ( createDirectoryHierarchy, directoryOf ) import Util ( sortLt, seqList ) import Binary ( getBinFileWithDict ) -import BinIface ( writeBinIface, v_IgnoreHiVersion ) +import BinIface ( writeBinIface, v_IgnoreHiWay ) import Unique ( Unique, Uniquable(..) ) import ErrUtils ( dumpIfSet_dyn, showPass ) import Digraph ( stronglyConnComp, SCC(..) ) @@ -936,7 +936,7 @@ showIface :: FilePath -> IO () showIface filename = do -- skip the version check; we don't want to worry about profiled vs. -- non-profiled interfaces, for example. - writeIORef v_IgnoreHiVersion True + writeIORef v_IgnoreHiWay True iface <- Binary.getBinFileWithDict filename printDump (pprModIface iface) where -- 1.7.10.4