]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go, cmd/ld: fix libgcc order and add __image_base__ symbol for windows
authorShenghou Ma <minux.ma@gmail.com>
Wed, 26 Sep 2012 14:34:25 +0000 (22:34 +0800)
committerShenghou Ma <minux.ma@gmail.com>
Wed, 26 Sep 2012 14:34:25 +0000 (22:34 +0800)
        Fixes #4063.

R=alex.brainman, rsc
CC=golang-dev
https://golang.org/cl/6543066

src/cmd/go/build.go
src/cmd/ld/pe.c
src/run.bat

index 889ed08b3b267c971d30129ba400a4e669e343fc..af5d87843f64c12775362f8acb6ea9aee07115ed 100644 (file)
@@ -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 {
index 1d70b4808b8686f93ff4053406cf34b7a63129bf..e69f34783dd57127f1d3f365352a92e83f0efbd3 100644 (file)
@@ -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
index 4998d815fb3d13f06e0acc55b2a230aa35e4a094..ea87d3d806b607d424196464189b88f871ebdcda 100644 (file)
@@ -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