Welcome! Log In Create A New Profile

Advanced

Re: [PATCH] Fix PCRE detection on OSX.

Piotr Sikora
December 11, 2012 03:20AM
Hey guys,
thanks for going into details why this happens, but to cut this
discussion short, I'll just focus on the patches.

> Index: auto/lib/pcre/conf
> ===================================================================
> --- auto/lib/pcre/conf (revision 4948)
> +++ auto/lib/pcre/conf (working copy)
> @@ -101,7 +101,17 @@
> ngx_feature_test="pcre *re;
> re = pcre_compile(NULL, 0, NULL, 0, NULL);
> if (re == NULL) return 1"
> - . auto/feature
> +
> + if [ "$NGX_SYSTEM" = "Darwin" ]; then
> + # Apple provides libpcre in /usr/lib but no /usr/include/pcre.h.
> + # This may interfere with libpcre installed into /usr/local if
> + # system compiler is used. To work around this, we delay the
> + # default test until after we tested /usr/local.
> + ngx_found=no
> +
> + else
> + . auto/feature
> + fi
>
> if [ $ngx_found = no ]; then
>
> @@ -119,6 +129,14 @@
> . auto/feature
> fi
>
> + if [ $ngx_found = no -a "$NGX_SYSTEM" = "Darwin" ]; then
> + ngx_feature="PCRE library"
> + ngx_feature_path=
> + ngx_feature_libs="-lpcre"
> +
> + . auto/feature
> + fi
> +
> if [ $ngx_found = no ]; then
>
> # RedHat RPM, Solaris package

I like this, it makes much more sense to defer the check instead of
completely skipping it.

> --- a/auto/lib/pcre/conf Mon Nov 26 18:01:49 2012 +0000
> +++ b/auto/lib/pcre/conf Mon Dec 10 18:21:53 2012 +0400
> @@ -172,6 +172,7 @@ else
> ngx_feature="PCRE JIT support"
> ngx_feature_name="NGX_HAVE_PCRE_JIT"
> ngx_feature_test="int jit = 0;
> + pcre_free_study(NULL);
> pcre_config(PCRE_CONFIG_JIT, &jit);
> if (jit != 1) return 1;"
> . auto/feature
>
> probably will be good enough. It will prevent build failures
> by checking if the code we are going to compile will compile.
>
> (Yes, I understand that it won't resolve the root cause, i.e. the
> library vs. headers mismatch. And yes, I understand that it will
> make PCRE JIT unavailable in some cases. I don't think we care
> though.)

While I agree that this is a better test for PCRE JIT presence and
that it should be included regardless of the OSX issue, I don't think
that this is solution to the problem at hand, because all it does is
hide the issue from the end user... Putting JIT capabilities aside, I
also dislike the fact that we might be throwing away almost 3 years of
PCRE fixes just because we cannot be bothered to link against newer
library that's available outside of the default search path... I
definitely prefer the solution with postponed check for the default
search path on OSX.

Alternatively, we could first try looking for the PCRE library with
JIT support and fallback to looking for the PCRE library without one:

diff --git a/auto/lib/pcre/conf b/auto/lib/pcre/conf
index 6a8c326..4f75018 100644
--- a/auto/lib/pcre/conf
+++ b/auto/lib/pcre/conf
@@ -92,21 +92,101 @@ else

PCRE=NO

- ngx_feature="PCRE library"
- ngx_feature_name="NGX_PCRE"
+ ngx_feature="PCRE library with JIT support"
+ ngx_feature_name="NGX_HAVE_PCRE_JIT"
ngx_feature_run=no
ngx_feature_incs="#include <pcre.h>"
ngx_feature_path=
ngx_feature_libs="-lpcre"
ngx_feature_test="pcre *re;
+ int jit = 0;
re = pcre_compile(NULL, 0, NULL, 0, NULL);
- if (re == NULL) return 1"
+ if (re == NULL) return 1;
+ pcre_free_study(NULL);
+ pcre_config(PCRE_CONFIG_JIT, &jit);
+ if (jit != 1) return 1;"
. auto/feature

if [ $ngx_found = no ]; then

# FreeBSD port

