Commit 6dc3c9cf authored by Russ Cox's avatar Russ Cox

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
parent 7903e360
......@@ -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
......
......@@ -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
......
......@@ -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
}
......
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