Commit 3df1c510 authored by Christian.Maeder@dfki.de's avatar Christian.Maeder@dfki.de Committed by Austin Seipp

Extract derived constants from nm output for various OSes differently.

Fixes #8783.

In order to avoid querying the nm version that does not work on Mac OS X
we use the "nm -P" output that is supposed to produce (more portable)
POSIX output and works on all tested OSes (MinGW, Mac OS X, Solaris and
Linux using GNU nm) although slightly different (as documented). The "nm
-P" output is actually only needed to recognize the output of a non-GNU
Solaris nm (all other OSes produce sane outut using "nm" only).
Signed-off-by: default avatarAustin Seipp <austin@well-typed.com>
parent 39aa1e95
...@@ -641,7 +641,7 @@ getWanted verbose tmpdir gccProgram gccFlags nmProgram ...@@ -641,7 +641,7 @@ getWanted verbose tmpdir gccProgram gccFlags nmProgram
oFile = tmpdir </> "tmp.o" oFile = tmpdir </> "tmp.o"
writeFile cFile cStuff writeFile cFile cStuff
execute verbose gccProgram (gccFlags ++ ["-c", cFile, "-o", oFile]) execute verbose gccProgram (gccFlags ++ ["-c", cFile, "-o", oFile])
xs <- readProcess nmProgram [oFile] "" xs <- readProcess nmProgram ["-P", oFile] ""
let ls = lines xs let ls = lines xs
ms = map parseNmLine ls ms = map parseNmLine ls
m = Map.fromList $ catMaybes ms m = Map.fromList $ catMaybes ms
...@@ -710,28 +710,21 @@ getWanted verbose tmpdir gccProgram gccFlags nmProgram ...@@ -710,28 +710,21 @@ getWanted verbose tmpdir gccProgram gccFlags nmProgram
doWanted (ClosurePayloadMacro {}) = [] doWanted (ClosurePayloadMacro {}) = []
doWanted (FieldTypeGcptrMacro {}) = [] doWanted (FieldTypeGcptrMacro {}) = []
-- parseNmLine parses nm output that looks like -- parseNmLine parses "nm -P" output that looks like
-- "0000000b C derivedConstantMAX_Vanilla_REG" -- "derivedConstantMAX_Vanilla_REG C 0000000b 0000000b" (GNU nm)
-- "_derivedConstantMAX_Vanilla_REG C b 0" (Mac OS X)
-- "_derivedConstantMAX_Vanilla_REG C 000000b" (MinGW)
-- "derivedConstantMAX_Vanilla_REG D 1 b" (Solaris)
-- and returns ("MAX_Vanilla_REG", 11) -- and returns ("MAX_Vanilla_REG", 11)
parseNmLine xs0 = case break (' ' ==) xs0 of parseNmLine line
(x1, ' ' : xs1) -> = case words line of
case break (' ' ==) xs1 of ('_' : n) : "C" : s : _ -> mkP n s
(x2, ' ' : x3) -> n : "C" : s : _ -> mkP n s
case readHex x1 of [n, "D", _, s] -> mkP n s
[(size, "")] -> _ -> Nothing
case x2 of where mkP r s = case (stripPrefix prefix r, readHex s) of
"C" -> (Just name, [(size, "")]) -> Just (name, size)
let x3' = case x3 of _ -> Nothing
'_' : rest -> rest
_ -> x3
in case stripPrefix prefix x3' of
Just name ->
Just (name, size)
_ -> Nothing
_ -> Nothing
_ -> Nothing
_ -> Nothing
_ -> Nothing
-- If an Int value is larger than 2^28 or smaller -- If an Int value is larger than 2^28 or smaller
-- than -2^28, then fail. -- than -2^28, then fail.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment