yajl-ruby icon indicating copy to clipboard operation
yajl-ruby copied to clipboard

Get rid of gcc-ism

Open unak opened this issue 12 years ago • 2 comments

unak avatar Apr 23 '13 11:04 unak

this is also a problem with AIX and Solaris

lamont-granquist avatar May 09 '13 22:05 lamont-granquist

something like this works for me on AIX with the IBM compiler:

if RbConfig::MAKEFILE_CONFIG['CC'] =~ /gcc/
  $CFLAGS << ' -Wall -funroll-loops'
  $CFLAGS << ' -Wextra -O0 -ggdb3' if ENV['DEBUG']
end

that variable is set to the path of the compiler which is why i used a regex. you could probably use File.basename to drop the path and match ^gcc instead, but you need to worry about gcc invoked as /blah/blah/gcc4, etc.

could also do something more involved like invoke the compiler with --version and see if the output looks like gcc...

here's the File.basename version:

if File.basename(RbConfig::MAKEFILE_CONFIG['CC']) =~ /^gcc/
  $CFLAGS << ' -Wall -funroll-loops'
  $CFLAGS << ' -Wextra -O0 -ggdb3' if ENV['DEBUG']
end

lamont-granquist avatar May 09 '13 22:05 lamont-granquist