[commit: ghc] ghc-8.0: deriveConstants: Verify sanity of nm (6810de7)

git at git.haskell.org git at git.haskell.org
Sun Apr 17 12:23:26 UTC 2016


Repository : ssh://git@git.haskell.org/ghc

On branch  : ghc-8.0
Link       : http://ghc.haskell.org/trac/ghc/changeset/6810de7c1c1955819b12ba60a033e6af35a07ffb/ghc

>---------------------------------------------------------------

commit 6810de7c1c1955819b12ba60a033e6af35a07ffb
Author: Herbert Valerio Riedel <hvr at gnu.org>
Date:   Sat Apr 16 15:25:07 2016 +0200

    deriveConstants: Verify sanity of nm
    
    Add a sanity check ensuring that nm emits valid hexadecimal output, as
    required by POSIX. See #11744 for motivation.
    
    Reviewers: austin, bgamari
    
    Subscribers: thomie
    
    Differential Revision: https://phabricator.haskell.org/D2113
    
    GHC Trac Issues: #11744
    
    (cherry picked from commit bf17fd0e5b5442a87f507b26e64a30c79732838a)


>---------------------------------------------------------------

6810de7c1c1955819b12ba60a033e6af35a07ffb
 utils/deriveConstants/Main.hs | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/utils/deriveConstants/Main.hs b/utils/deriveConstants/Main.hs
index 6a88ac2..96da166 100644
--- a/utils/deriveConstants/Main.hs
+++ b/utils/deriveConstants/Main.hs
@@ -296,8 +296,12 @@ haskellise "" = ""
 
 wanteds :: String -> Wanteds
 wanteds os = concat
-          [-- Closure header sizes.
-           constantWord Both "STD_HDR_SIZE"
+          [-- Control group constant for integrity check; this
+           -- round-tripped constant is used for testing that
+           -- derivedConstant works as expected
+           constantWord Both "CONTROL_GROUP_CONST_291" "0x123"
+           -- Closure header sizes.
+          ,constantWord Both "STD_HDR_SIZE"
                              -- grrr.. PROFILING is on so we need to
                              -- subtract sizeofW(StgProfHeader)
                              "sizeofW(StgHeader) - sizeofW(StgProfHeader)"
@@ -682,6 +686,14 @@ getWanted verbose os tmpdir gccProgram gccFlags nmProgram mobjdumpProgram
              m = Map.fromList $ case os of
                  "aix" -> parseAixObjdump ls
                  _     -> catMaybes $ map parseNmLine ls
+
+         case Map.lookup "CONTROL_GROUP_CONST_291" m of
+             Just 292   -> return () -- OK
+             Nothing    -> die "CONTROL_GROUP_CONST_291 missing!"
+             Just 0x292 -> die $ "broken 'nm' detected, see https://ghc.haskell.org/ticket/11744.\n"
+                              ++ "Workaround: You may want to pass '--with-nm=nm-classic' to 'configure'."
+             Just x     -> die ("unexpected value round-tripped for CONTROL_GROUP_CONST_291: " ++ show x)
+
          rs <- mapM (lookupResult m) (wanteds os)
          return rs
     where headers = ["#define IN_STG_CODE 0",



More information about the ghc-commits mailing list