summaryrefslogtreecommitdiff
path: root/utils/deriveConstants
diff options
context:
space:
mode:
authorKarel Gardas <karel.gardas@centrum.cz>2014-03-22 22:33:05 +0100
committerAustin Seipp <austin@well-typed.com>2014-03-22 19:39:43 -0500
commit045b28033a33a48d31951240a8cb35f2b78345dc (patch)
treeb1e98d0dc0404118ebf2cb8592c81446fa95690b /utils/deriveConstants
parentace7477690752d85defd71c083863f14db241350 (diff)
downloadhaskell-045b28033a33a48d31951240a8cb35f2b78345dc.tar.gz
change deriveConstants to use nm in a POSIX way (fixes #8781)
The patch provided by Christian Maeder <Christian.Maeder@dfki.de> Signed-off-by: Karel Gardas <karel.gardas@centrum.cz> Signed-off-by: Austin Seipp <austin@well-typed.com>
Diffstat (limited to 'utils/deriveConstants')
-rw-r--r--utils/deriveConstants/DeriveConstants.hs30
1 files changed, 10 insertions, 20 deletions
diff --git a/utils/deriveConstants/DeriveConstants.hs b/utils/deriveConstants/DeriveConstants.hs
index 293fe65492..6344569039 100644
--- a/utils/deriveConstants/DeriveConstants.hs
+++ b/utils/deriveConstants/DeriveConstants.hs
@@ -638,7 +638,7 @@ getWanted verbose tmpdir gccProgram gccFlags nmProgram
oFile = tmpdir </> "tmp.o"
writeFile cFile cStuff
execute verbose gccProgram (gccFlags ++ ["-c", cFile, "-o", oFile])
- xs <- readProcess nmProgram [oFile] ""
+ xs <- readProcess nmProgram ["-P", oFile] ""
let ls = lines xs
ms = map parseNmLine ls
m = Map.fromList $ catMaybes ms
@@ -707,27 +707,17 @@ getWanted verbose tmpdir gccProgram gccFlags nmProgram
doWanted (ClosurePayloadMacro {}) = []
doWanted (FieldTypeGcptrMacro {}) = []
- -- parseNmLine parses nm output that looks like
- -- "0000000b C derivedConstantMAX_Vanilla_REG"
+ -- parseNmLine parses "nm -P" output that looks like
+ -- "_derivedConstantMAX_Vanilla_REG C b 0" Mac OS X
+ -- "derivedConstantMAX_Vanilla_REG C 0000000b 0000000b" GNU
+ -- "derivedConstantMAX_Vanilla_REG D 1 b" Solaris
-- and returns ("MAX_Vanilla_REG", 11)
- parseNmLine xs0 = case break (' ' ==) xs0 of
- (x1, ' ' : xs1) ->
- case break (' ' ==) xs1 of
- (x2, ' ' : x3) ->
- case readHex x1 of
- [(size, "")] ->
- case x2 of
- "C" ->
- let x3' = case x3 of
- '_' : rest -> rest
- _ -> x3
- in case stripPrefix prefix x3' of
- Just name ->
- Just (name, size)
- _ -> Nothing
- _ -> Nothing
- _ -> Nothing
+ parseNmLine xs0 = case words xs0 of
+ [x0, x1, x2, x3] -> case stripPrefix prefix $ dropWhile (== '_') x0 of
+ Just name -> case readHex $ if x1 == "C" then x2 else x3 of
+ [(size, "")] -> Just (name, size)
_ -> Nothing
+ _ -> Nothing
_ -> Nothing
-- If an Int value is larger than 2^28 or smaller