Skip to content

Commit

Permalink
Set CC as the RbConfig's one
Browse files Browse the repository at this point in the history
To use the same C compiler with the Ruby.
If they are different, it may cause an issue.

For example a FreeBSD environment which has gcc and libiconv from
pkg/ports, which are installed in /usr/local.
The normal Ruby installation uses cc (clang).
But when nokogiri runs extconf.rb, libxml uses gcc by its configure,
and it uses libiconv (-liconv), instead of FreeBSD libc's iconv
because port's gcc sees /usr/local by default.
Then extconf.rb runs have_library('xml2', 'xmlParseDoc', 'libxml/parser.h')
but it fails to find -liconv because extconf.rb's try_compile uses
Ruby's CC (cc) and which doesn't see /usr/local.
  • Loading branch information
nurse committed Apr 12, 2016
1 parent ddd8e1d commit b1eb0e9
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions ext/nokogiri/extconf.rb
Expand Up @@ -364,6 +364,8 @@ def using_system_libraries?
end

RbConfig::MAKEFILE_CONFIG['CC'] = ENV['CC'] if ENV['CC']
# use same c compiler for libxml and libxslt
ENV['CC'] = RbConfig::MAKEFILE_CONFIG['CC']

if defined?(RUBY_ENGINE) && RUBY_ENGINE == 'macruby'
$LIBRUBYARG_STATIC.gsub!(/-static/, '')
Expand Down

0 comments on commit b1eb0e9

Please sign in to comment.