Hi,

Trying to get modperl compiling on a recent Ubuntu, I encountered the "inline semantics changed" issue, which is also mentioned here:

https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=777935#14

To make compilation easier on gcc5/clang hosts, I've created the attached patch, which automatically selects the appropriate c89 option, when modperl is being built with either gcc 5 or clang.

I've tested the patch on Ubuntu 15.10 (with gcc 5.2.1), Fedora 23 (with gcc 5.3.1) and FreeBSD 10.2 (with clang).

--
Klaus S. Madsen, Udvikler, k...@jobindex.dk
Jobindex A/S, Holger Danskes Vej 91, 2000 Frederiksberg
Tlf +45 38 32 33 55, Dir +45 38 32 33 70
http://www.jobindex.dk/

diff --git a/README b/README
index 7539400..8d7c79e 100644
--- a/README
+++ b/README
@@ -25,14 +25,6 @@ Perl:
   configurations) are currently believed to work, but this is not
   guaranteed to be the case, either now or in the future.
 
-C compiler:
-  The mod_perl source currently uses GNU89 inline semantics on GCC, but
-  GCC 5 defaults to newer C99 semantics.  If you see MP_INLINE related
-  warnings during the build and missing symbols when starting the test
-  suite, adding "-fgnu89-inline" to MP_CCOPTS may help.
-  There are also some reports of this happening with the Clang compiler,
-  where the corresponding option to try is "-std=gnu89".
-
 *** Status ***
 
 mod_perl is currently considered stable.
diff --git a/lib/Apache2/Build.pm b/lib/Apache2/Build.pm
index bb635df..7d2ef91 100644
--- a/lib/Apache2/Build.pm
+++ b/lib/Apache2/Build.pm
@@ -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
@@ -624,6 +632,16 @@ sub ap_ccopts {
     $ccopts;
 }
 
+sub has_clang {
+    my $self = shift;
+
+    my $has_version = $self->perl_config('gccversion');
+
+    return 0 unless $has_version;
+
+    return $has_version =~ m/Clang/;
+}
+
 sub has_gcc_version {
     my $self = shift;
     my $requested_version = shift;

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@perl.apache.org
For additional commands, e-mail: dev-h...@perl.apache.org

Reply via email to