yes I tripped over this too. The idea was to reduce recompilation checking, but unfortunately the FFI means the compiler is apparently supposed to see the rep of a newtype even if the programmer can't.
I've committed a fix for this one -- but I think you'll trip over a lint error in Quickcheck which I have not yet tracked down. Simon | -----Original Message----- | From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Sean Seefried | Sent: 10 February 2004 16:36 | To: Donald Bruce Stewart; [EMAIL PROTECTED] | Subject: Strange GHC bug | | Hi all, | | I'm came across the *strangest* build problem. (I was compiling the 8 | February 2004 GHC HEAD.) It seems that if you compile libraries with | the -Onot flag then data types are exported abstractly! I first became | aware of this problem while trying to build | base/Foreign/Marshall/Alloc.o. I received the following error: | | ------------- | | ../../ghc/compiler/ghc-inplace -H16m -O | -I/home/sseefried/local-ppc7400/include | -L/home/sseefried/local-ppc7400/lib -framework-path | /home/sseefried/Library/Fram | eworks -framework HaskellSupport -fglasgow-exts -cpp -Iinclude | -#include HsBase. | h -funbox-strict-fields -package-name base -H32 -Onot -Rghc-timing | -c Foreig | n/Marshal/Alloc.hs -o Foreign/Marshal/Alloc.o -ohi | Foreign/Marshal/Alloc.hi | | Foreign/Marshal/Alloc.hs:155:0: | Unacceptable argument type in foreign declaration: CSize | When checking declaration: | foreign import ccall unsafe "static stdlib.h &malloc" _malloc | :: CSize | | -> IO ( | Ptr a) | | Foreign/Marshal/Alloc.hs:156:0: | Unacceptable argument type in foreign declaration: CSize | When checking declaration: | foreign import ccall unsafe "static stdlib.h &realloc" _realloc | :: Ptr a | | -> CS | ize -> IO (Ptr b) | <<ghc: 11741976 bytes, 27 GCs, 553492/1069000 avg/max bytes residency | (2 samples | ), 6M in use, 0.02 INIT (0.01 elapsed), 0.20 MUT (0.29 elapsed), 0.19 | GC (0.12 e | lapsed) :ghc>> | make[1]: *** [Foreign/Marshal/Alloc.o] Error 1 | | -------------- | | I tracked this problem down to an error that is defined in | ghc/compiler/typecheck/TcForeign.lhs. | I quickly discovered that the argument type of a foreign import dynamic | must be marshalable type or a newtype of such a type. I looked into | Foreign/C/Types.hs and found that CSize should indeed be a newtype of a | marshalable type. So what was the problem? I decided to look at the | interface file Foreign/C/Types.hi using the --show-iface flag. | | To my surprise I got the following! | | 6 newtype CSize | Variances [] | RecFlag NonRecursive | Generics: yes | {- abstract -} | | When I removed the -Onot flag what I got was this: | | 6 newtype CSize | Variances [] | RecFlag NonRecursive | Generics: yes | = CSize GHC.Word.Word32{1} Stricts: _ | | This is obviously correct. | | So is this known behaviour and if so, why does it happen? | | Sean | | _______________________________________________ | Cvs-ghc mailing list | [EMAIL PROTECTED] | http://www.haskell.org/mailman/listinfo/cvs-ghc _______________________________________________ Cvs-ghc mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/cvs-ghc
