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.