bug in argument processing in hsc2hs

Antony Courtney antony at aya.yale.edu
Sun Dec 19 09:38:24 EST 2004


I'm trying to upgrade my Java/Haskell interoperability framework to the 
latest Java version.  Unfortunately, however, it appears that hsc2hs 
can't deal with embedded spaces in command line arguments.

The default install location for the latest JDK under Windows has 
changed to
	"C:/Program Files/Java/jdk1.5.0"
(note embdedded space), and include files (like <jni.h>) are found in 
the "include" subdirectory of above.  Unfortunately, it appears hsc2hs 
does some kind of extra parsing of its arguments somewhere, and gets 
very very confused by the extra spaces.

Adding a --cflag=-v to hsc2hs is somewhat illuminating about what's 
going wrong:

$ hsc2hs --cflag=-v -I"C:/Program Files/Java/jdk1.5.0/include" 
-I"C:/Program Files/Java/jdk1.5.0/include/win32" test2.hsc
Glasgow Haskell Compiler, Version 6.2.2, for Haskell 98, compiled by GHC 
version 6.0.1
Using package config file: c:\ghc\ghc-6.2.2\package.conf
[...]
*** C Compiler
c:\ghc\ghc-6.2.2\gcc -Bc:\ghc\ghc-6.2.2\gcc-lib/ test2_hsc_make.c -o 
c:\DOCUME~1\antony\LOCALS~1\Temp\ghc2688.s -DDONT_WANT_WIN32_DLL_SUPPORT 
-v -S -Wimplicit -O -D__GLASGOW_HASKELL__=602 -ffloat-store -I . -I C -I 
/Program -I C -I /Program -I c:/ghc/ghc-6.2.2/include -I 
c:/ghc/ghc-6.2.2/include/mingw

Note the suspicious "-I C -I /Program" args, which suggests that 
somebody somewhere is re-parsing the arguments to hsc2hs...

I tried to work around this by using an explicit --cc=gcc argument to 
hsc2hs, but then I get complaints from gcc about being unable to use -c 
and -S, leading me to think that hsc2hs makes some assumptions about ghc 
being the C compiler.

I've attached a little test program and Makefile to demonstrate the bug. 
  You can re-create the bug with:
$ make test2.hs

Any help or workarounds would be much appreciated.

Thanks,

	-Antony

-- 
Antony Courtney            email: antony at aya.yale.edu
New York, NY                 WWW: http://www.apocalypse.org/~antony
-------------- next part --------------

#include <stdio.h>
#include <stdlib.h>

/* for gcc: */
#define __int64 long long

#include <jni.h>

-------------- next part --------------

JDK = C:/Program Files/Java/jdk1.5.0

CPPFLAGS = -I"$(JDK)/include" -I"$(JDK)/include/win32"

CFLAGS = $(CPPFLAGS)

# CC = C:/ghc/ghc-6.2.2/bin/ghc

# We'd like to do things this way, but it looks like either
# hsc2hs or ghc can't handle embedded spaces in arguments:
%.hs : %.hsc
	hsc2hs --cflag=-v $(CPPFLAGS) $<

# Attempted workaround:  This doesn't work either, because hsc2hs actually
# makes a bunch of assumptions about the C compiler and passes arguments to
# it that don't actually work with ghc...
#%.hs : %.hsc
#	hsc2hs --cc=gcc --cflag=-V --cflag=-I"$(JDK)/include" --cflag=-I"$(JDK)/include/win32" --ld=ghc -DHSC $(CPPFLAGS) $<
-------------- next part --------------
module Test2 where

import Foreign
import Foreign.C.Types
import CString

#define FFIJNI_IMPL
#include <jni.h>


More information about the Cvs-ghc mailing list