Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 911178

Summary: ruby-fakegem.eclass: CC=$(tc-getCC) is ignored.
Product: Gentoo Linux Reporter: konsolebox <konsolebox>
Component: EclassesAssignee: Gentoo Ruby Team <ruby>
Status: UNCONFIRMED ---    
Severity: normal CC: sam
Priority: Normal    
Version: unspecified   
Hardware: All   
OS: Linux   
Whiteboard:
Package list:
Runtime testing required: ---

Description konsolebox 2023-07-25 00:02:33 UTC
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.
Comment 1 konsolebox 2023-07-25 00:34:45 UTC
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.