very hard to build darcs with win32 ghc-6.8.2!

I built darcs for win32 recently and it was much more difficult than it should be. Probably most of the blame goes to ghc-6.8.2 binary release for win32. Half of the effort is getting the zlib prereq working. Previously to build zlib for win32 ghc I did the following: http://www.haskell.org/pipermail/haskell-cafe/2007-March/023059.html However, now, the gcc binary for ghc-6.8.2 does not work as well as I would like which requires a bit more effort: - It did not automatically add mingw headers during compilation, and to fix this I had to force some extra flags. I built a shell script "xcc": #!/bin/sh GHC=/ghc/ghc-6.8.2 PATH=/c$GHC/gcc-lib:$PATH export PATH /c$GHC/gcc -I $GHC/include -I $GHC/include/mingw \ -I $GHC/gcc-lib/include -L $GHC/gcc-lib "$@" - During linking it did not find crt2.o and adding it to PATH and -L did not help, so I just copied wholesale all of /c/ghc/ghc-6.8.2/gcc-lib into my zlib source directory. - At this point I was able to build with: CC=./xcc ./configure --prefix=/c/ghc/ghc-6.8.2 \ --libdir=/c/ghc/ghc-6.8.2 make make install Why is the gcc in ghc's directory so non-functional? Ok, so with zlib (the C library) installed, the zlib haskell package installs properly. Dependency resolved. Next, to build darcs I had to configure it without libcurl support (or alternately spend time chasing down that dep, pass for now). Using cygwin I ran "./configure" which falsely uses the cygwin gcc for configuration checks, but since gcc is never used directly during the compilation process, that doesn't matter that much. I could have tried the "xcc" trick here again, but didn't bother. I ran into two problems during the build: - -Werror is specified in the GNUMakefile and there are many warnings. I just removed -Werror for now. - During linking it was not able to resolve "SleepEx" from src/win32/System/Posix.hs. I could not figure out what is going on here. I tried adding "-lkernel32" and "-L /ghc/ghc-6.8.2/gcc-lib -Lkernel32" to the Makefile and it still did not work even though /ghc/ghc-6.8.2/gcc-lib/libkernel32.a has SleepEx@8 defined(!) Finally I bit the bullet and hacked around this by noticing that mingw headers have _sleep() defined. I replaced the code in Posix.hs with: foreign import ccall "_sleep" c_sleep :: CULong -> IO () sleep :: Integer -> IO CInt sleep n = c_sleep (fromIntegral n) >> return (toEnum $ fromIntegral n) At this point darcs builds and the binary seems to work (so far). I don't know the implication of my sleep hack (which doesn't return the actual time slept). Here's a small test program which uses FFI to SleepEx which I was not able to get working with win32 ghc-6.8.2. ------ {-# OPTIONS -fglasgow-exts -fffi #-} module Main where import Foreign.C.Types foreign import ccall "SleepEx" c_SleepEx :: CUInt -> CInt -> IO CInt main = do putStrLn "start" n <- c_SleepEx (2*1000) 1 print n ------- So, what is going on with ghc-6.8.2? Why is the gcc so hard to use now? Why can't I get FFI working with standard win32 functions? Why aren't there prebuilt win32 darcs binaries anymore? Tim Newsham http://www.thenewsh.com/~newsham/

Am Mittwoch, 4. Juni 2008 22:26 schrieb Tim Newsham:
Here's a small test program which uses FFI to SleepEx which I was not able to get working with win32 ghc-6.8.2.
------ {-# OPTIONS -fglasgow-exts -fffi #-} module Main where import Foreign.C.Types
foreign import ccall "SleepEx" c_SleepEx :: CUInt -> CInt -> IO CInt
I seem to remember it should be "stdcall" on windows. That might also have a role in not finding SleepEx@8.
main = do putStrLn "start" n <- c_SleepEx (2*1000) 1 print n -------
So, what is going on with ghc-6.8.2? Why is the gcc so hard to use now? Why can't I get FFI working with standard win32 functions? Why aren't there prebuilt win32 darcs binaries anymore?
Tim Newsham http://www.thenewsh.com/~newsham/

On Wed, 2008-06-04 at 10:26 -1000, Tim Newsham wrote:
I built darcs for win32 recently and it was much more difficult than it should be. Probably most of the blame goes to ghc-6.8.2 binary release for win32. Half of the effort is getting the zlib prereq working.
Previously to build zlib for win32 ghc I did the following: http://www.haskell.org/pipermail/haskell-cafe/2007-March/023059.html
The recent versions of the zlib package on hackage bundle a complete copy of the zlib C library for the benefit of windows users (it uses the system zlib on all other systems). So it should "Just Work"tm. Duncan
participants (3)
-
Daniel Fischer
-
Duncan Coutts
-
Tim Newsham