Sorry for the late reply, here a few hints :
I wouldn't recommend using SFW GCC with pkgsrc. It's now pretty old ( GCC 3.4.3).
You might want to use opencsw to get GCC but their "most up to date" GCC is gcc5.5.0. So it might work for a time but I guess you will eventually face similar issues like SFW GCC.
Like Sad Clouds said, you might want to build your own GCC. GCC9 is the last version to support Solaris 10 SPARC (And maybe SPARC in general).
It only works with 32bit bootstrap. I'll eventually provide GCC9 with support with 64bits.
/usr/bin/bash is pretty much broken. And If I remember correctly /bin/sh is pretty much broken too. Use anything else. If you wish/can build and use pkgsrc bash instead of the one provided in Solaris.