-
- Downloads
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.
Showing
- compiler/main/DriverPipeline.hs 25 additions, 24 deletionscompiler/main/DriverPipeline.hs
- includes/Rts.h 1 addition, 0 deletionsincludes/Rts.h
- includes/RtsAPI.h 43 additions, 5 deletionsincludes/RtsAPI.h
- includes/RtsOpts.h 0 additions, 20 deletionsincludes/RtsOpts.h
- includes/rts/Main.h 3 additions, 1 deletionincludes/rts/Main.h
- rts/Main.c 0 additions, 24 deletionsrts/Main.c
- rts/RtsFlags.c 14 additions, 12 deletionsrts/RtsFlags.c
- rts/RtsFlags.h 3 additions, 1 deletionrts/RtsFlags.h
- rts/RtsMain.c 11 additions, 8 deletionsrts/RtsMain.c
- rts/RtsStartup.c 13 additions, 1 deletionrts/RtsStartup.c
- rts/ghc.mk 1 addition, 12 deletionsrts/ghc.mk
- rts/hooks/RtsOpts.c 0 additions, 14 deletionsrts/hooks/RtsOpts.c
Loading
Please register or sign in to comment