[commit: ghc] wip/D1500: derivedConstants: Add support for AIX (44d9e63)
git at git.haskell.org
git at git.haskell.org
Thu Nov 19 09:50:40 UTC 2015
Repository : ssh://git@git.haskell.org/ghc
On branch : wip/D1500
Link : http://ghc.haskell.org/trac/ghc/changeset/44d9e639107b5353957cb0eb2075f5b4d3246111/ghc
>---------------------------------------------------------------
commit 44d9e639107b5353957cb0eb2075f5b4d3246111
Author: Herbert Valerio Riedel <hvr at gnu.org>
Date: Thu Nov 19 10:50:20 2015 +0100
derivedConstants: Add support for AIX
Summary:
On IBM AIX `nm` doesn't support reporting symbol sizes, so we need to
resort to `objdump` instead, which has a peculiar output format on AIX.
depends on D1499
Reviewers: bgamari, austin
Subscribers: kgardas, thomie
Differential Revision: https://phabricator.haskell.org/D1500
>---------------------------------------------------------------
44d9e639107b5353957cb0eb2075f5b4d3246111
utils/deriveConstants/Main.hs | 28 ++++++++++++++++++++++++++--
1 file changed, 26 insertions(+), 2 deletions(-)
diff --git a/utils/deriveConstants/Main.hs b/utils/deriveConstants/Main.hs
index 832d4bc..09c94ab 100644
--- a/utils/deriveConstants/Main.hs
+++ b/utils/deriveConstants/Main.hs
@@ -675,11 +675,13 @@ getWanted verbose os tmpdir gccProgram gccFlags nmProgram mobjdumpProgram
execute verbose gccProgram (gccFlags ++ ["-c", cFile, "-o", oFile])
xs <- case os of
"openbsd" -> readProcess objdumpProgam ["--syms", oFile] ""
+ "aix" -> readProcess objdumpProgam ["--syms", oFile] ""
_ -> readProcess nmProgram ["-P", oFile] ""
let ls = lines xs
- ms = map parseNmLine ls
- m = Map.fromList $ catMaybes ms
+ m = Map.fromList $ case os of
+ "aix" -> parseAixObjdump ls
+ _ -> catMaybes $ map parseNmLine ls
rs <- mapM (lookupResult m) (wanteds os)
return rs
where headers = ["#define IN_STG_CODE 0",
@@ -764,6 +766,28 @@ getWanted verbose os tmpdir gccProgram gccFlags nmProgram mobjdumpProgram
(Just name, [(size, "")]) -> Just (name, size)
_ -> Nothing
+ -- On AIX, `nm` isn't able to tell us the symbol size, so we
+ -- need to use `objdump --syms`. However, unlike on OpenBSD,
+ -- `objdump --syms` outputs entries spanning two lines, e.g.
+ --
+ -- [ 50](sec 3)(fl 0x00)(ty 0)(scl 2) (nx 1) 0x00000318 derivedConstantBLOCK_SIZE
+ -- AUX val 4097 prmhsh 0 snhsh 0 typ 3 algn 3 clss 5 stb 0 snstb 0
+ --
+ parseAixObjdump :: [String] -> [(String,Integer)]
+ parseAixObjdump = catMaybes . goAix
+ where
+ goAix (l1@('[':_):l2@('A':'U':'X':_):ls')
+ = parseObjDumpEntry l1 l2 : goAix ls'
+ goAix (_:ls') = goAix ls'
+ goAix [] = []
+
+ parseObjDumpEntry l1 l2
+ | ["val",n] <- take 2 (tail $ words l2)
+ , Just sym <- stripPrefix prefix sym0 = Just (sym, read n)
+ | otherwise = Nothing
+ where
+ [sym0, adr] = take 2 (reverse $ words l1)
+
-- If an Int value is larger than 2^28 or smaller
-- than -2^28, then fail.
-- This test is a bit conservative, but if any
More information about the ghc-commits
mailing list