From 4836e28ac0482183a3a6af88ee4295ffdbc94f62 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Mon, 21 Dec 2020 01:36:15 -0500 Subject: [dev.regabi] cmd/compile: separate noder more cleanly Separate embed, cgo pragmas, and Main trackScopes variable from noder more cleanly. This lets us split embed and noder into new packages. It also assumes that the local embedded variables will be removed and deletes them now for simplicity. Change-Id: I9638bcc2c5f0e76440de056c6285b6aa2f73a00d Reviewed-on: https://go-review.googlesource.com/c/go/+/279299 Trust: Russ Cox Run-TryBot: Russ Cox TryBot-Result: Go Bot Reviewed-by: Matthew Dempsky --- src/cmd/compile/internal/gc/main.go | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'src/cmd/compile/internal/gc/main.go') diff --git a/src/cmd/compile/internal/gc/main.go b/src/cmd/compile/internal/gc/main.go index 545491daa1..45880c5cde 100644 --- a/src/cmd/compile/internal/gc/main.go +++ b/src/cmd/compile/internal/gc/main.go @@ -205,8 +205,6 @@ func Main(archInit func(*Arch)) { } } - trackScopes = base.Flag.Dwarf - Widthptr = thearch.LinkArch.PtrSize Widthreg = thearch.LinkArch.RegSize @@ -226,6 +224,7 @@ func Main(archInit func(*Arch)) { timings.Start("fe", "parse") lines := parseFiles(flag.Args()) + cgoSymABIs() timings.Stop() timings.AddEvent(int64(lines), "lines") @@ -477,6 +476,20 @@ func Main(archInit func(*Arch)) { } } +func cgoSymABIs() { + // The linker expects an ABI0 wrapper for all cgo-exported + // functions. + for _, prag := range Target.CgoPragmas { + switch prag[0] { + case "cgo_export_static", "cgo_export_dynamic": + if symabiRefs == nil { + symabiRefs = make(map[string]obj.ABI) + } + symabiRefs[prag[1]] = obj.ABI0 + } + } +} + // numNonClosures returns the number of functions in list which are not closures. func numNonClosures(list []*ir.Func) int { count := 0 -- cgit v1.2.3-54-g00ecf