]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/cgo: use explicit flag to emit dynamic linker path
authorRuss Cox <rsc@golang.org>
Mon, 4 Mar 2013 16:23:17 +0000 (11:23 -0500)
committerRuss Cox <rsc@golang.org>
Mon, 4 Mar 2013 16:23:17 +0000 (11:23 -0500)
Using -import_runtime_cgo would have worked great except
that it doesn't get passed to the second invocation of cgo,
and that's the one that writes the relevant file.

Fixes ARM build on systems with a different dynamic linker
than the one 5l assumes (like Gentoo).

R=golang-dev, minux.ma
CC=golang-dev
https://golang.org/cl/7432048

src/cmd/cgo/main.go
src/cmd/cgo/out.go
src/cmd/go/build.go

index 83104e412c53d2b2c9f9400b69c6e501809ad64f..7adc795de3b1bee340c2cc569921d11c6125e3a8 100644 (file)
@@ -142,6 +142,7 @@ var fset = token.NewFileSet()
 
 var dynobj = flag.String("dynimport", "", "if non-empty, print dynamic import data for that file")
 var dynout = flag.String("dynout", "", "write -dynobj output to this file")
+var dynlinker = flag.Bool("dynlinker", false, "record dynamic linker information in dynimport mode")
 
 // These flags are for bootstrapping a new Go implementation,
 // to generate Go and C headers that match the data layout and
index cb0ab44bdcbb1a897be90ebf228d88d75ec8790e..a126cf17fbb7d810e1eb5e0529eb9cd9149e2ed3 100644 (file)
@@ -163,8 +163,8 @@ func dynimport(obj string) {
        }
 
        if f, err := elf.Open(obj); err == nil {
-               if !*importRuntimeCgo {
-                       // We are runtime/cgo, so emit the cgo_dynamic_linker line.
+               if *dynlinker {
+                       // Emit the cgo_dynamic_linker line.
                        if sec := f.Section(".interp"); sec != nil {
                                if data, err := sec.Data(); err == nil && len(data) > 1 {
                                        // skip trailing \0 in data
index c9172cc98bfd1b2ae92ed1fe9c0b2e71d9bd3016..38fc43ef18dce384d18866400da9064db0500d3b 100644 (file)
@@ -1879,7 +1879,11 @@ func (b *builder) cgo(p *Package, cgoExe, obj string, gccfiles []string) (outGo,
 
        // cgo -dynimport
        importC := obj + "_cgo_import.c"
-       if err := b.run(p.Dir, p.ImportPath, cgoExe, "-objdir", obj, "-dynimport", dynobj, "-dynout", importC); err != nil {
+       cgoflags = []string{}
+       if p.Standard && p.ImportPath == "runtime/cgo" {
+               cgoflags = append(cgoflags, "-dynlinker") // record path to dynamic linker
+       }
+       if err := b.run(p.Dir, p.ImportPath, cgoExe, "-objdir", obj, "-dynimport", dynobj, "-dynout", importC, cgoflags); err != nil {
                return nil, nil, err
        }