Commit bca096a5 authored by Kirill Smelkov's avatar Kirill Smelkov

.

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