From f0d8175b3e2ce217a75e5ee6370594dd30be56a8 Mon Sep 17 00:00:00 2001 From: Alan Donovan Date: Mon, 6 Apr 2015 12:22:14 -0400 Subject: [PATCH] oracle: skip cgo processing for queries that don't need SSA/PTA This makes type-based queries faster and more robust because they needn't invoke a C compiler, at the cost of worse results in/near .go files that import "C". It's particularly important for "referrers" since a refererrs query on a name from the standard library can load every package in the workspace. Fixes issue 10347 Change-Id: I2f65474ce963de5c0897ba67eeb26290dd449cf1 Reviewed-on: https://go-review.googlesource.com/8493 Reviewed-by: David Crawshaw --- oracle/oracle.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/oracle/oracle.go b/oracle/oracle.go index 0a30ad38..4cdd2eca 100644 --- a/oracle/oracle.go +++ b/oracle/oracle.go @@ -278,6 +278,9 @@ func parseQueryPos(lprog *loader.Program, posFlag string, needExact bool) (*quer // allowErrors causes type errors to be silently ignored. // (Not suitable if SSA construction follows.) func allowErrors(lconf *loader.Config) { + ctxt := *lconf.Build // copy + ctxt.CgoEnabled = false + lconf.Build = &ctxt lconf.AllowErrors = true lconf.TypeChecker.Error = func(err error) {} }