testmain.exp: link against GOLIBS

Patch by Maciej W. Rozycki.

Change-Id: I373d19bbcc0d160065e1453d613c0473a5adb0f9
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/207458
Reviewed-by: Ian Lance Taylor <iant@golang.org>
diff --git a/libgo/testsuite/libgo.testmain/testmain.exp b/libgo/testsuite/libgo.testmain/testmain.exp
index 0b887ac..6dd5445 100644
--- a/libgo/testsuite/libgo.testmain/testmain.exp
+++ b/libgo/testsuite/libgo.testmain/testmain.exp
@@ -47,7 +47,11 @@
     regsub $gluefile $object_files "" object_files
 }
 
-set comp_output [go_target_compile "$object_files _testmain.go" \
+set golibs ""
+if [info exists env(GOLIBS)] {
+    set golibs "$env(GOLIBS)"
+}
+set comp_output [go_target_compile "$object_files _testmain.go $golibs" \
 			 "./a.exe" "executable" $options]
 if ![ string match "" $comp_output ] {
     verbose -log $comp_output