Welcome! Log In Create A New Profile

Advanced

Re: [PATCH] Fix PCRE detection on OSX.

Maxim Dounin
December 09, 2012 09:38PM
Hello!

On Fri, Dec 07, 2012 at 11:01:18PM -0800, Piotr Sikora wrote:

> Hey Ruslan,
>
> > And what happens if Apple fixes it the other day by putting PCRE
> > headers (back?) under /usr/include? How do we compile with the
> > version in /usr/include and /usr/lib then?
>
> - if [ "$NGX_SYSTEM" = "Darwin" ]; then
> + if [ "$NGX_SYSTEM" = "Darwin" -a "$NGX_RELEASE" < "X.Y.Z" ]; then
>
> where X.Y.Z is the fixed release... But this is really a question for
> another day, because OSX ships with libpcre without pcre.h at least
> from the OSX 10.6 release (so from 2009).

The problem with Mac OS X is not with libpcre withou pcre.h, but with
broken toolchain which prefers headers from /usr/local/include but
libraries from /usr/lib by default.

Here is a test:

#!/bin/sh -e

# in /usr/ {include, lib}:
# bad foo.h, good libfoo.a

# in /usr/local/ {include, lib}
# good foo.h, bad libfoo.a

CC=cc
AR=ar

echo '#error "broken foo.h in /usr/include"' > foo.h
install foo.h /usr/include/

echo 'char *foo() { return "broken libfoo.a from /usr/lib"; }' > foo.c
${CC} -c -o foo.o foo.c
${AR} -rs libfoo.a foo.o
install libfoo.a /usr/lib/

echo '#warning "good foo.h in /usr/local/include"' > foo.h
echo 'char *foo();' >> foo.h
install foo.h /usr/local/include/

echo 'char *foo() { return "good libfoo.a from /usr/local/"; }' > foo.c
${CC} -c -o foo.o foo.c
${AR} -rs libfoo.a foo.o
install libfoo.a /usr/local/lib/

cat << END > test.c

#include <foo.h>
#include <stdio.h>

int
main(void) {
printf("%s\n", foo());
}

END

${CC} -o test -l foo test.c
../test

On Mac OS X 10.7.5 with Xcode 4.5.2 it results in:

# ./test.sh
In file included from test.c:2:
/usr/local/include/foo.h:1:2: warning: "good foo.h in /usr/local/include" [-W#warnings]
#warning "good foo.h in /usr/local/include"
^
1 warning generated.
broken libfoo.a from /usr/lib

That is, header file from /usr/local/include was used, but library
from /usr/lib. This is the clear incosistency in build toolchain
which will result in various build problems till fixed.

Easy fix is to avoid using /usr/local/ till the problem is fixed.
Alternatively, one may try to provide appropriate compiler
arguments to fix the toolchain. Another alternative would be to
switch to a different toolchain (e.g. MacPort's provided one).

I don't think nginx should try to do anything with it as it's
indeed not our problem. But if we are going to, it probably
should be something better that just not searching for PCRE in
default compiler search paths, as it e.g. breaks compilation with
search paths explicitly configured by a user via ./configure
arguments.

--
Maxim Dounin
http://nginx.com/support.html

_______________________________________________
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 1101 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 456 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 756 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 456 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: 112
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