| ... |
... |
@@ -18,16 +18,17 @@ |
|
18
|
18
|
* // etc.
|
|
19
|
19
|
* };
|
|
20
|
20
|
*
|
|
21
|
|
- * `ghc_hs_iface` is initialized during program loading via the
|
|
22
|
|
- * `init_ghc_hs_iface` constructor in `ghc-interface`
|
|
|
21
|
+ * `ghc_hs_iface` is initialized via the `init_ghc_hs_iface` function
|
|
|
22
|
+ * in `ghc-internal` cbits, when it is invoked by `hs_init_ghc` during
|
|
|
23
|
+ * GHC RTS initialization:
|
|
23
|
24
|
*
|
|
24
|
|
- * const struct HsIface the_hs_iface = {
|
|
|
25
|
+ * struct HsIface the_hs_iface = {
|
|
25
|
26
|
* .runIO = &ghczminternal_GHCziInternalziTopHandler_runIO_closure,
|
|
26
|
27
|
* .Z0T = &ghczminternal_GHCziInternalziTuple_Z0T_closure,
|
|
27
|
28
|
* // etc.
|
|
28
|
29
|
* };
|
|
29
|
30
|
*
|
|
30
|
|
- * void __attribute__((constructor)) init_ghc_hs_iface() {
|
|
|
31
|
+ * void init_ghc_hs_iface(void) {
|
|
31
|
32
|
* ghc_hs_iface = &the_hs_iface;
|
|
32
|
33
|
* }
|
|
33
|
34
|
*
|
| ... |
... |
@@ -36,7 +37,7 @@ |
|
36
|
37
|
* side-effect of making the interface between the RTS and `ghc-internal`
|
|
37
|
38
|
* explicit.
|
|
38
|
39
|
*
|
|
39
|
|
- * Note that the ((constructor)) symbol is explicitly included in the final
|
|
|
40
|
+ * Note that the init_ghc_hs_iface symbol is explicitly included in the final
|
|
40
|
41
|
* binary via the linker flag `-uinit_ghc_hs_iface`, when an executable is
|
|
41
|
42
|
* linked against ghc-internal by GHC.
|
|
42
|
43
|
*
|
| ... |
... |
@@ -45,11 +46,15 @@ |
|
45
|
46
|
* (since, otherwise, only objects members which provide undefined symbols
|
|
46
|
47
|
* needed by the executable are included in the final object).
|
|
47
|
48
|
*
|
|
48
|
|
- * When `ghc-internal` is a dynamic dependency of an executable, the
|
|
49
|
|
- * constructor will run when the shared object for `ghc-internal` is loaded.
|
|
50
|
|
- * When the executable is statically linked against `ghc-internal`, the
|
|
51
|
|
- * constructor will be run when the program is loaded (since the constructor
|
|
52
|
|
- * symbol was forcibly included as described in the paragraph above).
|
|
|
49
|
+ * CAUTION: there may be constructors invoked before hs_init_ghc, and
|
|
|
50
|
+ * those constructors will see an uninitialized ghc_hs_iface! For now
|
|
|
51
|
+ * we're fine: when GHC generates a constructor that references
|
|
|
52
|
+ * certain closures or info tables, the generated references don't go
|
|
|
53
|
+ * through ghc_hs_iface redirection, and they are not forward
|
|
|
54
|
+ * references to other objects not compiled yet. Still, always keep
|
|
|
55
|
+ * the no-ghc_hs_iface restriction in mind when doing work related to
|
|
|
56
|
+ * constructors, be it the compiler-generated ones or explicitly
|
|
|
57
|
+ * written ones in RTS.
|
|
53
|
58
|
*/
|
|
54
|
59
|
|
|
55
|
60
|
#include "Rts.h"
|