From 1df28a805b465a28b61f4cfe4db28f247a183206 Mon Sep 17 00:00:00 2001 From: Simon Marlow Date: Tue, 15 Nov 2011 15:43:28 +0000 Subject: Generate the C main() function when linking a binary (fixes #5373) Rather than have main() be statically compiled as part of the RTS, we now generate it into the tiny C file that we compile when linking a binary. The main motivation is that we want to pass the settings for the -rtsotps and -with-rtsopts flags into the RTS, rather than relying on fragile linking semantics to override the defaults, which don't work with DLLs on Windows (#5373). In order to do this, we need to extend the API for initialising the RTS, so now we have: void hs_init_ghc (int *argc, char **argv[], // program arguments RtsConfig rts_config); // RTS configuration hs_init_ghc() can optionally be used instead of hs_init(), and allows passing in configuration options for the RTS. RtsConfig is a struct, which currently has two fields: typedef struct { RtsOptsEnabledEnum rts_opts_enabled; const char *rts_opts; } RtsConfig; but might have more in the future. There is a default value for the struct, defaultRtsConfig, the idea being that you start with this and override individual fields as necessary. In fact, main() was in a separate static library, libHSrtsmain.a. That's now gone. --- includes/Rts.h | 1 + 1 file changed, 1 insertion(+) (limited to 'includes/Rts.h') diff --git a/includes/Rts.h b/includes/Rts.h index 91ec76d467..5caba59dbe 100644 --- a/includes/Rts.h +++ b/includes/Rts.h @@ -213,6 +213,7 @@ void _assertFail(const char *filename, unsigned int linenum) #include "rts/TTY.h" #include "rts/Utils.h" #include "rts/PrimFloat.h" +#include "rts/Main.h" /* Misc stuff without a home */ DLL_IMPORT_RTS extern char **prog_argv; /* so we can get at these from Haskell */ -- cgit v1.2.1