Subject: | No way to specify multiple compiler options via extra_compiler_options via the command line |
If I do the following (using the version module from CPAN as my test case):
% perl Build.PL extra_compiler_flags="-arch ppc -arch i386"
and then try to build:
% perl Build
cc -I./vutil -I/System/Library/Perl/5.8.6/darwin-thread-multi-2level/CORE -arch ppc -arch
i386 -c -g -pipe -fno-common -DPERL_DARWIN -no-cpp-precomp -fno-strict-aliasing -I/
usr/local/include -Os -o ./vutil/vutil.o ./vutil/vutil.c
cc1: error: unrecognized command line option "-arch ppc -arch i386"
What is happening is that the string "-arch ppc -arch i386" is being passed as a single
argument to cc which obviously doesn't work.
The issue is, as far as I can tell, that '_construct' in Module::Build::Base is doing the following:
# Convert to arrays
for ('extra_compiler_flags', 'extra_linker_flags') {
$p->{$_} = [ $self->split_like_shell($p->{$_}) ] if exists $p->{$_};
}
which looks good except that extra_compiler_flags isn't populated until the call to
read_config which happens after _construct. If I move that same loop into
Module::Build::Base::resume (and initialize $p of course), then it works as expected (I'm not
proposing that as a solution necessarily, just using it as indication that this does appear to
be the root cause of the problem)
I'm aware that I can work around this by modifying Build.PL and passing extra_compiler_flags
there but I was trying to make this automated and applicable to multiple modules so being
able to control this from the invocation of 'perl Build.PL' would make things much simpler.
Occurs with Module::Build-0.28, perl-5.8.6 on MacOS X (10.4.6)