windows: Fix process termination code.

The ctrl-c hack used before didn't actually seem to work.

No haskell libraries expose TerminateProcess. I tried just calling it via
FFI, but got segfaults, probably to do with the wacky process handle not
being managed correctly. Moving it all into one C function worked.

This was hell. The EvilLinker hack was just final icing on the cake.
We all know what the cake was made of.
This commit is contained in:
Joey Hess 2014-02-13 14:00:15 -04:00
parent 84083ecdd3
commit f11f7520b5
10 changed files with 58 additions and 24 deletions

View file

@ -17,6 +17,7 @@ import Control.Applicative ((<$>))
import Control.Monad
import System.Directory
import Data.Maybe
import Data.List
import Utility.Monad
import Utility.Process
@ -94,13 +95,19 @@ parseCollect2 = do
path <- manyTill anyChar (try $ string ldcmd)
void $ char ' '
params <- restOfLine
return $ CmdParams (path ++ ldcmd) (escapeDosPaths params) Nothing
return $ CmdParams (path ++ ldcmd) (skipHack $ escapeDosPaths params) Nothing
where
ldcmd = "ld.exe"
versionline = do
void $ string "collect2 version"
restOfLine
{- For unknown reasons, asking the linker to link this in fails,
- with error about multiple definitions of a symbol from the library.
- This is a horrible hack. -}
skipHack :: String -> String
skipHack = replace "dist/build/git-annex/git-annex-tmp/Utility/winprocess.o" ""
{- Input contains something like
- c:/program files/haskell platform/foo -LC:/Program Files/Haskell Platform/ -L...
- and the *right* spaces must be escaped with \