Specifying `CC=$(tc-getCC)` before `${RUBY} --disable=did_you_mean -C ${extension%/*} ${extension##*/} --with-cflags="${CFLAGS}" --with-ldflags="${LDFLAGS}" ${RUBY_FAKEGEM_EXTENSION_OPTIONS}` does nothing as the Makefile will always be generated to a constant `CC = (whatever RbConfig::MAKEFILE_CONFIG['CC'] evaluates to)`. It should be done in emake instead: emake CC="$(tc-getCC)" V=1 -C ${extension%/*} Also better quote that `${extension%/*}` as well. This of course applies to extensions that use 'mkmf.rb' only. Also, mkmf.rb has been like this since at least 2.2.10 which existed in ::gentoo before extension building support was added in ruby-fakegem.eclass.
Come to think of it, only specifying CC in emake is wrong or is not enough since an extension may call try_compile or one of its variants during configuration. try_compile needs to use the same compiler specified to emake. The problem is ENV['CC'] is ignored by mkmf.rb and this can be reproduced by: $ CC=clang ruby -e 'puts RbConfig::expand("$(CC)")' gcc This can be hacked with the following command instead: $ CC=clang ruby -e 'RbConfig::CONFIG["CC"] = ENV["CC"]; puts RbConfig::expand("$(CC)")' clang Which I think is just plain illegal.