develooper Front page | perl.perl5.porters | Postings from November 2013

perl verses extension strict compiler options

Thread Next
Dave Mitchell
November 24, 2013 16:41
perl verses extension strict compiler options
Message ID:
I've just been having a look at the way C compiler command-line options
get passed to the C compiler (specifically -Wfoo under gcc) and was
surprised to see that core is treated very differently from extensions
(ext/, dist/. cpan/).

If I've understood right, -W flags which are passed to Configure with
-Accflags eventually end up in config.*, and for extensions (and XS
modules in general), MakeMaker et al extract out these flags using to compile XS code.

On the other hand, compiling the *perl* source uses cflags.SH to test out
the C compiler, and add "by hand" a whole slew of extra more fascist
compiler args to the ones that were originally specified in -Accflags.

This means for example that the perl core is automatically compiled with
-Wdeclaration-after-statement, but stuff under ext/ etc isn't.

So, some questions (mostly hand-wavy).

1. Is the summary above accurate?
2. Is there any way we could change things so that stuff under ext/ (and
probably dist/, but probably not cpan/ and almost certainly not anything
being built by the end user that's been downloaded from cpan) could
*automatically* inherit these stricter flags too?
3. Related to that, is there any way we could enable -Werror (which turns
warnings into errors) on all compiling except under cpan/?

The place I would like to see us end up is that for all stuff under p5p
control, it's compiled with fascist warnings, with warnings being
upgraded to errors. This wouldn't be the case for normal end-use builds,
but for developer builds and smokes (with say a Configure -Dstrict arg) we
get the extra B&D. This wouldn't apply to cpan/ since code under there
isn't ours to fix.

Although arguably the extra fascist flags could make their way into under a different entry (e.g. "strictccflags"), and individual
extension authors would be free to choose whether to enable the extra
flags, perhaps by a 'STRICT' entry in Makefile.PL or equivalent???

Is this a reasonable goal to aim for? Is it viable that we could get
there? Does anyone understand how it could be achieved (and/or be prepared
to do the work)?

And does any of this still apply for non_UNIX builds?

(I understand very little of the perl and cpan build toolchains, which
is why I'm waving my arms hard enough to take off.)

The Enterprise successfully ferries an alien VIP from one place to another
without serious incident.
    -- Things That Never Happen in "Star Trek" #7

Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About