Trying to get the whole #include business right: ccalls are unfolded
into interface files, even without -funfold-casms-in-hi-file. Although
this is a good thing performance-wise, the header files should better
be #included during compilation of the .hc files. Solution:
* Every .hc file #includes "Stg.h" first.
* For every package `foo' used, "HsFoo.h" is #included, too. This
means that every package has to come with a corresponding header
file, even if it is empty.
Downside:
* Getting #includes right with ghc-inplace is a little bit ugly:
The boot target in Makefiles must copy the package's header files
into GHC_INCLUDE_DIR (don't forget the clean target!), and final
installation of those headers is done there, too. :-P Better
solutions are highly welcome.
* Possible pollution of the C name spaces.
\begin{code}
$CcRegd = $GHC_OPT_HILEV_ASM;
@CcBoth_flags = ('-S','-Wimplicit'); # flags for *any* C compilation
\begin{code}
$CcRegd = $GHC_OPT_HILEV_ASM;
@CcBoth_flags = ('-S','-Wimplicit'); # flags for *any* C compilation
+@CcInjects = ("#include \"Stg.h\"\n", "#include \"HsStd.h\"\n");
# GCC flags:
# those for all files,
# GCC flags:
# those for all files,
# a tmp .c file which #include's the needful.
open(TMP, "> $cc_help") || &tidy_up_and_die(1,"$Pgm: failed to open `$cc_help' (to write)\n");
if ( $is_hc_file ) {
# a tmp .c file which #include's the needful.
open(TMP, "> $cc_help") || &tidy_up_and_die(1,"$Pgm: failed to open `$cc_help' (to write)\n");
if ( $is_hc_file ) {
- print TMP <<EOINCL;
-#include "Stg.h"
-EOINCL
- # user may have asked for #includes to be injected...
- print TMP @CcInjects if $#CcInjects >= 0;
} else {
# Straight .c files may want to know that they're being used
# with a particular version of GHC, so we define __GLASGOW_HASKELL__ for their benefit.
} else {
# Straight .c files may want to know that they're being used
# with a particular version of GHC, so we define __GLASGOW_HASKELL__ for their benefit.
+ # Make sure that header file HsFoo.h is included for syslib foo.
+ push(@CcInjects, "#include \"Hs\u$syslib.h\"\n") unless ( exists $Syslibs_added{$syslib} );
+
# This check is here to avoid syslib loops from
# spoiling the party. A side-effect of it is that
# it disallows multiple mentions of a syslib on a command-line,
# This check is here to avoid syslib loops from
# spoiling the party. A side-effect of it is that
# it disallows multiple mentions of a syslib on a command-line,