aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2015-09-01 14:37:02 -0700
committerGravatar Joey Hess <joeyh@joeyh.name>2015-09-01 14:51:14 -0700
commit6d66a81ca98f8579bf06f7fb724ed733670d39b9 (patch)
tree1acad0170e35d49cc6ff732fbf539648de7073e7
parent6e4a1f7a771ca10ede528776ed126ef11f802dfd (diff)
Fix Windows build to work with ghc 7.10
It was failing at link time, some problem with terminatePID. Re-implemented that to not use a C wrapper function, which cleared up the problem. Removed old EvilLinker hack with must have been related to the same problem. Note that I have not tested this with older ghc's. In 4f59f9439687cccfb7aac6aca62dbe97038179bf I mention having tried this approach before, and getting segfaults.. So, who knows. It seems to work fine with ghc 7.10 at least.
-rw-r--r--Build/EvilLinker.hs8
-rw-r--r--Utility/WinProcess.hs17
-rw-r--r--Utility/winprocess.c10
-rw-r--r--debian/changelog6
-rw-r--r--git-annex.cabal1
5 files changed, 22 insertions, 20 deletions
diff --git a/Build/EvilLinker.hs b/Build/EvilLinker.hs
index d1b0cc746..fa260edab 100644
--- a/Build/EvilLinker.hs
+++ b/Build/EvilLinker.hs
@@ -95,19 +95,13 @@ parseCollect2 = do
path <- manyTill anyChar (try $ string ldcmd)
void $ char ' '
params <- restOfLine
- return $ CmdParams (path ++ ldcmd) (skipHack $ escapeDosPaths params) Nothing
+ return $ CmdParams (path ++ ldcmd) (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 \
diff --git a/Utility/WinProcess.hs b/Utility/WinProcess.hs
index 36f079d04..31f6cfc69 100644
--- a/Utility/WinProcess.hs
+++ b/Utility/WinProcess.hs
@@ -11,5 +11,18 @@ module Utility.WinProcess where
import Utility.PID
-foreign import ccall unsafe "terminatepid"
- terminatePID :: PID -> IO ()
+import System.Win32.Process
+import Control.Exception (bracket)
+import Control.Monad
+
+terminatePID :: PID -> IO ()
+terminatePID p = bracket
+ (openProcess pROCESS_TERMINATE False p)
+ (void . c_closeProcess)
+ (\h -> void $ c_TerminateProcess h 1)
+
+foreign import ccall unsafe "windows.h TerminateProcess"
+ c_TerminateProcess :: ProcessHandle -> Int -> IO Int
+
+foreign import ccall unsafe "windows.h CloseHandle"
+ c_closeProcess :: ProcessHandle -> IO Bool
diff --git a/Utility/winprocess.c b/Utility/winprocess.c
deleted file mode 100644
index b6e315573..000000000
--- a/Utility/winprocess.c
+++ /dev/null
@@ -1,10 +0,0 @@
-#include <windows.h>
-
-void terminatepid (DWORD pid) {
- HANDLE h;
- h = OpenProcess(PROCESS_TERMINATE, 0, pid);
- if (h != NULL) {
- TerminateProcess(h, 1);
- }
- CloseHandle(h);
-}
diff --git a/debian/changelog b/debian/changelog
index 9d66a81e2..165426c41 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,9 @@
+git-annex (5.20150825) UNRELEASED; urgency=medium
+
+ * Fix Windows build to work with ghc 7.10.
+
+ -- Joey Hess <id@joeyh.name> Tue, 01 Sep 2015 14:46:18 -0700
+
git-annex (5.20150824) unstable; urgency=medium
* Sped up downloads of files from ssh remotes, reducing the
diff --git a/git-annex.cabal b/git-annex.cabal
index 306e9bc6b..7800a8b5a 100644
--- a/git-annex.cabal
+++ b/git-annex.cabal
@@ -158,7 +158,6 @@ Executable git-annex
if (os(windows))
Build-Depends: Win32, Win32-extras, unix-compat (>= 0.4.1.3), setenv
- C-Sources: Utility/winprocess.c
else
Build-Depends: unix
-- Need to list these because they're generated from .hsc files.