[Haskell-beginners] problem using hsc2hs

Graham Gill math.simplex at gmail.com
Mon Aug 29 05:45:30 CEST 2011


I've been trying to build package unix-compat-0.2.2.1 on a Windows XP 
machine which has the latest Haskell package installed (2011.2.0.1). I 
use "cabal install unix-compat". (I've updated my package list.)

I run into a problem when the file Extensions.hs is generated from 
Extensions.hsc using hsc2hs. Extensions.hs is created, but empty.

When I run the cabal install with verbose on, I'm able to see the hsc2hs 
command which generates Extensions.hs. Running that hsc2hs command with 
verbose on, I see the steps where it creates intermediate files .c, .o 
and .exe, then runs the .exe, which sends its output to stdout, and that 
stdout is redirected into Extentions.hs. The intermediate files are 
deleted. Extensions.hs is empty.

However, if I manually run each command which hsc2hs runs, Extensions.hs 
has the intended contents. I've reproduced the details below. Could this 
be a case of a problem with how lazy IO is used?

Here are the details. This command (I've cut out the paths from 
Extensions* files, so they're all created in/read from the current 
directory),

"C:\Program Files\Haskell Platform\2011.2.0.1\bin\hsc2hs.exe" 
--cc="C:\Program Files\Haskell Platform\2011.2.0.1\mingw\bin\gcc.exe" 
--ld="C:\Program Files\Haskell Platform\2011.2.0.1\mingw\bin\gcc.exe" 
--cflag=-fno-stack-protector --lflag=-fno-stack-protector 
--cflag=-D__GLASGOW_HASKELL__=700 --cflag=-Dmingw32_BUILD_OS 
--cflag=-Dmingw32_HOST_OS --cflag=-Di386_BUILD_ARCH 
--cflag=-Di386_HOST_ARCH --cflag=-DMISSING_POSIX_TYPES 
--cflag="-IC:\Program Files\Haskell 
Platform\2011.2.0.1\lib\directory-1.1.0.0\include" --cflag="-IC:\Program 
Files\Haskell Platform\2011.2.0.1\lib\old-time-1.0.0.6\include" 
--cflag="-IC:\Program Files\Haskell 
Platform\2011.2.0.1\lib\Win32-2.2.0.1\include" --cflag="-IC:\Program 
Files\Haskell Platform\2011.2.0.1\lib\bytestring-0.9.1.10\include" 
--cflag="-IC:\Program Files\Haskell 
Platform\2011.2.0.1\lib\base-4.3.1.0\include" --cflag="-IC:\Program 
Files\Haskell Platform\2011.2.0.1\lib/include" --cflag="-IC:\Program 
Files\Haskell Platform\2011.2.0.1\lib/include" --lflag="-LC:\Program 
Files\Haskell Platform\2011.2.0.1\lib\directory-1.1.0.0" 
--lflag="-LC:\Program Files\Haskell 
Platform\2011.2.0.1\lib\old-time-1.0.0.6" --lflag="-LC:\Program 
Files\Haskell Platform\2011.2.0.1\lib\old-locale-1.0.0.2" 
--lflag="-LC:\Program Files\Haskell 
Platform\2011.2.0.1\lib\filepath-1.2.0.0" --lflag="-LC:\Program 
Files\Haskell Platform\2011.2.0.1\lib\Win32-2.2.0.1" --lflag=-luser32 
--lflag=-lgdi32 --lflag=-lwinmm --lflag=-ladvapi32 --lflag=-lshell32 
--lflag=-lshfolder --lflag="-LC:\Program Files\Haskell 
Platform\2011.2.0.1\lib\bytestring-0.9.1.10" --lflag="-LC:\Program 
Files\Haskell Platform\2011.2.0.1\lib\base-4.3.1.0" --lflag=-lwsock32 
--lflag=-luser32 --lflag=-lshell32 --lflag="-LC:\Program Files\Haskell 
Platform\2011.2.0.1\lib\integer-gmp-0.2.0.3" --lflag="-LC:\Program 
Files\Haskell Platform\2011.2.0.1\lib\ghc-prim-0.2.0.0" 
--lflag="-LC:\Program Files\Haskell Platform\2011.2.0.1\lib" --lflag=-lm 
--lflag=-lwsock32 --lflag="-LC:\Program Files\Haskell 
Platform\2011.2.0.1\lib" --verbose -o Extensions.hs Extensions.hsc

run in a Windows command shell, generates Extensions_hsc_make.c, 
Extensions_hsc_make.o, Extensions_hsc_make.exe, and then runs

.\Extensions_hsc_make.exe >Extensions.hs

After this the intermediate files Extensions_hsc_make.* are deleted. 
Extensions.hs has no contents.

Since I ran with verbose on, I could see each step. Running each step 
individually:

1) create Extensions_hsc_make.c from Extensions.hsc, using --no-compile 
flag to hsc2hs:
"C:\Program Files\Haskell Platform\2011.2.0.1\bin\hsc2hs.exe" 
--cc="C:\Program Files\Haskell Platform\2011.2.0.1\mingw\bin\gcc.exe" 
--ld="C:\Program Files\Haskell Platform\2011.2.0.1\mingw\bin\gcc.exe" 
--cflag=-fno-stack-protector --lflag=-fno-stack-protector 
--cflag=-D__GLASGOW_HASKELL__=700 --cflag=-Dmingw32_BUILD_OS 
--cflag=-Dmingw32_HOST_OS --cflag=-Di386_BUILD_ARCH 
--cflag=-Di386_HOST_ARCH --cflag=-DMISSING_POSIX_TYPES 
--cflag="-IC:\Program Files\Haskell 
Platform\2011.2.0.1\lib\directory-1.1.0.0\include" --cflag="-IC:\Program 
Files\Haskell Platform\2011.2.0.1\lib\old-time-1.0.0.6\include" 
--cflag="-IC:\Program Files\Haskell 
Platform\2011.2.0.1\lib\Win32-2.2.0.1\include" --cflag="-IC:\Program 
Files\Haskell Platform\2011.2.0.1\lib\bytestring-0.9.1.10\include" 
--cflag="-IC:\Program Files\Haskell 
Platform\2011.2.0.1\lib\base-4.3.1.0\include" --cflag="-IC:\Program 
Files\Haskell Platform\2011.2.0.1\lib/include" --cflag="-IC:\Program 
Files\Haskell Platform\2011.2.0.1\lib/include" --lflag="-LC:\Program 
Files\Haskell Platform\2011.2.0.1\lib\directory-1.1.0.0" 
--lflag="-LC:\Program Files\Haskell 
Platform\2011.2.0.1\lib\old-time-1.0.0.6" --lflag="-LC:\Program 
Files\Haskell Platform\2011.2.0.1\lib\old-locale-1.0.0.2" 
--lflag="-LC:\Program Files\Haskell 
Platform\2011.2.0.1\lib\filepath-1.2.0.0" --lflag="-LC:\Program 
Files\Haskell Platform\2011.2.0.1\lib\Win32-2.2.0.1" --lflag=-luser32 
--lflag=-lgdi32 --lflag=-lwinmm --lflag=-ladvapi32 --lflag=-lshell32 
--lflag=-lshfolder --lflag="-LC:\Program Files\Haskell 
Platform\2011.2.0.1\lib\bytestring-0.9.1.10" --lflag="-LC:\Program 
Files\Haskell Platform\2011.2.0.1\lib\base-4.3.1.0" --lflag=-lwsock32 
--lflag=-luser32 --lflag=-lshell32 --lflag="-LC:\Program Files\Haskell 
Platform\2011.2.0.1\lib\integer-gmp-0.2.0.3" --lflag="-LC:\Program 
Files\Haskell Platform\2011.2.0.1\lib\ghc-prim-0.2.0.0" 
--lflag="-LC:\Program Files\Haskell Platform\2011.2.0.1\lib" --lflag=-lm 
--lflag=-lwsock32 --lflag="-LC:\Program Files\Haskell 
Platform\2011.2.0.1\lib" --no-compile -o Extensions.hs Extensions.hsc

