How to specify compiler for "gem install"?

How can I specify which compiler should be used for gem install? In Bash CC=gcc gem install ... does not help, because it still uses Solaris Studio on my system.