Commit bca096a5 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent b0acbea8
......@@ -5,7 +5,7 @@ package server
import (
"lab.nexedi.com/kirr/neo/go/xcommon/tracing"
"unsafe"
_ "unsafe"
"lab.nexedi.com/kirr/neo/go/neo"
)
......
......@@ -745,7 +745,6 @@ func tracegen1(P *Program, tpkg *Package, pkgdir string, kind string) error {
prologue.emit("// code generated for tracepoints")
prologue.emit("\nimport (")
prologue.emit("\t%q", "lab.nexedi.com/kirr/neo/go/xcommon/tracing")
prologue.emit("\t%q", "unsafe")
// pkgpaths of all packages needed for used types
needPkg := StrSet{}
......@@ -757,6 +756,7 @@ func tracegen1(P *Program, tpkg *Package, pkgdir string, kind string) error {
// code for trace:event definitions
for _, event := range tpkg.Eventv {
needPkg.Add("unsafe") // used in tr
needPkg.Add(event.NeedPkgv()...)
err = traceEventCodeTmpl.Execute(text, event)
if err != nil {
......@@ -826,6 +826,14 @@ func tracegen1(P *Program, tpkg *Package, pkgdir string, kind string) error {
}
// finish prologue with needed imports
if !needPkg.Has("unsafe") {
// we need it anyway because go:linkname is not allowed without unsafe
prologue.emit("\t_ %q", "unsafe")
} else {
prologue.emit("\t%q", "unsafe")
needPkg.Delete("unsafe")
}
needPkg.Delete(tpkg.Pkgi.Pkg.Path()) // our pkg - no need to import
needPkgv := needPkg.Itemv()
if len(needPkgv) > 0 {
......
......@@ -5,7 +5,7 @@ package pkg3
import (
"lab.nexedi.com/kirr/neo/go/xcommon/tracing"
"unsafe"
_ "unsafe"
aaa1 "a/pkg1"
"net/url"
......
......@@ -5,7 +5,7 @@ package pkg3_test
import (
"lab.nexedi.com/kirr/neo/go/xcommon/tracing"
"unsafe"
_ "unsafe"
)
// traceimport: "b/pkg2"
......
......@@ -49,6 +49,11 @@ func (s StrSet) Delete(item string) {
delete(s, item)
}
func (s StrSet) Has(item string) bool {
_, has := s[item]
return has
}
// Itemv returns ordered slice of set items
func (s StrSet) Itemv() []string {
itemv := make([]string, 0, len(s))
......
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