2) create Extensions_hsc_make.o from Extensions_hsc_make.c:
"C:\Program Files\Haskell Platform\2011.2.0.1\mingw\bin\gcc.exe" -c 
Extensions_hsc_make.c -o Extensions_hsc_make.o -fno-stack-protector 
-D__GLASGOW_HASKELL__=700 -Dmingw32_BUILD_OS -Dmingw32_HOST_OS 
-Di386_BUILD_ARCH -Di386_HOST_ARCH -DMISSING_POSIX_TYPES -I"C:\Program 
Files\Haskell Platform\2011.2.0.1\lib\directory-1.1.0.0\include" 
-I"C:\Program Files\Haskell 
Platform\2011.2.0.1\lib\old-time-1.0.0.6\include" -I"C:\Program 
Files\Haskell Platform\2011.2.0.1\lib\Win32-2.2.0.1\include" 
-I"C:\Program Files\Haskell 
Platform\2011.2.0.1\lib\bytestring-0.9.1.10\include" -I"C:\Program 
Files\Haskell Platform\2011.2.0.1\lib\base-4.3.1.0\include" 
-I"C:\Program Files\Haskell Platform\2011.2.0.1\lib/include" 
-I"C:\Program Files\Haskell Platform\2011.2.0.1\lib/include" 
-I"C:/Program Files/Haskell Platform/2011.2.0.1/lib/include/"

3) create Extensions_hsc_make.exe from Extensions_hsc_make.o:
"C:\Program Files\Haskell Platform\2011.2.0.1\mingw\bin\gcc.exe" 
Extensions_hsc_make.o -o Extensions_hsc_make.exe -fno-stack-protector 
-L"C:\Program Files\Haskell Platform\2011.2.0.1\lib\directory-1.1.0.0" 
-L"C:\Program Files\Haskell Platform\2011.2.0.1\lib\old-time-1.0.0.6" 
-L"C:\Program Files\Haskell Platform\2011.2.0.1\lib\old-locale-1.0.0.2" 
-L"C:\Program Files\Haskell Platform\2011.2.0.1\lib\filepath-1.2.0.0" 
-L"C:\Program Files\Haskell Platform\2011.2.0.1\lib\Win32-2.2.0.1" 
-luser32 -lgdi32 -lwinmm -ladvapi32 -lshell32 -lshfolder -L"C:\Program 
Files\Haskell Platform\2011.2.0.1\lib\bytestring-0.9.1.10" -L"C:\Program 
Files\Haskell Platform\2011.2.0.1\lib\base-4.3.1.0" -lwsock32 -luser32 
-lshell32 -L"C:\Program Files\Haskell 
Platform\2011.2.0.1\lib\integer-gmp-0.2.0.3" -L"C:\Program Files\Haskell 
Platform\2011.2.0.1\lib\ghc-prim-0.2.0.0" -L"C:\Program Files\Haskell 
Platform\2011.2.0.1\lib" -lm -lwsock32 -L"C:\Program Files\Haskell 
Platform\2011.2.0.1\lib"

4) and creating Extensions.hs using Extensions_hsc_make.exe:
Extensions_hsc_make.exe >Extensions.hs

This generates a file with the intended contents. There are two other 
files in the unix-compat package, Files.hsc and User.hsc, which run into 
the same problem.

So what's the difference between running each step individually, which 
works, and running the combination of all steps, which gives me an empty 
file?

cheers!
Graham



More information about the Beginners mailing list