Commit 1d0c89a4 authored by Russ Cox's avatar Russ Cox

runtime: run runtime.init

Run it right before main.init.
There is still some runtime initialization that
happens before runtime.init, and some of that
may call into Go code (for example to acquire locks)
so this timing is not perfect, but I believe it is the
best we can do.

This came up because global variables intialized
to func values are done in the generated init code,
not in the linker.

LGTM=dvyukov
R=dvyukov
CC=golang-codereviews, iant, khr, r
https://golang.org/cl/135210043
parent 4af796fb
...@@ -199,6 +199,7 @@ runtime·schedinit(void) ...@@ -199,6 +199,7 @@ runtime·schedinit(void)
} }
extern void main·init(void); extern void main·init(void);
extern void runtime·init(void);
extern void main·main(void); extern void main·main(void);
static FuncVal initDone = { runtime·unlockOSThread }; static FuncVal initDone = { runtime·unlockOSThread };
...@@ -246,6 +247,7 @@ runtime·main(void) ...@@ -246,6 +247,7 @@ runtime·main(void)
if(g->m != &runtime·m0) if(g->m != &runtime·m0)
runtime·throw("runtime·main not on m0"); runtime·throw("runtime·main not on m0");
runtime·init();
main·init(); main·init();
if(g->defer != &d || d.fn != &initDone) if(g->defer != &d || d.fn != &initDone)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment