yuki-kimoto / Rstats

R language build on Perl
6 stars 1 forks source link

Should not hardcode g++ #5

Open eserte opened 9 years ago

eserte commented 9 years ago

Compiling fails on FreeBSD 10:

g++ -c  -I. -I./Rstats_lib/include  -DHAS_FPSETMASK -DHAS_FLOATINGPOINT_H -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include -D_FORTIFY_SOURCE=2 -O3    -DVERSION=\"0.0145\"  -DXS_VERSION=\"0.0145\" -DPIC -fPIC "-I/usr/perl5.23.3p/lib/5.23.3/amd64-freebsd/CORE"  -o Rstats.o Rstats.c
g++: not found

Problem is that FreeBSD 10 does not ship anymore gcc, but clang instead. Best solution probably is to not use "g++" here, but "c++" which works for both, gcc and clang systems.

yuki-kimoto commented 9 years ago

thanks, I try to change g++ to c++

yuki-kimoto commented 9 years ago

Windows MinGW have only g++. What is best way?

eserte commented 9 years ago

I see that you try to pick the right c++ compiler depending on the ccname config value: https://github.com/yuki-kimoto/Rstats/blob/master/Makefile.PL#L10 Unfortunately, ccname is gcc even on FreeBSD 10. Looking at perl's Configure script it seems that it's just checked whether __GNUC__ is defined (and __INTEL_COMPILER is undefined) to set ccname=gcc. But the __GNUC__ macro is also defined in clang, so ccname is here also set to gcc!

A possible approach is to define specific operating system rules. So you could do something like

$cc = $^O eq 'MSWin32' ? $cpp_compilers->{$Config{ccname}} : 'c++';

Or the other way around:

$cc = $^O eq 'freebsd' ? 'c++' : $cpp_compilers->{$Config{ccname}};
yuki-kimoto commented 9 years ago

thanks, I try this.

eserte commented 9 years ago

Compilation now works on FreeBSD 10.1 with clang++. But for some reason tests are failing here, and just with clang, see http://analysis.cpantesters.org/solved?distv=Rstats-0.0148#conf%3Agccversion This is somewhat surprising, usually clang-compiled stuff works as well as gcc-compiled things...