diff options
author | Simon Marlow <marlowsd@gmail.com> | 2011-11-15 15:43:28 +0000 |
---|---|---|
committer | Simon Marlow <marlowsd@gmail.com> | 2011-11-16 14:39:24 +0000 |
commit | 1df28a805b465a28b61f4cfe4db28f247a183206 (patch) | |
tree | 2fff045a1ac1b8468bff2fb892b7059d397d794e /rts/Main.c | |
parent | 1790dbe4a5829af5bcdc5bc81eafb67b154008cc (diff) | |
download | haskell-1df28a805b465a28b61f4cfe4db28f247a183206.tar.gz |
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.
Diffstat (limited to 'rts/Main.c')
-rw-r--r-- | rts/Main.c | 24 |
1 files changed, 0 insertions, 24 deletions
diff --git a/rts/Main.c b/rts/Main.c deleted file mode 100644 index c7a559fc14..0000000000 --- a/rts/Main.c +++ /dev/null @@ -1,24 +0,0 @@ -/* ----------------------------------------------------------------------------- - * - * (c) The GHC Team 2009 - * - * The C main() function for a standalone Haskell program. - * - * Note that this is not part of the RTS. It calls into the RTS to get things - * going. It is compiled to a separate Main.o which is linked into every - * standalone Haskell program that uses a Haskell Main.main function - * (as opposed to a mixed Haskell C program using a C main function). - * - * ---------------------------------------------------------------------------*/ - -#include "PosixSource.h" -#include "Rts.h" -#include "RtsMain.h" - -/* Similarly, we can refer to the ZCMain_main_closure here */ -extern StgClosure ZCMain_main_closure; - -int main(int argc, char *argv[]) -{ - return hs_main(argc, argv, &ZCMain_main_closure); -} |