misc/cgo/testcarchive: avoid writing to GOROOT in tests
misc/cgo/testcarchive: avoid writing to GOROOT in tests

Also add a -testwork flag to facilitate debugging the test itself.

Three of the tests of this package invoked 'go install -i
-buildmode=c-archive' in order to generate an archive as well as
multiple C header files.

Unfortunately, the behavior of the '-i' flag is inappropriately broad
for this use-case: it not only generates the library and header files
(as desired), but also attempts to install a number of (unnecessary)
archive files for transitive dependencies to
GOROOT/pkg/$GOOS_$GOARCH_shared, which may not be writable — for
example, if GOROOT is owned by the root user but the test is being run
by a non-root user.

Instead, for now we generate the header files for transitive dependencies
separately by running 'go tool cgo -exportheader'.

In the future, we should consider how to improve the ergonomics for
generating transitive header files without coupling that to
unnecessary library installation.

Updates #28387
Updates #30316
Updates #35715

Change-Id: I3d483f84e22058561efe740aa4885fc3f26137b5
Reviewed-on: https://go-review.googlesource.com/c/go/+/208117
Run-TryBot: Bryan C. Mills <1c8aad60184261ccede67f5c63a0d2a3bf3c9ff4@google.com>
TryBot-Result: Gobot Gobot <66cb808b70d30c07676d5e946fee83fd561249e5@golang.org>
Reviewed-by: Ian Lance Taylor <87e9c6d529889242b7e184afb632328636553ab4@golang.org>

nawawi/go,CAFxX/go,golang/go,akutz/go,cloudflare/go,golang/go,golang/go,cloudflare/go,akutz/go,nawawi/go,golang/go,CAFxX/go,cloudflare/go,cloudflare/go,cloudflare/go,CAFxX/go,akutz/go,cloudflare/go,nawawi/go,golang/go,akutz/go,akutz/go,nawawi/go,CAFxX/go,CAFxX/go,CAFxX/go,golang/go,CAFxX/go,golang/go,akutz/go,akutz/go,golang/go,akutz/go,nawawi/go,CAFxX/go,cloudflare/go,nawawi/go,nawawi/go,cloudflare/go,nawawi/go