EvilLinker, stage 1
This commit is contained in:
parent
a42285b87c
commit
01799cafc3
2 changed files with 68 additions and 5 deletions
60
Build/EvilLinker.hs
Normal file
60
Build/EvilLinker.hs
Normal file
|
@ -0,0 +1,60 @@
|
||||||
|
{- Allows linking haskell programs too big for all the files to fit in a
|
||||||
|
- command line.
|
||||||
|
-
|
||||||
|
-
|
||||||
|
- Copyright 2013 Joey Hess <joey@kitenet.net>
|
||||||
|
-
|
||||||
|
- Licensed under the GNU GPL version 3 or higher.
|
||||||
|
-}
|
||||||
|
|
||||||
|
module Main where
|
||||||
|
|
||||||
|
import Data.Maybe
|
||||||
|
import Data.Either
|
||||||
|
import Data.List
|
||||||
|
import Text.Parsec
|
||||||
|
import Text.Parsec.String
|
||||||
|
import Control.Applicative ((<$>))
|
||||||
|
import Control.Monad
|
||||||
|
|
||||||
|
import Utility.Monad
|
||||||
|
import Utility.Process
|
||||||
|
|
||||||
|
data CmdParams = CmdParams String String
|
||||||
|
deriving (Show)
|
||||||
|
|
||||||
|
parseGhcLink :: Parser CmdParams
|
||||||
|
parseGhcLink = do
|
||||||
|
many prelinklines
|
||||||
|
linkheaderline
|
||||||
|
char '"'
|
||||||
|
gcccmd <- many1 (noneOf "\"")
|
||||||
|
string "\" "
|
||||||
|
gccparams <- restOfLine
|
||||||
|
return $ CmdParams gcccmd gccparams
|
||||||
|
where
|
||||||
|
linkheaderline = do
|
||||||
|
string "*** Linker"
|
||||||
|
restOfLine
|
||||||
|
prelinklines = do
|
||||||
|
notFollowedBy linkheaderline
|
||||||
|
restOfLine
|
||||||
|
|
||||||
|
restOfLine :: Parser String
|
||||||
|
restOfLine = newline `after` many (noneOf "\n")
|
||||||
|
|
||||||
|
getOutput :: String -> [String] -> IO String
|
||||||
|
getOutput cmd params = do
|
||||||
|
putStrLn $ unwords [cmd, show params]
|
||||||
|
(log, ok) <- processTranscript cmd params Nothing
|
||||||
|
unless ok $
|
||||||
|
error $ cmd ++ " failed:\n\n" ++ log
|
||||||
|
return log
|
||||||
|
|
||||||
|
runParser' :: Parser a -> String -> a
|
||||||
|
runParser' p s = either (error . show) id (parse p "" s)
|
||||||
|
|
||||||
|
main = do
|
||||||
|
ghcout <- getOutput "cabal"
|
||||||
|
["build", "--ghc-options=-v -keep-tmp-files"]
|
||||||
|
print $ runParser' parseGhcLink ghcout
|
|
@ -28,8 +28,11 @@ withcyg cabal build || true
|
||||||
|
|
||||||
# Works around link failure https://ghc.haskell.org/trac/ghc/ticket/8596
|
# Works around link failure https://ghc.haskell.org/trac/ghc/ticket/8596
|
||||||
# using a response file.
|
# using a response file.
|
||||||
withcyg rm -f build.log gcc.opt
|
ghc --make Build/EvilLinker
|
||||||
withcyg cabal build --ghc-options='-v -keep-tmp-files' > build.log 2>&1 || true
|
Build/EvilLinker
|
||||||
withcyg grep 'dist\\build\\git-annex\\git-annex.exe' build.log | withcyg grep -v Linking | withcyg sed -e 's/^"[^"]*" //' -e 's/\\/\//g' > gcc.opt
|
|
||||||
PATH="$HP/mingw/bin:$PATH"
|
#withcyg rm -f build.log gcc.opt
|
||||||
gcc @gcc.opt
|
#withcyg cabal build --ghc-options='-v -keep-tmp-files' > build.log 2>&1 || true
|
||||||
|
#withcyg grep 'dist\\build\\git-annex\\git-annex.exe' build.log | withcyg grep -v Linking | withcyg sed -e 's/^"[^"]*" //' -e 's/\\/\//g' > gcc.opt
|
||||||
|
#PATH="$HP/mingw/bin:$PATH"
|
||||||
|
#gcc @gcc.opt
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue