wayneeseguin/rvm — Issue #660: Using clang results in invalid flags added to rubies/ruby-<v>/config
Author: rtyler
Created: 2011-12-26 19:54:49+00:00
State: open

I noticed this issue while trying to build native extensions (in this case EventMachine):

```
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

/home/tyler/.rvm/rubies/ruby-1.9.3-p0/bin/ruby extconf.rb
checking for rb_trap_immediate in ruby.h,rubysig.h... no
checking for rb_thread_blocking_region()... yes
checking for inotify_init() in sys/inotify.h... yes
checking for writev() in sys/uio.h... yes
checking for rb_thread_check_ints()... yes
checking for rb_time_new()... yes
checking for sys/event.h... no
checking for epoll_create() in sys/epoll.h... yes
creating Makefile

make
compiling em.cpp
cc1plus: warning: command line option ‘-Wdeclaration-after-statement’ is valid for C/ObjC but not for C++ [enabled by default]
cc1plus: error: unrecognized command line option ‘-Wshorten-64-to-32’
cc1plus: warning: command line option ‘-Wimplicit-function-declaration’ is valid for C/ObjC but not for C++ [enabled by default]
make: *** [em.o] Error 1
```

After many hours of tracking down the issue to my use of `CC=clang` on my Linux system.

Unlike Mac OS X, the compilers on Linux don't have this extra `-Wshorten-64-to-32` warning flag patched in. Somehow my use of `clang(1)` causes rvm to falsely register that this flag should be present and adds it to the `~/.rvm/rubies/ruby-1.9.3-p0/config` entries for `CFLAGS` and `CXXFLAGS`

Returning my `$CC` variable to `gcc(1)` and rebuilding the Ruby seems to fix the issue.