mirror of
https://github.com/golang/go
synced 2024-11-26 18:06:55 -07:00
cmd/compile: define func value symbols at declaration
This is mostly Russ's https://golang.org/cl/12145 but with some extra fixes to account for the fact that function declarations without implementations now break shared libraries, and including my test case. Fixes #11480. Change-Id: Iabdc2934a0378e5025e4e7affadb535eaef2c8f1 Reviewed-on: https://go-review.googlesource.com/12340 Reviewed-by: Ian Lance Taylor <iant@golang.org>
This commit is contained in:
parent
4db074639c
commit
1125cd4997
10
misc/cgo/testshared/src/dep/asm.s
Normal file
10
misc/cgo/testshared/src/dep/asm.s
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
// Copyright 2014 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
//+build !gccgo
|
||||||
|
|
||||||
|
#include "textflag.h"
|
||||||
|
|
||||||
|
TEXT ·ImplementedInAsm(SB),NOSPLIT,$0-0
|
||||||
|
RET
|
5
misc/cgo/testshared/src/dep/gccgo.go
Normal file
5
misc/cgo/testshared/src/dep/gccgo.go
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
//+build gccgo
|
||||||
|
|
||||||
|
package dep
|
||||||
|
|
||||||
|
func ImplementedInAsm() {}
|
5
misc/cgo/testshared/src/dep/stubs.go
Normal file
5
misc/cgo/testshared/src/dep/stubs.go
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
//+build !gccgo
|
||||||
|
|
||||||
|
package dep
|
||||||
|
|
||||||
|
func ImplementedInAsm()
|
@ -1,7 +1,12 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import "dep"
|
import (
|
||||||
|
"dep"
|
||||||
|
"runtime"
|
||||||
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
defer dep.ImplementedInAsm()
|
||||||
|
runtime.GC()
|
||||||
dep.V = dep.F() + 1
|
dep.V = dep.F() + 1
|
||||||
}
|
}
|
||||||
|
@ -199,6 +199,7 @@ func makeclosure(func_ *Node) *Node {
|
|||||||
xfunc.Func.Nname.Name.Funcdepth = func_.Func.Depth
|
xfunc.Func.Nname.Name.Funcdepth = func_.Func.Depth
|
||||||
xfunc.Func.Depth = func_.Func.Depth
|
xfunc.Func.Depth = func_.Func.Depth
|
||||||
xfunc.Func.Endlineno = func_.Func.Endlineno
|
xfunc.Func.Endlineno = func_.Func.Endlineno
|
||||||
|
makefuncsym(xfunc.Func.Nname.Sym)
|
||||||
|
|
||||||
xfunc.Nbody = func_.Nbody
|
xfunc.Nbody = func_.Nbody
|
||||||
xfunc.Func.Dcl = concat(func_.Func.Dcl, xfunc.Func.Dcl)
|
xfunc.Func.Dcl = concat(func_.Func.Dcl, xfunc.Func.Dcl)
|
||||||
|
@ -585,6 +585,10 @@ func funchdr(n *Node) {
|
|||||||
Fatal("funchdr: dclcontext")
|
Fatal("funchdr: dclcontext")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if importpkg == nil && n.Func.Nname != nil {
|
||||||
|
makefuncsym(n.Func.Nname.Sym)
|
||||||
|
}
|
||||||
|
|
||||||
dclcontext = PAUTO
|
dclcontext = PAUTO
|
||||||
markdcl()
|
markdcl()
|
||||||
Funcdepth++
|
Funcdepth++
|
||||||
@ -1489,12 +1493,21 @@ func funcsym(s *Sym) *Sym {
|
|||||||
}
|
}
|
||||||
|
|
||||||
s1 := Pkglookup(s.Name+"·f", s.Pkg)
|
s1 := Pkglookup(s.Name+"·f", s.Pkg)
|
||||||
if s1.Def == nil {
|
|
||||||
s1.Def = newfuncname(s1)
|
|
||||||
s1.Def.Func.Shortname = newname(s)
|
|
||||||
funcsyms = list(funcsyms, s1.Def)
|
|
||||||
}
|
|
||||||
s.Fsym = s1
|
s.Fsym = s1
|
||||||
|
|
||||||
return s1
|
return s1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func makefuncsym(s *Sym) {
|
||||||
|
if isblanksym(s) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if compiling_runtime != 0 && s.Name == "getg" {
|
||||||
|
// runtime.getg() is not a real function and so does
|
||||||
|
// not get a funcsym.
|
||||||
|
return
|
||||||
|
}
|
||||||
|
s1 := funcsym(s)
|
||||||
|
s1.Def = newfuncname(s1)
|
||||||
|
s1.Def.Func.Shortname = newname(s)
|
||||||
|
funcsyms = list(funcsyms, s1.Def)
|
||||||
|
}
|
||||||
|
@ -16,5 +16,4 @@ func setMaxThreads(int) int
|
|||||||
|
|
||||||
// Implemented in package runtime.
|
// Implemented in package runtime.
|
||||||
func readGCStats(*[]time.Duration)
|
func readGCStats(*[]time.Duration)
|
||||||
func enableGC(bool) bool
|
|
||||||
func freeOSMemory()
|
func freeOSMemory()
|
||||||
|
@ -249,7 +249,6 @@ func time_now() (sec int64, nsec int32)
|
|||||||
|
|
||||||
// in asm_*.s
|
// in asm_*.s
|
||||||
// not called directly; definitions here supply type information for traceback.
|
// not called directly; definitions here supply type information for traceback.
|
||||||
func call16(fn, arg unsafe.Pointer, n, retoffset uint32)
|
|
||||||
func call32(fn, arg unsafe.Pointer, n, retoffset uint32)
|
func call32(fn, arg unsafe.Pointer, n, retoffset uint32)
|
||||||
func call64(fn, arg unsafe.Pointer, n, retoffset uint32)
|
func call64(fn, arg unsafe.Pointer, n, retoffset uint32)
|
||||||
func call128(fn, arg unsafe.Pointer, n, retoffset uint32)
|
func call128(fn, arg unsafe.Pointer, n, retoffset uint32)
|
||||||
|
14
src/runtime/stubs32.go
Normal file
14
src/runtime/stubs32.go
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
// Copyright 2015 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// +build 386 arm amd64p32
|
||||||
|
|
||||||
|
package runtime
|
||||||
|
|
||||||
|
import "unsafe"
|
||||||
|
|
||||||
|
// Declarations for runtime services implemented in C or assembly that
|
||||||
|
// are only present on 32 bit systems.
|
||||||
|
|
||||||
|
func call16(fn, arg unsafe.Pointer, n, retoffset uint32)
|
Loading…
Reference in New Issue
Block a user