The default gcc that comes with Solaris support 64 bits compiling (tested on solaris 10).
/usr/sfw/bin/gcc
gcc version 3.4.3 (csl-sol210-3_4-branch+sol_rpath)

You just need to pass the -m64 argument.
This works on sparc64 but also on amd64.

For example to compile lsof 4.77 just export CC="gcc -m64"

In the case of lsof you also need a patch for Solaris > 10-0606:
--- dialects/sun/machine.h Mon Jul 10 19:59:17 2006 ***************
*** 76,81 ****
- 76,82 --

# if solaris>=80000
#include <sys/wait.h>
+ #include <sys/types32.h>
#define _KERNEL 1
#include <netinet/in.h>
#undef _KERNEL