Updated Branches: refs/heads/chaz_compiler_flags f332e0895 -> 608794946
Migrate more compiler flag probing to Charmonizer. When possible, move probing for compiler flags which are used on core source files out of the Perl build and into Charmonizer so that the probing logic can be reused across other host builds. Sometimes flags need to be duplicated rather than migrated -- for instance, the "/TP" to make MSVC compile as C++ is still mandatory because of our headers (though not because of the source content that goes into $module.xs). Project: http://git-wip-us.apache.org/repos/asf/lucy/repo Commit: http://git-wip-us.apache.org/repos/asf/lucy/commit/60879494 Tree: http://git-wip-us.apache.org/repos/asf/lucy/tree/60879494 Diff: http://git-wip-us.apache.org/repos/asf/lucy/diff/60879494 Branch: refs/heads/chaz_compiler_flags Commit: 6087949469db783f08ce80853a001353cf69d6a9 Parents: f332e08 Author: Marvin Humphrey <[email protected]> Authored: Thu Dec 13 18:16:41 2012 -0800 Committer: Marvin Humphrey <[email protected]> Committed: Thu Dec 13 18:21:42 2012 -0800 ---------------------------------------------------------------------- .../compiler/perl/lib/Clownfish/CFC/Perl/Build.pm | 5 +--- .../perl/lib/Clownfish/CFC/Perl/Build/Charmonic.pm | 5 +--- clownfish/runtime/common/charmonizer.c | 15 ++++++++++++++ clownfish/runtime/common/charmonizer.main | 15 ++++++++++++++ common/charmonizer.c | 16 ++++++++++++++- common/charmonizer.main | 16 ++++++++++++++- 6 files changed, 62 insertions(+), 10 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/lucy/blob/60879494/clownfish/compiler/perl/lib/Clownfish/CFC/Perl/Build.pm ---------------------------------------------------------------------- diff --git a/clownfish/compiler/perl/lib/Clownfish/CFC/Perl/Build.pm b/clownfish/compiler/perl/lib/Clownfish/CFC/Perl/Build.pm index 7f21b39..19ada50 100644 --- a/clownfish/compiler/perl/lib/Clownfish/CFC/Perl/Build.pm +++ b/clownfish/compiler/perl/lib/Clownfish/CFC/Perl/Build.pm @@ -59,10 +59,7 @@ sub new { my $self = shift->SUPER::new( @_ ); my $extra_ccflags = $self->extra_compiler_flags; - if ( $self->config('gccversion') ) { - push @$extra_ccflags, qw( -std=gnu99 -D_GNU_SOURCE ); - } - elsif ( $self->config('cc') =~ /^cl\b/ ) { + if ( $self->config('cc') =~ /^cl\b/ ) { # Compile as C++ under MSVC. push @$extra_ccflags, qw( -TP -D_CRT_SECURE_NO_WARNINGS -D_SCL_SECURE_NO_WARNINGS http://git-wip-us.apache.org/repos/asf/lucy/blob/60879494/clownfish/compiler/perl/lib/Clownfish/CFC/Perl/Build/Charmonic.pm ---------------------------------------------------------------------- diff --git a/clownfish/compiler/perl/lib/Clownfish/CFC/Perl/Build/Charmonic.pm b/clownfish/compiler/perl/lib/Clownfish/CFC/Perl/Build/Charmonic.pm index d35b1e6..8c5843c 100644 --- a/clownfish/compiler/perl/lib/Clownfish/CFC/Perl/Build/Charmonic.pm +++ b/clownfish/compiler/perl/lib/Clownfish/CFC/Perl/Build/Charmonic.pm @@ -79,10 +79,7 @@ sub ACTION_charmony { if ( !$self->config('usethreads') ) { push @command, '--disable-threads'; } - push @command, - '--', - $self->config('ccflags'), - map { _quotify($_) } @{ $self->extra_compiler_flags }; + push @command, ( '--', $self->config('ccflags') ); if ( $ENV{CHARM_VALGRIND} ) { unshift @command, "valgrind", "--leak-check=yes"; } http://git-wip-us.apache.org/repos/asf/lucy/blob/60879494/clownfish/runtime/common/charmonizer.c ---------------------------------------------------------------------- diff --git a/clownfish/runtime/common/charmonizer.c b/clownfish/runtime/common/charmonizer.c index ef8aedc..8e23906 100644 --- a/clownfish/runtime/common/charmonizer.c +++ b/clownfish/runtime/common/charmonizer.c @@ -4783,6 +4783,21 @@ S_add_compiler_flags(struct chaz_CLIArgs *args) { "-Wno-variadic-macros " ); } + + /* Only core source files require this -- not our headers and + * autogenerated files. */ + chaz_CC_add_extra_cflags("-std=gnu99 -D_GNU_SOURCE"); + } + else if (chaz_Probe_compiler_is_msvc()) { + /* Compile as C++ under MSVC. */ + chaz_CC_add_extra_cflags("/TP"); + + /* Thwart stupid warnings. */ + chaz_CC_add_extra_cflags("-D_CRT_SECURE_NO_WARNINGS"); + chaz_CC_add_extra_cflags("-D_SCL_SECURE_NO_WARNINGS"); + + /* Redefine 'for' to fix broken 'for' scoping under MSVC6. */ + chaz_CC_add_extra_cflags("-Dfor=\"if(0);else for\""); } } http://git-wip-us.apache.org/repos/asf/lucy/blob/60879494/clownfish/runtime/common/charmonizer.main ---------------------------------------------------------------------- diff --git a/clownfish/runtime/common/charmonizer.main b/clownfish/runtime/common/charmonizer.main index 4ffef3b..56c83a0 100644 --- a/clownfish/runtime/common/charmonizer.main +++ b/clownfish/runtime/common/charmonizer.main @@ -51,6 +51,21 @@ S_add_compiler_flags(struct chaz_CLIArgs *args) { "-Wno-variadic-macros " ); } + + /* Only core source files require this -- not our headers and + * autogenerated files. */ + chaz_CC_add_extra_cflags("-std=gnu99 -D_GNU_SOURCE"); + } + else if (chaz_Probe_compiler_is_msvc()) { + /* Compile as C++ under MSVC. */ + chaz_CC_add_extra_cflags("/TP"); + + /* Thwart stupid warnings. */ + chaz_CC_add_extra_cflags("-D_CRT_SECURE_NO_WARNINGS"); + chaz_CC_add_extra_cflags("-D_SCL_SECURE_NO_WARNINGS"); + + /* Redefine 'for' to fix broken 'for' scoping under MSVC6. */ + chaz_CC_add_extra_cflags("-Dfor=\"if(0);else for\""); } } http://git-wip-us.apache.org/repos/asf/lucy/blob/60879494/common/charmonizer.c ---------------------------------------------------------------------- diff --git a/common/charmonizer.c b/common/charmonizer.c index ea65d94..bf84c96 100644 --- a/common/charmonizer.c +++ b/common/charmonizer.c @@ -4782,6 +4782,21 @@ S_add_compiler_flags(struct chaz_CLIArgs *args) { "-Wno-variadic-macros " ); } + + /* Only core source files require this -- not our headers and + * autogenerated files. */ + chaz_CC_add_extra_cflags("-std=gnu99 -D_GNU_SOURCE"); + } + else if (chaz_Probe_compiler_is_msvc()) { + /* Compile as C++ under MSVC. */ + chaz_CC_add_extra_cflags("/TP"); + + /* Thwart stupid warnings. */ + chaz_CC_add_extra_cflags("-D_CRT_SECURE_NO_WARNINGS"); + chaz_CC_add_extra_cflags("-D_SCL_SECURE_NO_WARNINGS"); + + /* Redefine 'for' to fix broken 'for' scoping under MSVC6. */ + chaz_CC_add_extra_cflags("-Dfor=\"if(0);else for\""); } } @@ -4795,7 +4810,6 @@ int main(int argc, const char **argv) { } chaz_Probe_init(&args); S_add_compiler_flags(&args); - } { int i; http://git-wip-us.apache.org/repos/asf/lucy/blob/60879494/common/charmonizer.main ---------------------------------------------------------------------- diff --git a/common/charmonizer.main b/common/charmonizer.main index 0a54b88..c8a6d24 100644 --- a/common/charmonizer.main +++ b/common/charmonizer.main @@ -50,6 +50,21 @@ S_add_compiler_flags(struct chaz_CLIArgs *args) { "-Wno-variadic-macros " ); } + + /* Only core source files require this -- not our headers and + * autogenerated files. */ + chaz_CC_add_extra_cflags("-std=gnu99 -D_GNU_SOURCE"); + } + else if (chaz_Probe_compiler_is_msvc()) { + /* Compile as C++ under MSVC. */ + chaz_CC_add_extra_cflags("/TP"); + + /* Thwart stupid warnings. */ + chaz_CC_add_extra_cflags("-D_CRT_SECURE_NO_WARNINGS"); + chaz_CC_add_extra_cflags("-D_SCL_SECURE_NO_WARNINGS"); + + /* Redefine 'for' to fix broken 'for' scoping under MSVC6. */ + chaz_CC_add_extra_cflags("-Dfor=\"if(0);else for\""); } } @@ -63,7 +78,6 @@ int main(int argc, const char **argv) { } chaz_Probe_init(&args); S_add_compiler_flags(&args); - } { int i;
