problem using ffi with profiling
Hal Daume III
hdaume@ISI.EDU
Mon, 27 Jan 2003 08:42:35 -0800 (PST)
Sure. The relevant files look like:
CMU_LM.hs:
...
import CTypes
import IOExts
...
foreign import ccall "lm_bridge.h
queryLanguageModel2" c__queryLanguageModel2 :: CUShort -> CUShort ->
CUShort -> IO Double
...
lm_bridge.h:
...
#include "pc_libs/pc_general.h"
#include "rr_libs/general.h"
#include "ngram.h"
#include "toolkit.h"
double queryLanguageModel2(id__t word, id__t c1, id__t c2);
...
When we compile without profiling, we get (package info snipped)
% ghc -ffi -cpp -c -fglasgow-exts -package data CMU_LM.hs
Glasgow Haskell Compiler, Version 5.04.2, for Haskell 98, compiled by GHC
version 5.04.2
Using package config file: /nfs/isd/hdaume/lib/ghc-5.04.2/package.conf
Hsc static flags: -static -fignore-interface-pragmas
-fomit-interface-pragmas -fdo-lambda-eta-expansion -flet-no-escape
*** C pre-processor
gcc -E -undef -traditional -v -I . -I
/nfs/isd/hdaume/lib/ghc-5.04.2/include -D__HASKELL1__=5
-D__GLASGOW_HASKELL__=504 -D__HASKELL98__ -D__CONCURRENT_HASKELL__ -x c
CMU_LM.hs -o /tmp/ghc8127.hscpp
Reading specs from /opt/sfw/lib/gcc-lib/sparc-sun-solaris2.8/2.95.2/specs
gcc version 2.95.2 19991024 (release)
/opt/sfw/lib/gcc-lib/sparc-sun-solaris2.8/2.95.2/cpp -lang-c -v -I . -I
/nfs/isd/hdaume/lib/ghc-5.04.2/include -D__GNUC__=2 -D__GNUC_MINOR__=95
-traditional -D__GCC_NEW_VARARGS__
-Acpu(sparc) -Amachine(sparc) -D__HASKELL1__=5 -D__GLASGOW_HASKELL__=504
-D__HASKELL98__ -D__CONCURRENT_HASKELL__ CMU_LM.hs -o /tmp/ghc8127.hscpp
GNU CPP version 2.95.2 19991024 (release) (sparc)
#include "..." search starts here:
#include <...> search starts here:
.
/nfs/isd/hdaume/lib/ghc-5.04.2/include
/opt/sfw/include
/opt/sfw/lib/gcc-lib/sparc-sun-solaris2.8/2.95.2/../../../../sparc-sun-solaris2.8/include
/opt/sfw/lib/gcc-lib/sparc-sun-solaris2.8/2.95.2/include
/usr/include
End of search list.
The following default directories have been omitted from the search path:
/opt/sfw/lib/gcc-lib/sparc-sun-solaris2.8/2.95.2/../../../../include/g++-3
End of omitted list.
*** Checking old interface for hs = Just "CMU_LM.hs", hspp = Just
"/tmp/ghc8127.hscpp":
*** Parser:
*** Renamer:
*** Typechecker:
*** Desugar:
*** Simplify:
*** Tidy Core:
*** CorePrep:
*** Stg2Stg:
*** CodeGen:
*** CodeOutput:
*** Assembler
gcc -I. -I. -c /tmp/ghc8127.s -o CMU_LM.o
*** Deleting temp files
Deleting: /tmp/ghc8127.s /tmp/ghc8127.hspp /tmp/ghc8127.hscpp
Warning: deleting non-existent /tmp/ghc8127.hspp
then, we remove CMU_LM.o and .hi and redo with -prof and get:
Glasgow Haskell Compiler, Version 5.04.2, for Haskell 98, compiled by GHC
version 5.04.2
Using package config file: /nfs/isd/hdaume/lib/ghc-5.04.2/package.conf
Hsc static flags: -static -fscc-profiling -fignore-interface-pragmas
-fomit-interface-pragmas -fdo-lambda-eta-expansion -flet-no-escape
*** C pre-processor
gcc -E -undef -traditional -v -I . -I
/nfs/isd/hdaume/lib/ghc-5.04.2/include -D__HASKELL1__=5
-D__GLASGOW_HASKELL__=504 -D__HASKELL98__ -D__CONCURRENT_HASKELL__
-D'PROFILING' -x c CMU_LM.hs -o /tmp/ghc8140.hscpp
Reading specs from /opt/sfw/lib/gcc-lib/sparc-sun-solaris2.8/2.95.2/specs
gcc version 2.95.2 19991024 (release)
/opt/sfw/lib/gcc-lib/sparc-sun-solaris2.8/2.95.2/cpp -lang-c -v -I . -I
/nfs/isd/hdaume/lib/ghc-5.04.2/include -D__GNUC__=2 -D__GNUC_MINOR__=95
-traditional -D__GCC_NEW_VARARGS__
-Acpu(sparc) -Amachine(sparc) -D__HASKELL1__=5 -D__GLASGOW_HASKELL__=504
-D__HASKELL98__ -D__CONCURRENT_HASKELL__ -DPROFILING CMU_LM.hs -o
/tmp/ghc8140.hscpp
GNU CPP version 2.95.2 19991024 (release) (sparc)
#include "..." search starts here:
#include <...> search starts here:
.
/nfs/isd/hdaume/lib/ghc-5.04.2/include
/opt/sfw/include
/opt/sfw/lib/gcc-lib/sparc-sun-solaris2.8/2.95.2/../../../../sparc-sun-solaris2.8/include
/opt/sfw/lib/gcc-lib/sparc-sun-solaris2.8/2.95.2/include
/usr/include
End of search list.
The following default directories have been omitted from the search path:
/opt/sfw/lib/gcc-lib/sparc-sun-solaris2.8/2.95.2/../../../../include/g++-3
End of omitted list.
*** Checking old interface for hs = Just "CMU_LM.hs", hspp = Just
"/tmp/ghc8140.hscpp":
*** Parser:
*** Renamer:
*** Typechecker:
*** Desugar:
*** Simplify:
*** Tidy Core:
*** CorePrep:
*** Stg2Stg:
*** CodeGen:
*** CodeOutput:
*** C Compiler
gcc -x c /tmp/ghc8140.hc -o /tmp/ghc8140.raw_s -w -v -S -Wimplicit -O
-D__GLASGOW_HASKELL__=504 -DPROFILING -ffloat-store -I . -I . -I
/nfs/isd/hdaume/lib/ghc-5.04.2/include
Reading specs from /opt/sfw/lib/gcc-lib/sparc-sun-solaris2.8/2.95.2/specs
gcc version 2.95.2 19991024 (release)
/opt/sfw/lib/gcc-lib/sparc-sun-solaris2.8/2.95.2/cpp -lang-c -v -I . -I
. -I /nfs/isd/hdaume/lib/ghc-5.04.2/include -D__GNUC__=2
-D__GNUC_MINOR__=95 -Dsparc -Dsun -Dunix -D__svr4__ -D__SVR4 -D__sparc__
-D__sun__ -D__unix__ -D__svr4__ -D__SVR4 -D__sparc -D__sun -D__unix
-Asystem(unix) -Asystem(svr4) -D__OPTIMIZE__ -Wimplicit -w
-D__GCC_NEW_VARARGS__
-Acpu(sparc) -Amachine(sparc) -D__GLASGOW_HASKELL__=504 -DPROFILING
/tmp/ghc8140.hc /var/tmp/cc7MwnHS.i
GNU CPP version 2.95.2 19991024 (release) (sparc)
#include "..." search starts here:
#include <...> search starts here:
.
/nfs/isd/hdaume/lib/ghc-5.04.2/include
/opt/sfw/include
/opt/sfw/lib/gcc-lib/sparc-sun-solaris2.8/2.95.2/../../../../sparc-sun-solaris2.8/include
/opt/sfw/lib/gcc-lib/sparc-sun-solaris2.8/2.95.2/include
/usr/include
End of search list.
The following default directories have been omitted from the search path:
/opt/sfw/lib/gcc-lib/sparc-sun-solaris2.8/2.95.2/../../../../include/g++-3
End of omitted list.
In file included from /tmp/ghc8140.hc:6:
lm_bridge.h:4: pc_libs/pc_general.h: No such file or directory
lm_bridge.h:5: rr_libs/general.h: No such file or directory
lm_bridge.h:6: ngram.h: No such file or directory
lm_bridge.h:7: toolkit.h: No such file or directory
Failed: gcc -x c /tmp/ghc8140.hc -o /tmp/ghc8140.raw_s -w -v -S -Wimplicit
-O -D__GLASGOW_HASKELL__=504 -DPROFILING -ffloat-store -I . -I . -I
/nfs/isd/hdaume/lib/ghc-5.04.2/include
*** Deleting temp files
Deleting: /tmp/ghc8140.raw_s /tmp/ghc8140.hc /tmp/ghc8140.hspp
/tmp/ghc8140.hscpp
Warning: deleting non-existent /tmp/ghc8140.raw_s
Warning: deleting non-existent /tmp/ghc8140.hspp
I can probably trim down a smaller example and send if off if that would
help. It doesn't happen with a very simple example. I think it probably
depends crucially on the fact that the .h file #includes another .h file.
- Hal
--
Hal Daume III
"Computer science is no more about computers | hdaume@isi.edu
than astronomy is about telescopes." -Dijkstra | www.isi.edu/~hdaume
On Mon, 27 Jan 2003, Simon Marlow wrote:
> > I'm having difficulty compiling something with profiling which uses
> > ffi. It compiles fine without profiling, but not with:
> ...
> > Any idea why there would be a difference?
>
> Not sure. Could you send the output with -v?
>
> Cheers,
> Simon
> _______________________________________________
> Glasgow-haskell-users mailing list
> Glasgow-haskell-users@haskell.org
> http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
>