Nginx on OpenBSD

Hello,

When trying to compile nginx on OpenBSD (4.2 or 4.3 prerelease), I get
the following error:

In file included from src/os/unix/ngx_posix_config.h:74,
from src/core/ngx_config.h:37,
from src/core/nginx.c:7:
/usr/include/malloc.h:4:2: #warning “<malloc.h> is obsolete, use
<stdlib.h>”

Of course, replacing <malloc.h> by <stdlib.h> in
src/os/unix/ngx_posix_config.h solves the problem. But isn’t there a way
to detect this at configure time?

Regards

On Fri, Mar 21, 2008 at 09:41:33AM +0100, Renaud Allard wrote:

Of course, replacing <malloc.h> by <stdlib.h> in
src/os/unix/ngx_posix_config.h solves the problem. But isn’t there a way
to detect this at configure time?

Regards

Igor,

Is there any platform that actually needs malloc.h? AFAIK, the C
standard defines malloc() in stdlib.h.

I’d vote for hardcoding stdlib.h instead of malloc.h.

Best regards,
Grzegorz N.

On Fri, Mar 21, 2008 at 09:41:33AM +0100, Renaud Allard wrote:

to detect this at configure time?
<malloc.h> is tested at configure time, it was done for cygwin,
but without -Werror. I will look how to resolve the issue.

On Fri, Mar 21, 2008 at 09:59:00AM +0100, Grzegorz N. wrote:

standard defines malloc() in stdlib.h.

I’d vote for hardcoding stdlib.h instead of malloc.h.

malloc.h is required for Cygwin only. And it seems that it’s required
for currently unused memalign() only.

Darrin Chandler wrote:

OpenBSD. There are not many special cases, since nginx is BSD friendly.
:slight_smile:

I think that, as it is only needed on cygwin, the C spec says malloc()
is in stdlib, it would really be cleaner if Igor did the change in the
official source tree. Also, I am using v0.6.
I would even say, it would be great if nginx with its BSD license was
the default web server on OpenBSD instead of the old, slow and memory
hungry apache. But I don’t know about crypto export restrictions.

On Fri, Mar 21, 2008 at 09:41:33AM +0100, Renaud Allard wrote:

to detect this at configure time?
I’ve dealt with this in the OpenBSD port of nginx by adding:

–with-cc-opt="-DNGX_HAVE_MALLOC_H=0"

I’d rather find a better way to deal with it, but the above works fine.
If you’re using the 5.x nginx you might consider using the OpenBSD port
I made, as long as the configured options match what you need.
Otherwise, you might have a peek at /usr/ports/www/nginx/Makefile to
give you some hints on anything I’ve done to make it work better on
OpenBSD. There are not many special cases, since nginx is BSD friendly.
:slight_smile:

On Fri, Mar 21, 2008 at 08:22:12PM +0100, Renaud Allard wrote:

I would even say, it would be great if nginx with its BSD license was
the default web server on OpenBSD instead of the old, slow and memory
hungry apache. But I don’t know about crypto export restrictions.

nginx is not Apache replacement.
The default server should may run CGIs, but nginx can not.

You maybe must be try the OpenBSD port located in /usr/ports/www/nginx
This is the best way to install it.

Darrin Chandler is the maintaner for nginx port and any comments with it
you
are freely for mail to him.

Personally I’m using a old nginx version in my OpenBSD server, the
0.5.19compiled manually.

Best Regards.

On Fri, Mar 21, 2008 at 08:22:12PM +0100, Renaud Allard wrote:

I think that, as it is only needed on cygwin, the C spec says malloc()
is in stdlib, it would really be cleaner if Igor did the change in the
official source tree. Also, I am using v0.6.

I would like to see it removed in the nginx source, too. If it’s not I
can understand. In the meantime the option I mentioned should work for
you with 0.6.x fine.

I would even say, it would be great if nginx with its BSD license was
the default web server on OpenBSD instead of the old, slow and memory
hungry apache. But I don’t know about crypto export restrictions.

It’s a nice thought but it will not happen now, and maybe never. Too
many people expect or want Apache by default, so there it is. However,
when I made the nginx port I didn’t expect that many people would be
using it and I have been surprised on that. At least a few of the
OpenBSD developers are using it or have tried it, and users as well. So
providing nginx as a port on OpenBSD is a nice thing. With 4.3 it should
also appear as a binary package and I’d expect wider usage then.

On Fri, Mar 21, 2008 at 09:41:33AM +0100, Renaud Allard wrote:

Of course, replacing <malloc.h> by <stdlib.h> in
src/os/unix/ngx_posix_config.h solves the problem. But isn’t there a way
to detect this at configure time?

Try the attached patch.

Igor S. wrote:

/usr/include/malloc.h:4:2: #warning “<malloc.h> is obsolete, use <stdlib.h>”

Of course, replacing <malloc.h> by <stdlib.h> in
src/os/unix/ngx_posix_config.h solves the problem. But isn’t there a way
to detect this at configure time?

Try the attached patch.

Thanks, it works great.