aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/ld
diff options
context:
space:
mode:
authorDmitriy Vyukov <dvyukov@google.com>2011-12-07 16:53:17 +0300
committerDmitriy Vyukov <dvyukov@google.com>2011-12-07 16:53:17 +0300
commit428062da4e5e35ce75178d993dd6d8ef5e3ecb5d (patch)
treeba42071e9fce2013704374474713b920249a2c23 /src/cmd/ld
parent5e43527336e056b9c5a51bf0e23e790c86e3affa (diff)
downloadgo-428062da4e5e35ce75178d993dd6d8ef5e3ecb5d.tar.xz
ld: increase default stack size on Windows for cgo
Fixes #2437. R=rsc, hectorchu, mattn.jp, alex.brainman, jdpoirier, snaury, n13m3y3r CC=golang-dev https://golang.org/cl/5371049
Diffstat (limited to 'src/cmd/ld')
-rw-r--r--src/cmd/ld/lib.c1
-rw-r--r--src/cmd/ld/lib.h1
-rw-r--r--src/cmd/ld/pe.c17
3 files changed, 17 insertions, 2 deletions
diff --git a/src/cmd/ld/lib.c b/src/cmd/ld/lib.c
index 82f3f007f4..5a4d752892 100644
--- a/src/cmd/ld/lib.c
+++ b/src/cmd/ld/lib.c
@@ -274,6 +274,7 @@ loadlib(void)
for(i=0; i<libraryp; i++) {
if(debug['v'])
Bprint(&bso, "%5.2f autolib: %s (from %s)\n", cputime(), library[i].file, library[i].objref);
+ iscgo |= strcmp(library[i].pkg, "runtime/cgo") == 0;
objfile(library[i].file, library[i].pkg);
}
diff --git a/src/cmd/ld/lib.h b/src/cmd/ld/lib.h
index f66eb438f0..bbaa52d43c 100644
--- a/src/cmd/ld/lib.h
+++ b/src/cmd/ld/lib.h
@@ -125,6 +125,7 @@ EXTERN int32 nsymbol;
EXTERN char* thestring;
EXTERN int ndynexp;
EXTERN int havedynamic;
+EXTERN int iscgo;
EXTERN Segment segtext;
EXTERN Segment segdata;
diff --git a/src/cmd/ld/pe.c b/src/cmd/ld/pe.c
index 2e50490cec..1d70b4808b 100644
--- a/src/cmd/ld/pe.c
+++ b/src/cmd/ld/pe.c
@@ -650,8 +650,21 @@ asmbpe(void)
// Commit size must be strictly less than reserve
// size otherwise reserve will be rounded up to a
// larger size, as verified with VMMap.
- set(SizeOfStackReserve, 0x00010000);
- set(SizeOfStackCommit, 0x0000ffff);
+
+ // Go code would be OK with 64k stacks, but we need larger stacks for cgo.
+ // That default stack reserve size affects only the main thread,
+ // for other threads we specify stack size in runtime explicitly
+ // (runtime knows whether cgo is enabled or not).
+ // If you change stack reserve sizes here,
+ // change them in runtime/cgo/windows_386/amd64.c as well.
+ if(!iscgo) {
+ set(SizeOfStackReserve, 0x00010000);
+ set(SizeOfStackCommit, 0x0000ffff);
+ } else {
+ set(SizeOfStackReserve, pe64 ? 0x00200000 : 0x00100000);
+ // account for 2 guard pages
+ set(SizeOfStackCommit, (pe64 ? 0x00200000 : 0x00100000) - 0x2000);
+ }
set(SizeOfHeapReserve, 0x00100000);
set(SizeOfHeapCommit, 0x00001000);
set(NumberOfRvaAndSizes, 16);