Commit 5490814c authored by Shenghou Ma's avatar Shenghou Ma

cmd/go, cmd/ld: fix libgcc order and add __image_base__ symbol for windows

        Fixes #4063.

R=alex.brainman, rsc
CC=golang-dev
https://golang.org/cl/6543066
parent e80fccb4
......@@ -1597,9 +1597,12 @@ func (b *builder) cgo(p *Package, cgoExe, obj string, gccfiles []string) (outGo,
if err != nil {
return nil, nil, err
}
staticLibs := []string{libgcc}
var staticLibs []string
if goos == "windows" {
staticLibs = append(staticLibs, "-lmingwex", "-lmingw32")
// libmingw32 and libmingwex might also use libgcc, so libgcc must come last
staticLibs = []string{"-lmingwex", "-lmingw32", libgcc}
} else {
staticLibs = []string{libgcc}
}
for _, cfile := range cfiles {
......
......@@ -148,6 +148,9 @@ peinit(void)
PESECTHEADR = rnd(PEFILEHEADR, PESECTALIGN);
nextsectoff = PESECTHEADR;
nextfileoff = PEFILEHEADR;
// some mingw libs depend on this symbol, for example, FindPESectionByName
xdefine("__image_base__", SDATA, PEBASE);
}
static void
......
......@@ -64,11 +64,10 @@ echo.
:: cgo tests
if x%CGO_ENABLED% == x0 goto nocgo
:: TODO(brainman) disabled, because it is broken on go builder - http://golang.org/issue/4063
::echo # ..\misc\cgo\life
::go run %GOROOT%\test\run.go - ..\misc\cgo\life
::if errorlevel 1 goto fail
::echo.
echo # ..\misc\cgo\life
go run %GOROOT%\test\run.go - ..\misc\cgo\life
if errorlevel 1 goto fail
echo.
echo # ..\misc\cgo\stdio
go run %GOROOT%\test\run.go - ..\misc\cgo\stdio
......
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