go: Fix gccgo -v on Solaris with ld

The Go testsuite's go.sum file ends in

Couldn't determine version of /var/gcc/regression/master/11.4-gcc-64/build/gcc/gccgo

on Solaris.  It turns out this happens because gccgo -v is confused:

[...]
gcc version 15.0.0 20240531 (experimental) [master a0d60660f2] (GCC)
COMPILER_PATH=./:/usr/ccs/bin/
LIBRARY_PATH=./:/lib/amd64/:/usr/lib/amd64/:/lib/:/usr/lib/
COLLECT_GCC_OPTIONS='-g1' '-B' './' '-v' '-shared-libgcc' '-mtune=generic' '-march=x86-64' '-dumpdir' 'a.'
 ./collect2 -V -M ./libgcc-unwind.map -Qy /usr/lib/amd64/crt1.o ./crtp.o /usr/lib/amd64/crti.o /usr/lib/amd64/values-Xa.o /usr/lib/amd64/values-xpg6.o ./crtbegin.o -L. -L/lib/amd64 -L/usr/lib/amd64 -t -lgcc_s -lgcc -lc -lgcc_s -lgcc ./crtend.o /usr/lib/amd64/crtn.o
ld: Software Generation Utilities - Solaris Link Editors: 5.11-1.3297
Undefined			first referenced
 symbol  			    in file
main                                /usr/lib/amd64/crt1.o
ld: fatal: symbol referencing errors
collect2: error: ld returned 1 exit status

trying to invoke the linker without adding any object file.  This only
happens when Solaris ld is in use.  gccgo passes -t to the linker in
that case, but does it unconditionally, even with -v.

When configured to use GNU ld, gccgo -v is fine instead.

This patch avoids this by restricting the -t to actually linking.

Tested on i386-pc-solaris2.11 and sparc-sun-solaris2.11 (ld and gld).

2024-06-05  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

	gcc/go:
	* gospec.cc (lang_specific_driver) [TARGET_SOLARIS !USE_GLD]: Only
	add -t if linking.
This commit is contained in:
Rainer Orth 2024-06-07 10:14:23 +02:00
parent 9ab90fc627
commit 9fff0be2f8

View file

@ -443,8 +443,11 @@ lang_specific_driver (struct cl_decoded_option **in_decoded_options,
using the GNU linker, the Solaris linker needs an option to not
warn about this. Everything works without this option, but you
get unsightly warnings at link time. */
generate_option (OPT_Wl_, "-t", 1, CL_DRIVER, &new_decoded_options[j]);
j++;
if (library > 0)
{
generate_option (OPT_Wl_, "-t", 1, CL_DRIVER, &new_decoded_options[j]);
j++;
}
#endif
*in_decoded_options_count = j;