Tech Tip: Overriding the C compiler with ExtUtils::MakeMaker

In order to override the C compiler with ExtUtils::MakeMaker, one can do something like:

perl Makefile.PL CC=/usr/bin/clang

Which will make the "CC" variable in the generated makefile be set to /usr/bin/clang instead of the default. Apparently, setting the CC environment variable does not work like it does with CMake.

Thanks to Sisyphus for the tip.

1 Comment

If you want to permanently use this setting put it in the $ENV{PERL_MM_OPT}. Module::Build has also its own $ENV{PERL_MB_OPT}.

This feature is used in particular by local::lib to change the install directory for CPAN modules.

Leave a comment

About Shlomi Fish

user-pic An Israeli software developer, essayist, and writer, and an enthusiast of open/free software and cultural works. I've been working with Perl since 1996.