It's been a while, but I have compiled Perl and many modules on various versions of Solaris and SunOS, using both gcc and Suns own compiler, and usually had no problems.
But do yourself a favour, and don't mix compilers. Either compile everything with gcc, or with the native compiler.