cmd/go: When linking with gccgo pass .a files in the order they are discovered
cmd/go: When linking with gccgo pass .a files in the order they are discovered

Under some circumstances linking a test binary with gccgo can fail, because
the installed version of the library ends up before the version built for the
test on the linker command line.

This admittedly slightly hackish fix fixes this by putting the library archives
on the linker command line in the order that a pre-order depth first traversal
of the dependencies gives them, which has the side effect of always putting the
version of the library built for the test first.

Fixes issue 6768

LGTM=rsc
R=golang-codereviews, minux.ma, gobot, rsc, dave
CC=golang-codereviews
https://codereview.appspot.com/28050043

Committer: Dave Cheney <bfcdf3e6ca6cef45543bfbb57509c92aec9a39fb@cheney.net>

wesolows/golang-old,wesolows/golang,wesolows/golang-old,firebitsbr/golang-old,wesolows/golang-old,wesolows/golang,wesolows/golang,firebitsbr/golang-old,wesolows/golang,firebitsbr/golang-old,firebitsbr/golang-old,wesolows/golang-old,wesolows/golang-old,firebitsbr/golang-old,wesolows/golang,wesolows/golang,wesolows/golang,firebitsbr/golang-old,firebitsbr/golang-old,wesolows/golang-old,wesolows/golang-old,firebitsbr/golang-old