summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@golang.org>2010-04-09 14:15:15 -0700
committerIan Lance Taylor <iant@golang.org>2010-04-09 14:15:15 -0700
commitdb29cd3d807e01e17add6dd664c408d8977eaa1b (patch)
tree666ed57d59b516785cd5f0733d6cc817f50fe069
parent6bac492a5893aee496bacf021e1f4c1b4ccbfc0d (diff)
downloadgolang-db29cd3d807e01e17add6dd664c408d8977eaa1b.tar.gz
Run initcgo for all amd64 targets, not just GNU/Linux.
This is required to make cgo export work on Darwin. Note that this corrects the stack alignment when calling initcgo to that required by gcc on amd64. R=rsc CC=golang-dev http://codereview.appspot.com/907041
-rw-r--r--src/pkg/runtime/amd64/asm.s9
-rw-r--r--src/pkg/runtime/linux/amd64/rt0.s7
2 files changed, 8 insertions, 8 deletions
diff --git a/src/pkg/runtime/amd64/asm.s b/src/pkg/runtime/amd64/asm.s
index 627af6632..52b0a89bc 100644
--- a/src/pkg/runtime/amd64/asm.s
+++ b/src/pkg/runtime/amd64/asm.s
@@ -9,10 +9,16 @@ TEXT _rt0_amd64(SB),7,$-8
MOVQ 0(DI), AX // argc
LEAQ 8(DI), BX // argv
SUBQ $(4*8+7), SP // 2args 2auto
- ANDQ $~7, SP
+ ANDQ $~15, SP
MOVQ AX, 16(SP)
MOVQ BX, 24(SP)
+ // if there is an initcgo, call it.
+ MOVQ initcgo(SB), AX
+ TESTQ AX, AX
+ JZ 2(PC)
+ CALL AX
+
// set the per-goroutine and per-mach registers
LEAQ m0(SB), m
LEAQ g0(SB), g
@@ -372,4 +378,5 @@ TEXT getcallersp(SB),7,$0
MOVQ sp+0(FP), AX
RET
+GLOBL initcgo(SB), $8
GLOBL libcgo_set_scheduler(SB), $8
diff --git a/src/pkg/runtime/linux/amd64/rt0.s b/src/pkg/runtime/linux/amd64/rt0.s
index 6b1b29775..2190b4414 100644
--- a/src/pkg/runtime/linux/amd64/rt0.s
+++ b/src/pkg/runtime/linux/amd64/rt0.s
@@ -5,13 +5,6 @@
// Darwin and Linux use the same linkage to main
TEXT _rt0_amd64_linux(SB),7,$-8
- MOVQ initcgo(SB), AX
- TESTQ AX, AX
- JZ 2(PC)
- CALL AX
-
MOVQ $_rt0_amd64(SB), AX
MOVQ SP, DI
JMP AX
-
-GLOBL initcgo(SB), $8