in reply to How to make an XS module with a different C compiler?

The Makefile that ExtUtils::MakeMaker creates (and probably Module::Build as well, although I'm less familiar with it) uses whatever the Config module's $Config{cc} says use. This is whatever compiler was used to build your perl executable. You can probably override it with make CC=/usr/local/.../cc on the command line, but keep in mind that there's probably a whole can of monkeys hiding underneath waiting to bite you in the tuckus if the compilers don't play nice together (different link expectations, expecting different symbols to be defined in something like crt0.o, yadda yadda yadda).

Replies are listed 'Best First'.
Re^2: How to make an XS module with a different C compiler?
by Errto (Vicar) on Jan 18, 2005 at 02:05 UTC
    Regarding the monkeys, I haven't played with this much but I'm wondering: if this is true, should it not also be true that one can only safely compile XS modules using the same compiler and settings that Perl itself was built with on one's machine?

      It's not that you have to use the same compiler, it's just more likely that you're going to have problems if you don't. Just be sure to have bribes handy for your local C guru and/or sysadmin to get them to lay hands on things when they break.

Re^2: How to make an XS module with a different C compiler?
by mifflin (Curate) on Jan 18, 2005 at 01:56 UTC
    So, are you telling me that if I have two vendors that I get libraries from and both will only give me the .so files and each choose to use a different compilier to build their product that I would not be able to use one installation of Perl to access them because I would have to choose one of those compiliers to build my Perl?

      Maybe yes, maybe no. It all depends on the OS, the compiler used, the phase of the moon. You may get lucky and figure out what flags are causing cc to choke (-fpic is a gcc-ism for instance that's causing problems in your output below).

      It's even worse with C++ though (there's no standard for name mangling, for example, so two different compilers can make completely different symbols in the output object for the same int foo( char *bar, double& baz ).

Re^2: How to make an XS module with a different C compiler?
by mifflin (Curate) on Jan 18, 2005 at 02:06 UTC
    I tried your suggestion and I do get lots of errors.
    Are these the types of errors that will "bite me in the tukas" ?
    erickn@isfe:/home/erickn/ACE> perl Makefile.PL Checking if your kit is complete... Looks good Writing Makefile for ACE erickn@isfe:/home/erickn/ACE> make CC=/usr/local/studio8/SUNWspro/bin/ +cc cp ACE.pm blib/lib/ACE.pm /home/utils/perl/bin/perl /home/utils/perl/lib/perl5/5.8.0/ExtUtils/xs +ubpp -typemap /home/utils/perl/lib/perl5/5.8.0/ExtUtils/typemap -typ +emap typemap ACE.xs > ACE.xsc && mv ACE.xsc ACE.c /usr/local/studio8/SUNWspro/bin/cc -c -I/opt/Ace750cRev1/postware/ace +lib -I/home/utils/perl/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BI +TS=64 -O -DVERSION=\"3.00\" -DXS_VERSION=\"3.00\" -fPIC "-I/home/ +utils/perl/lib/perl5/5.8.0/sun4-solaris/CORE" -DSolaris64 ACE.c cc: Warning: illegal option -fPIC "/home/utils/perl/lib/perl5/5.8.0/sun4-solaris/CORE/perlio.h", line 20 +9: syntax error before or at: __attribute__ "/home/utils/perl/lib/perl5/5.8.0/sun4-solaris/CORE/perlio.h", line 20 +9: warning: old-style declaration or incorrect type for: __attribute_ +_ "/home/utils/perl/lib/perl5/5.8.0/sun4-solaris/CORE/perlio.h", line 20 +9: warning: syntax error: empty declaration "/home/utils/perl/lib/perl5/5.8.0/sun4-solaris/CORE/perlio.h", line 26 +9: syntax error before or at: __attribute__ "/home/utils/perl/lib/perl5/5.8.0/sun4-solaris/CORE/perlio.h", line 26 +9: warning: old-style declaration or incorrect type for: __attribute_ +_ "/home/utils/perl/lib/perl5/5.8.0/sun4-solaris/CORE/perlio.h", line 26 +9: identifier redefined: __attribute__ current : function() returning int previous: function() returning int : "/home/utils/perl/lib/per +l5/5.8.0/sun4-solaris/CORE/perlio.h", line 209 "/home/utils/perl/lib/perl5/5.8.0/sun4-solaris/CORE/perlio.h", line 26 +9: warning: syntax error: empty declaration "/home/utils/perl/lib/perl5/5.8.0/sun4-solaris/CORE/perlio.h", line 27 +3: syntax error before or at: __attribute__ "/home/utils/perl/lib/perl5/5.8.0/sun4-solaris/CORE/perlio.h", line 27 +3: warning: old-style declaration or incorrect type for: __attribute_ +_ "/home/utils/perl/lib/perl5/5.8.0/sun4-solaris/CORE/perlio.h", line 27 +3: identifier redefined: __attribute__ current : function() returning int previous: function() returning int : "/home/utils/perl/lib/per +l5/5.8.0/sun4-solaris/CORE/perlio.h", line 269 "/home/utils/perl/lib/perl5/5.8.0/sun4-solaris/CORE/perlio.h", line 27 +3: warning: syntax error: empty declaration "/home/utils/perl/lib/perl5/5.8.0/sun4-solaris/CORE/proto.h", line 98: + syntax error before or at: __attribute__ "/home/utils/perl/lib/perl5/5.8.0/sun4-solaris/CORE/proto.h", line 98: + warning: old-style declaration or incorrect type for: __attribute__ "/home/utils/perl/lib/perl5/5.8.0/sun4-solaris/CORE/proto.h", line 98: + identifier redefined: __attribute__ current : function() returning int previous: function() returning int : "/home/utils/perl/lib/per +l5/5.8.0/sun4-solaris/CORE/perlio.h", line 273 "/home/utils/perl/lib/perl5/5.8.0/sun4-solaris/CORE/proto.h", line 102 +: warning: syntax error: empty declaration "/home/utils/perl/lib/perl5/5.8.0/sun4-solaris/CORE/proto.h", line 103 +: syntax error before or at: __attribute__ "/home/utils/perl/lib/perl5/5.8.0/sun4-solaris/CORE/proto.h", line 103 +: warning: old-style declaration or incorrect type for: __attribute__ "/home/utils/perl/lib/perl5/5.8.0/sun4-solaris/CORE/proto.h", line 103 +: identifier redefined: __attribute__ current : function() returning int previous: function() returning int : "/home/utils/perl/lib/per +l5/5.8.0/sun4-solaris/CORE/proto.h", line 98 "/home/utils/perl/lib/perl5/5.8.0/sun4-solaris/CORE/proto.h", line 103 +: warning: syntax error: empty declaration "/home/utils/perl/lib/perl5/5.8.0/sun4-solaris/CORE/proto.h", line 503 +: syntax error before or at: __attribute__ "/home/utils/perl/lib/perl5/5.8.0/sun4-solaris/CORE/proto.h", line 503 +: warning: old-style declaration or incorrect type for: __attribute__ "/home/utils/perl/lib/perl5/5.8.0/sun4-solaris/CORE/proto.h", line 503 +: identifier redefined: __attribute__ current : function() returning int previous: function() returning int : "/home/utils/perl/lib/per +l5/5.8.0/sun4-solaris/CORE/proto.h", line 103 "/home/utils/perl/lib/perl5/5.8.0/sun4-solaris/CORE/proto.h", line 503 +: warning: syntax error: empty declaration "/home/utils/perl/lib/perl5/5.8.0/sun4-solaris/CORE/proto.h", line 504 +: syntax error before or at: __attribute__ "/home/utils/perl/lib/perl5/5.8.0/sun4-solaris/CORE/proto.h", line 504 +: warning: old-style declaration or incorrect type for: __attribute__ "/home/utils/perl/lib/perl5/5.8.0/sun4-solaris/CORE/proto.h", line 504 +: identifier redefined: __attribute__ current : function() returning int previous: function() returning int : "/home/utils/perl/lib/per +l5/5.8.0/sun4-solaris/CORE/proto.h", line 503 "/home/utils/perl/lib/perl5/5.8.0/sun4-solaris/CORE/proto.h", line 504 +: warning: syntax error: empty declaration cc: acomp failed for ACE.c *** Error code 2 make: Fatal error: Command failed for target `ACE.o'