+ ngx_feature="PCRE library with JIT support in /usr/local/"
+ ngx_feature_path="/usr/local/include"
+
+ if [ $NGX_RPATH = YES ]; then
+ ngx_feature_libs="-R/usr/local/lib -L/usr/local/lib -lpcre"
+ else
+ ngx_feature_libs="-L/usr/local/lib -lpcre"
+ fi
+
+ . auto/feature
+ fi
+
+ if [ $ngx_found = no ]; then
+
+ # RedHat RPM, Solaris package
+
+ ngx_feature="PCRE library with JIT support in /usr/include/pcre/"
+ ngx_feature_path="/usr/include/pcre"
+ ngx_feature_libs="-lpcre"
+
+ . auto/feature
+ fi
+
+ if [ $ngx_found = no ]; then
+
+ # NetBSD port
+
+ ngx_feature="PCRE library with JIT support in /usr/pkg/"
+ ngx_feature_path="/usr/pkg/include"
+
+ if [ $NGX_RPATH = YES ]; then
+ ngx_feature_libs="-R/usr/pkg/lib -L/usr/pkg/lib -lpcre"
+ else
+ ngx_feature_libs="-L/usr/pkg/lib -lpcre"
+ fi
+
+ . auto/feature
+ fi
+
+ if [ $ngx_found = no ]; then
+
+ # MacPorts
+
+ ngx_feature="PCRE library with JIT support in /opt/local/"
+ ngx_feature_path="/opt/local/include"
+
+ if [ $NGX_RPATH = YES ]; then
+ ngx_feature_libs="-R/opt/local/lib -L/opt/local/lib -lpcre"
+ else
+ ngx_feature_libs="-L/opt/local/lib -lpcre"
+ fi
+
+ . auto/feature
+ fi
+
+ if [ $ngx_found = yes ]; then
+ PCRE_JIT=YES
+ fi
+
+ if [ $ngx_found = no ]; then
+
+ ngx_feature="PCRE library"
+ ngx_feature_name="NGX_PCRE"
+ ngx_feature_path=
+ ngx_feature_libs="-lpcre"
+ ngx_feature_test="pcre *re;
+ re = pcre_compile(NULL, 0, NULL, 0, NULL);
+ if (re == NULL) return 1"
+
+ . auto/feature
+ fi
+
+ if [ $ngx_found = no ]; then
+
+ # FreeBSD port
+
ngx_feature="PCRE library in /usr/local/"
ngx_feature_path="/usr/local/include"

@@ -167,19 +247,6 @@ else
CORE_LIBS="$CORE_LIBS $ngx_feature_libs"
PCRE=YES
fi
-
- if [ $PCRE = YES ]; then
- ngx_feature="PCRE JIT support"
- ngx_feature_name="NGX_HAVE_PCRE_JIT"
- ngx_feature_test="int jit = 0;
- pcre_config(PCRE_CONFIG_JIT, &jit);
- if (jit != 1) return 1;"
- . auto/feature
-
- if [ $ngx_found = yes ]; then
- PCRE_JIT=YES
- fi
- fi
fi

if [ $PCRE != YES ]; then

but honestly, it seems like a bit of an overkill.

Best regards,
Piotr Sikora

_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

[PATCH] Fix PCRE detection on OSX.

Piotr Sikora 1103 December 07, 2012 03:26PM

Re: [PATCH] Fix PCRE detection on OSX.

Ruslan Ermilov 437 December 07, 2012 05:22PM

Re: [PATCH] Fix PCRE detection on OSX.

Piotr Sikora 409 December 07, 2012 05:54PM

Re: [PATCH] Fix PCRE detection on OSX.

Tom van der Woerdt 498 December 07, 2012 06:06PM

Re: [PATCH] Fix PCRE detection on OSX.

Piotr Sikora 457 December 07, 2012 06:16PM

Re: [PATCH] Fix PCRE detection on OSX.

Ruslan Ermilov 416 December 08, 2012 12:26AM

Re: [PATCH] Fix PCRE detection on OSX.

Matthieu Tourne 424 December 08, 2012 01:34AM

Re: [PATCH] Fix PCRE detection on OSX.

Piotr Sikora 415 December 08, 2012 02:02AM

Re: [PATCH] Fix PCRE detection on OSX.

Maxim Dounin 757 December 09, 2012 09:38PM

Re: [PATCH] Fix PCRE detection on OSX.

Ruslan Ermilov 573 December 10, 2012 05:32AM

Re: [PATCH] Fix PCRE detection on OSX.

Maxim Dounin 457 December 10, 2012 09:52AM

Re: [PATCH] Fix PCRE detection on OSX.

Ruslan Ermilov 444 December 10, 2012 10:08AM

Re: [PATCH] Fix PCRE detection on OSX.

Piotr Sikora 424 December 11, 2012 03:20AM

Re: [PATCH] Fix PCRE detection on OSX.

Maxim Dounin 548 December 12, 2012 06:06AM

Re: [PATCH] Fix PCRE detection on OSX.

Matthieu Tourne 414 December 07, 2012 06:02PM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 125
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready