You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
garble/testdata/scripts
Daniel Martí 4c3b90c051 stop loading obfuscated type information from deps
If package P1 imports package P2, P1 needs to know which names from P2
weren't obfuscated. For instance, if P2 declares T2 and does
"reflect.TypeOf(T2{...})", then P2 won't obfuscate the name T2, and
neither should P1.

This information should flow from P2 to P1, as P2 builds before
P1. We do this via obfuscatedTypesPackage; P1 loads the type information
of the obfuscated version of P2, and does a lookup for T2. If T2 exists,
then it wasn't obfuscated.

This mechanism has served us well, but it has downsides:

1) It wastes CPU; we load the type information for the entire package.

2) It's complex; for instance, we need KnownObjectFiles as an extra.

3) It makes our code harder to understand, as we load both the original
   and obfuscated type informaiton.

Instead, we now have each package record what names were not obfuscated
as part of its cachedOuput file. Much like KnownObjectFiles, the map
records incrementally through the import graph, to avoid having to load
cachedOutput files for indirect dependencies.

We shouldn't need to worry about those maps getting large;
we only skip obfuscating declared names in a few uncommon scenarios,
such as the use of reflection or cgo's "//export".

Since go/types is relatively allocation-heavy, and the export files
contain a lot of data, we get a nice speed-up:

	name      old time/op         new time/op         delta
	Build-16          11.5s ± 2%          11.1s ± 3%  -3.77%  (p=0.008 n=5+5)

	name      old bin-B           new bin-B           delta
	Build-16          5.15M ± 0%          5.15M ± 0%    ~     (all equal)

	name      old cached-time/op  new cached-time/op  delta
	Build-16          375ms ± 3%          341ms ± 6%  -8.96%  (p=0.008 n=5+5)

	name      old sys-time/op     new sys-time/op     delta
	Build-16          283ms ±17%          289ms ±13%    ~     (p=0.841 n=5+5)

	name      old user-time/op    new user-time/op    delta
	Build-16          687ms ± 6%          664ms ± 7%    ~     (p=0.548 n=5+5)

Fixes #456.
Updates #475.
2 years ago
..
asm.txt CI: test on GOARCH=386 3 years ago
basic.txt fix binsubstr calls to not prepare for a regexp 3 years ago
cgo.txt stop loading obfuscated type information from deps 2 years ago
crossbuild.txt only list missing packages when obfuscating the runtime 3 years ago
debugdir.txt avoid build ID mismatches when using -debugdir 3 years ago
embed.txt deprecate using GOPRIVATE in favor of GOGARBLE (#427) 3 years ago
gogarble.txt only list missing packages when obfuscating the runtime 3 years ago
goversion.txt drop support for Go 1.16.x 3 years ago
help.txt give a useful error for "garble build -tiny" 3 years ago
implement.txt deprecate using GOPRIVATE in favor of GOGARBLE (#427) 3 years ago
imports.txt handle --long build flags properly 3 years ago
init.txt drop support for Go 1.16.x 3 years ago
ldflags.txt avoid obfuscating literals set via -ldflags=-X 3 years ago
linkname.txt deprecate using GOPRIVATE in favor of GOGARBLE (#427) 3 years ago
literals.txt support GOGARBLE=* with -literals again 3 years ago
modinfo.txt testdata: adjust for newer Go 1.18 tip version 3 years ago
plugin.txt deprecate using GOPRIVATE in favor of GOGARBLE (#427) 3 years ago
position.txt deprecate using GOPRIVATE in favor of GOGARBLE (#427) 3 years ago
reflect.txt stop loading obfuscated type information from deps 2 years ago
reverse.txt testdata: make pointer regexp less prone to flakes 3 years ago
seed.txt deprecate using GOPRIVATE in favor of GOGARBLE (#427) 3 years ago
syntax.txt testdata: ensure go:noinline works via runtime.Callers 3 years ago
test.txt drop support for Go 1.16.x 3 years ago
tiny.txt deprecate using GOPRIVATE in favor of GOGARBLE (#427) 3 years ago