PR/51359: Automatic compiler flags for gcc 5 and clang.

This commit is contained in:
nonaka 2016-08-04 14:18:15 +00:00
parent e5933e186e
commit 365327fe1f
2 changed files with 50 additions and 1 deletions

View file

@ -1,7 +1,8 @@
$NetBSD: distinfo,v 1.20 2015/11/04 02:46:48 agc Exp $
$NetBSD: distinfo,v 1.21 2016/08/04 14:18:15 nonaka Exp $
SHA1 (mod_perl-2.0.9.tar.gz) = 5de3018214da21de186d758a429d5c78f827caa5
RMD160 (mod_perl-2.0.9.tar.gz) = f4be60f1b4f4b5645aa7e97ad09d6b1871611bd4
SHA512 (mod_perl-2.0.9.tar.gz) = 421d385f0d5d04cbe8c1e9559960eea86a017fa1bed88e614009143550baf852e2345001faff1fb849d9b3e6383786e0011f45ebc3e7d26ad57651fbad4e2f2c
Size (mod_perl-2.0.9.tar.gz) = 3846584 bytes
SHA1 (patch-lib_Apache2_Build.pm) = b2dd179612272ff6facb0280c00d9589aa93dad6
SHA1 (patch-src_modules_perl_modperl_common_util.h) = a5fd094351fef2994b67c6c70abc18c772aec532

View file

@ -0,0 +1,48 @@
$NetBSD: patch-lib_Apache2_Build.pm,v 1.1 2016/08/04 14:18:15 nonaka Exp $
from mod_perl r1733566.
-----
Automatic compiler flags for gcc 5 and clang
To make compilation easier on gcc5/clang hosts, this patch automatically selects the appropriate c89 option, when modperl is being built with either gcc 5 or clang.
Tested by the author on Ubuntu 15.10 (with gcc 5.2.1), Fedora 23 (with gcc 5.3.1) and FreeBSD 10.2 (with clang).
Thanks to Klaus S. Madsen <ksm@jobindex.dk> for the patch.
-----
--- lib/Apache2/Build.pm.orig 2015-06-19 05:13:53.000000000 +0900
+++ lib/Apache2/Build.pm 2016-07-26 17:27:03.000000000 +0900
@@ -611,6 +611,14 @@ sub ap_ccopts {
$ccopts .= " -DMP_TRACE";
}
+ if ($self->has_gcc_version('5.0.0') && $ccopts !~ /-fgnu89-inline/) {
+ $ccopts .= " -fgnu89-inline";
+ }
+
+ if ($self->has_clang && $ccopts !~ /-std=gnu89/) {
+ $ccopts .= " -std=gnu89";
+ }
+
# make sure apr.h can be safely included
# for example Perl's included -D_GNU_SOURCE implies
# -D_LARGEFILE64_SOURCE on linux, but this won't happen on
@@ -641,6 +649,16 @@ sub has_gcc_version {
return cmp_tuples(\@tuples, \@r_tuples) == 1;
}
+sub has_clang {
+ my $self = shift;
+
+ my $has_version = $self->perl_config('gccversion');
+
+ return 0 unless $has_version;
+
+ return $has_version =~ m/Clang/;
+}
+
sub cmp_tuples {
my ($num_a, $num_b) = @_;