diff options
-rwxr-xr-x | configure | 28 | ||||
-rwxr-xr-x | run-cc.pl | 100 | ||||
-rw-r--r-- | src/modes/Makefile | 34 |
3 files changed, 131 insertions, 31 deletions
@@ -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 <<ITEM; cmd_$cmd.so: cmd_$cmd.cpp ../../include/base.h ../../include/modules.h ../../include/inspircd.h ../../include/channels.h ../../include/users.h ../../include/globals.h ../../include/inspircd_config.h ../../include/commands/cmd_$cmd.h - \$(CC) -pipe -I../../include \$(FLAGS) -export-dynamic -c cmd_$cmd.cpp - \$(CC) -pipe $SHARED -o cmd_$cmd.so cmd_$cmd.o + ../../run-cc.pl \$(CC) -pipe -I../../include \$(FLAGS) -export-dynamic -c cmd_$cmd.cpp + ../../run-cc.pl \$(CC) -pipe $SHARED -o cmd_$cmd.so cmd_$cmd.o ITEM } #try build a .so, no intermediate .o -# \$(CC) -pipe -I../../include \$(FLAGS) -export-dynamic $SHARED -o cmd_$cmd.so +# ../../run-cc.pl \$(CC) -pipe -I../../include \$(FLAGS) -export-dynamic $SHARED -o cmd_$cmd.so #this works for sure -# \$(CC) -pipe -I../../include \$(FLAGS) -export-dynamic -c cmd_$cmd.cpp -# \$(CC) -pipe $SHARED -o cmd_$cmd.so cmd_$cmd.o +# ../../run-cc.pl \$(CC) -pipe -I../../include \$(FLAGS) -export-dynamic -c cmd_$cmd.cpp +# ../../run-cc.pl \$(CC) -pipe $SHARED -o cmd_$cmd.so cmd_$cmd.o } # Routine to list out the extra/ modules that have been enabled. diff --git a/run-cc.pl b/run-cc.pl new file mode 100755 index 000000000..29af15393 --- /dev/null +++ b/run-cc.pl @@ -0,0 +1,100 @@ +#!/usr/bin/perl + +### THIS IS DESIGNED TO BE RUN BY MAKE! DO NOT RUN FROM THE SHELL (because it MIGHT sigterm the shell)! ### + +use strict; +use warnings FATAL => 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 |