1
0
mirror of https://github.com/golang/go synced 2024-11-12 05:40:22 -07:00

cmd/cgo: use explicit flag to emit dynamic linker path

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
This commit is contained in:
Russ Cox 2013-03-04 11:23:17 -05:00
parent 7903e3600c
commit 6dc3c9cfdd
3 changed files with 8 additions and 3 deletions

View 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

View 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

View 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
}