return
}
- // Find cgo_export symbols. They are roots in the deadcode pass.
- for _, f := range directives {
- switch f[0] {
- case "cgo_export_static", "cgo_export_dynamic":
- if len(f) < 2 || len(f) > 3 {
- continue
- }
- local := f[1]
- switch ctxt.BuildMode {
- case BuildModeCShared, BuildModeCArchive, BuildModePlugin:
- if local == "main" {
- continue
- }
- }
- local = expandpkg(local, pkg)
- if f[0] == "cgo_export_static" {
- ctxt.cgo_export_static[local] = true
- } else {
- ctxt.cgo_export_dynamic[local] = true
- }
- }
- }
-
// Record the directives. We'll process them later after Symbols are created.
ctxt.cgodata = append(ctxt.cgodata, cgodata{file, pkg, directives})
}
return
}
+ // Mark exported symbols and also add them to
+ // the lists used for roots in the deadcode pass.
if f[0] == "cgo_export_static" {
l.SetAttrCgoExportStatic(s, true)
+ ctxt.cgo_export_static[local] = true
} else {
l.SetAttrCgoExportDynamic(s, true)
+ ctxt.cgo_export_dynamic[local] = true
}
+
continue
case "cgo_dynamic_linker":
// Logging an error means that on exit cmd/link will delete any
// output file and return a non-zero error code.
//
-// TODO: remove. Use ctxt.Errof instead.
+// TODO: remove. Use ctxt.Errorf instead.
// All remaining calls use nil as first arg.
func Errorf(dummy *int, format string, args ...interface{}) {
format += "\n"