From 6650ab5cb5a7836569c553b4f756332be5f86beb Mon Sep 17 00:00:00 2001 From: aquanight Date: Sat, 9 Feb 2008 01:55:31 +0000 Subject: Add a perl script which will abort compiles for warning messages that don't have a switch to convert to errors (like the one about non-PODs through ...) git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@8855 e03df62e-2008-0410-955e-edbf42e46eb7 --- configure | 28 +++++++-------- run-cc.pl | 100 +++++++++++++++++++++++++++++++++++++++++++++++++++++ src/modes/Makefile | 34 +++++++++--------- 3 files changed, 131 insertions(+), 31 deletions(-) create mode 100755 run-cc.pl diff --git a/configure b/configure index 1b28e30a1..90a67e967 100755 --- a/configure +++ b/configure @@ -1369,14 +1369,14 @@ EOCHEESE { print FILEHANDLE " m_$i.so: m_$i.cpp ../../include/modules.h ../../include/users.h ../../include/channels.h ../../include/base.h ../../include/inspircd_config.h ../../include/inspircd.h ../../include/configreader.h $deps - \$(CC) -pipe -I../../include \$(NICEFLAGS) $cmflags \$(PICLDFLAGS) $liflags -export-dynamic -o m_$i.so m_$i.cpp + ../../run-cc.pl \$(CC) -pipe -I../../include \$(NICEFLAGS) $cmflags \$(PICLDFLAGS) $liflags -export-dynamic -o m_$i.so m_$i.cpp " } else { print FILEHANDLE " m_$i.so: m_$i.cpp ../../include/modules.h ../../include/users.h ../../include/channels.h ../../include/base.h ../../include/inspircd_config.h ../../include/inspircd.h ../../include/configreader.h $deps - \$(CC) -pipe -I../../include \$(FLAGS) $cmflags \$(PICLDFLAGS) $liflags -export-dynamic -o m_$i.so m_$i.cpp + ../../run-cc.pl \$(CC) -pipe -I../../include \$(FLAGS) $cmflags \$(PICLDFLAGS) $liflags -export-dynamic -o m_$i.so m_$i.cpp "; } $install_list = $install_list . " install -m \$(INSTMODE) src/modules/m_$i.so \$(MODPATH)\n"; @@ -1399,9 +1399,9 @@ m_$i.so: m_$i.cpp ../../include/modules.h ../../include/users.h ../../include/ch print "Composing Makefile rules for directory \e[1;32m$name\e[0m... (\e[1;32m$mfcount files found\e[0m)\n"; print FILEHANDLE "$name.so: ../../include/modules.h ../../include/users.h ../../include/channels.h ../../include/base.h ../../include/inspircd_config.h ../../include/inspircd.h ../../include/configreader.h $mobjs\n"; if ($config{IS_DARWIN} eq "YES") { - print FILEHANDLE " \$(CC) -pipe -twolevel_namespace -undefined dynamic_lookup \$(FLAGS) $mliflags -bundle -o $name.so $mobjs\n"; + print FILEHANDLE " ../../run-cc.pl \$(CC) -pipe -twolevel_namespace -undefined dynamic_lookup \$(FLAGS) $mliflags -bundle -o $name.so $mobjs\n"; } else { - print FILEHANDLE " \$(CC) -pipe \$(FLAGS) -shared $mliflags -o $name.so $mobjs\n"; + print FILEHANDLE " ../../run-cc.pl \$(CC) -pipe \$(FLAGS) -shared $mliflags -o $name.so $mobjs\n"; } print FILEHANDLE "\n$mfrules\n"; closedir(MDIRHANDLE); @@ -1427,7 +1427,7 @@ sub read_module_directory { my $oname = $fname; $oname =~ s/\.cpp$/.o/g; $mfrules = $mfrules . "$reldpath/$oname: $reldpath/$fname ../../include/modules.h ../../include/users.h ../../include/channels.h ../../include/base.h ../../include/inspircd_config.h ../../include/inspircd.h ../../include/configreader.h $deps\n"; - $mfrules = $mfrules . " \$(CC) -pipe -I../../include -I. \$(FLAGS) $cmflags -export-dynamic -o $reldpath/$oname -c $reldpath/$fname\n\n"; + $mfrules = $mfrules . " ../../run-cc.pl \$(CC) -pipe -I../../include -I. \$(FLAGS) $cmflags -export-dynamic -o $reldpath/$oname -c $reldpath/$fname\n\n"; $mobjs = $mobjs . " $reldpath/$oname"; $mfcount++; } @@ -1597,13 +1597,13 @@ sub write_dynamic_makefile if ($config{IS_DARWIN} eq "YES") { $libraryext = "dylib"; - $othercrap = " \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c inspircd.cpp\n \$(CC) -pipe -dynamic -bind_at_load -L. -o inspircd \$(LDLIBS) inspircd.o " + $othercrap = " ../run-cc.pl \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c inspircd.cpp\n ../run-cc.pl \$(CC) -pipe -dynamic -bind_at_load -L. -o inspircd \$(LDLIBS) inspircd.o " } else { $libraryext = "so"; $RPATH = "-Wl,--rpath -Wl,$config{LIBRARY_DIR}" unless defined $opt_disablerpath; - $othercrap = " \$(CC) -pipe -I../include $RPATH \$(FLAGS) $freebsd4libs -rdynamic -L. inspircd.cpp -o inspircd \$(LDLIBS) "; + $othercrap = " ../run-cc.pl \$(CC) -pipe -I../include $RPATH \$(FLAGS) $freebsd4libs -rdynamic -L. inspircd.cpp -o inspircd \$(LDLIBS) "; } foreach my $cpp (sort keys %filelist) @@ -1676,12 +1676,12 @@ EOM } } print FH $thislib . ": $cpp $deps ". (defined($specialdeps{$cpp}) ? $specialdeps{$cpp} : "") . "\n"; - print FH " \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c $rawcpp\n"; + print FH " ../run-cc.pl \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c $rawcpp\n"; if (exists($extrabuildlines{$cpp})) { print FH " " . $extrabuildlines{$cpp} . "\n"; } - print FH " \$(CC) -pipe $libcrap -o " . $thislib . " " . $objs . "\n\n"; + print FH " ../run-cc.pl \$(CC) -pipe $libcrap -o " . $thislib . " " . $objs . "\n\n"; } print FH "moo:\n \${MAKE} -C \"commands\" DIRNAME=\"src/commands\" CC=\"\$(CC)\" \$(MAKEARGS)\n\n"; @@ -1710,17 +1710,17 @@ ITEM foreach my $cmd (@cmdlist) { print FH < qw(all); + +use POSIX (); + +# Runs the compiler, passing it the given arguments. +# Filters select output from the compiler's standard error channel and +# can take different actions as a result. + +# NOTE: this is *NOT* a hash (sadly: a hash would stringize all the regexes and thus render them useless, plus you can't index a hash based on regexes anyway) +# even though we use the => in it. + +# The subs are passed the message, and anything the regex captured. + +my @msgfilters = ( + [ qr/^(.*) warning: cannot pass objects of non-POD type `(.*)' through `\.\.\.'; call will abort at runtime/ => sub { + my ($msg, $where, $type) = @_; + my $errstr = "$where error: cannot pass objects of non-POD type `$type' through `...'\n"; + if ($type =~ m/::string/) { + $errstr .= "$where (Did you forget to call c_str()?)\n"; + } + die $errstr; + } ], +); + +my $pid; + +my ($r_stderr, $w_stderr); + +my $cc = shift(@ARGV); + +if (!defined($cc) || $cc eq "") { + die "Compiler not specified!\n"; +} + +pipe($r_stderr, $w_stderr) or die "pipe stderr: $!\n"; + +$pid = fork; + +die "Cannot fork to start gcc! $!\n" unless defined($pid); + +if ($pid) { + my $fail = 0; + # Parent - Close child-side pipes. + close $w_stderr; + # Close STDIN to ensure no conflicts with child. + close STDIN; + # Now read each line of stderr +LINE: while (defined(my $line = <$r_stderr>)) { + chomp $line; + for my $filter (@msgfilters) { + my @caps; + if (@caps = ($line =~ $filter->[0])) { + $@ = ""; + eval { + $filter->[1]->($line, @caps); + }; + if ($@) { + $fail = 1; + print STDERR $@; + } + next LINE; + } + } + print STDERR "$line\n"; + } + waitpid $pid, 0; + close $r_stderr; + my $exit = $?; + # Simulate the same exit, so make gets the right termination info. + if (POSIX::WIFSIGNALED($exit)) { + # Make won't get the right termination info (it gets ours, not the compiler's), so we must tell the user what really happened ourselves! + print STDERR "$cc killed by signal " . POSIX::WTERMSIGN($exit) . "\n"; + kill "TERM", getppid(); # Needed for bsd make. + kill "TERM", $$; + } + else { + if (POSIX::WEXITSTATUS($exit) == 0) { + if ($fail) { + kill "TERM", getppid(); # Needed for bsd make. + kill "TERM", $$; + } + exit 0; + } else { + exit POSIX::WEXITSTATUS($exit); + } + } +} else { + # Child - Close parent-side pipes. + close $r_stderr; + # Divert stderr + open STDERR, ">&", $w_stderr or die "Cannot divert STDERR: $!\n"; + # Run the compiler! + exec { $cc } $cc, @ARGV; + die "exec $cc: $!\n"; +} diff --git a/src/modes/Makefile b/src/modes/Makefile index 8839168b7..04dd5d671 100644 --- a/src/modes/Makefile +++ b/src/modes/Makefile @@ -4,55 +4,55 @@ CXXFLAGS = -I../../include ${FLAGS} all: umode_w.o umode_s.o umode_o.o umode_n.o umode_i.o cmode_v.o cmode_t.o cmode_s.o cmode_p.o cmode_o.o cmode_n.o cmode_m.o cmode_l.o cmode_k.o cmode_i.o cmode_h.o cmode_b.o modeclasses.a umode_w.o: umode_w.cpp ../../include/base.h ../../include/modules.h ../../include/inspircd.h ../../include/channels.h ../../include/users.h ../../include/inspircd_config.h ../../include/mode.h - $(CC) -pipe -I../../include $(FLAGS) -export-dynamic -c umode_w.cpp + ../../run-cc.pl $(CC) -pipe -I../../include $(FLAGS) -export-dynamic -c umode_w.cpp umode_s.o: umode_s.cpp ../../include/base.h ../../include/modules.h ../../include/inspircd.h ../../include/channels.h ../../include/users.h ../../include/inspircd_config.h ../../include/mode.h - $(CC) -pipe -I../../include $(FLAGS) -export-dynamic -c umode_s.cpp + ../../run-cc.pl $(CC) -pipe -I../../include $(FLAGS) -export-dynamic -c umode_s.cpp umode_o.o: umode_o.cpp ../../include/base.h ../../include/modules.h ../../include/inspircd.h ../../include/channels.h ../../include/users.h ../../include/inspircd_config.h ../../include/mode.h - $(CC) -pipe -I../../include $(FLAGS) -export-dynamic -c umode_o.cpp + ../../run-cc.pl $(CC) -pipe -I../../include $(FLAGS) -export-dynamic -c umode_o.cpp umode_n.o: umode_n.cpp ../../include/base.h ../../include/modules.h ../../include/inspircd.h ../../include/channels.h ../../include/users.h ../../include/inspircd_config.h ../../include/mode.h - $(CC) -pipe -I../../include $(FLAGS) -export-dynamic -c umode_n.cpp + ../../run-cc.pl $(CC) -pipe -I../../include $(FLAGS) -export-dynamic -c umode_n.cpp umode_i.o: umode_i.cpp ../../include/base.h ../../include/modules.h ../../include/inspircd.h ../../include/channels.h ../../include/users.h ../../include/inspircd_config.h ../../include/mode.h - $(CC) -pipe -I../../include $(FLAGS) -export-dynamic -c umode_i.cpp + ../../run-cc.pl $(CC) -pipe -I../../include $(FLAGS) -export-dynamic -c umode_i.cpp cmode_v.o: cmode_v.cpp ../../include/base.h ../../include/modules.h ../../include/inspircd.h ../../include/channels.h ../../include/users.h ../../include/inspircd_config.h ../../include/mode.h - $(CC) -pipe -I../../include $(FLAGS) -export-dynamic -c cmode_v.cpp + ../../run-cc.pl $(CC) -pipe -I../../include $(FLAGS) -export-dynamic -c cmode_v.cpp cmode_t.o: cmode_t.cpp ../../include/base.h ../../include/modules.h ../../include/inspircd.h ../../include/channels.h ../../include/users.h ../../include/inspircd_config.h ../../include/mode.h - $(CC) -pipe -I../../include $(FLAGS) -export-dynamic -c cmode_t.cpp + ../../run-cc.pl $(CC) -pipe -I../../include $(FLAGS) -export-dynamic -c cmode_t.cpp cmode_s.o: cmode_s.cpp ../../include/base.h ../../include/modules.h ../../include/inspircd.h ../../include/channels.h ../../include/users.h ../../include/inspircd_config.h ../../include/mode.h - $(CC) -pipe -I../../include $(FLAGS) -export-dynamic -c cmode_s.cpp + ../../run-cc.pl $(CC) -pipe -I../../include $(FLAGS) -export-dynamic -c cmode_s.cpp cmode_p.o: cmode_p.cpp ../../include/base.h ../../include/modules.h ../../include/inspircd.h ../../include/channels.h ../../include/users.h ../../include/inspircd_config.h ../../include/mode.h - $(CC) -pipe -I../../include $(FLAGS) -export-dynamic -c cmode_p.cpp + ../../run-cc.pl $(CC) -pipe -I../../include $(FLAGS) -export-dynamic -c cmode_p.cpp cmode_o.o: cmode_o.cpp ../../include/base.h ../../include/modules.h ../../include/inspircd.h ../../include/channels.h ../../include/users.h ../../include/inspircd_config.h ../../include/mode.h - $(CC) -pipe -I../../include $(FLAGS) -export-dynamic -c cmode_o.cpp + ../../run-cc.pl $(CC) -pipe -I../../include $(FLAGS) -export-dynamic -c cmode_o.cpp cmode_n.o: cmode_n.cpp ../../include/base.h ../../include/modules.h ../../include/inspircd.h ../../include/channels.h ../../include/users.h ../../include/inspircd_config.h ../../include/mode.h - $(CC) -pipe -I../../include $(FLAGS) -export-dynamic -c cmode_n.cpp + ../../run-cc.pl $(CC) -pipe -I../../include $(FLAGS) -export-dynamic -c cmode_n.cpp cmode_m.o: cmode_m.cpp ../../include/base.h ../../include/modules.h ../../include/inspircd.h ../../include/channels.h ../../include/users.h ../../include/inspircd_config.h ../../include/mode.h - $(CC) -pipe -I../../include $(FLAGS) -export-dynamic -c cmode_m.cpp + ../../run-cc.pl $(CC) -pipe -I../../include $(FLAGS) -export-dynamic -c cmode_m.cpp cmode_l.o: cmode_l.cpp ../../include/base.h ../../include/modules.h ../../include/inspircd.h ../../include/channels.h ../../include/users.h ../../include/inspircd_config.h ../../include/mode.h - $(CC) -pipe -I../../include $(FLAGS) -export-dynamic -c cmode_l.cpp + ../../run-cc.pl $(CC) -pipe -I../../include $(FLAGS) -export-dynamic -c cmode_l.cpp cmode_k.o: cmode_k.cpp ../../include/base.h ../../include/modules.h ../../include/inspircd.h ../../include/channels.h ../../include/users.h ../../include/inspircd_config.h ../../include/mode.h - $(CC) -pipe -I../../include $(FLAGS) -export-dynamic -c cmode_k.cpp + ../../run-cc.pl $(CC) -pipe -I../../include $(FLAGS) -export-dynamic -c cmode_k.cpp cmode_i.o: cmode_i.cpp ../../include/base.h ../../include/modules.h ../../include/inspircd.h ../../include/channels.h ../../include/users.h ../../include/inspircd_config.h ../../include/mode.h - $(CC) -pipe -I../../include $(FLAGS) -export-dynamic -c cmode_i.cpp + ../../run-cc.pl $(CC) -pipe -I../../include $(FLAGS) -export-dynamic -c cmode_i.cpp cmode_h.o: cmode_h.cpp ../../include/base.h ../../include/modules.h ../../include/inspircd.h ../../include/channels.h ../../include/users.h ../../include/inspircd_config.h ../../include/mode.h - $(CC) -pipe -I../../include $(FLAGS) -export-dynamic -c cmode_h.cpp + ../../run-cc.pl $(CC) -pipe -I../../include $(FLAGS) -export-dynamic -c cmode_h.cpp cmode_b.o: cmode_b.cpp ../../include/base.h ../../include/modules.h ../../include/inspircd.h ../../include/channels.h ../../include/users.h ../../include/inspircd_config.h ../../include/mode.h - $(CC) -pipe -I../../include $(FLAGS) -export-dynamic -c cmode_b.cpp + ../../run-cc.pl $(CC) -pipe -I../../include $(FLAGS) -export-dynamic -c cmode_b.cpp modeclasses.a: umode_w.o umode_s.o umode_o.o umode_n.o umode_i.o cmode_v.o cmode_t.o cmode_s.o cmode_p.o cmode_o.o cmode_n.o cmode_m.o cmode_l.o cmode_k.o cmode_i.o cmode_h.o cmode_b.o @-rm -rf modeclasses.a -- cgit v1.2.3