0.9.1 compilation failure on Nexenta 3.0.1

When playing around with Nexenta 3.0.1 and trying to compile latest
nginx, I got this error:

make[1]: Entering directory /export/home/edho/tmp/nginx-0.9.1' gcc -c -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Wunused-function -Wunused-variable -Wunused-value -Werror -g -I/app/pcre/include -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \ -o objs/src/os/unix/ngx_errno.o \ src/os/unix/ngx_errno.c src/os/unix/ngx_errno.c: In function ‘ngx_strerror’: src/os/unix/ngx_errno.c:36: error: ‘NGX_SYS_NERR’ undeclared (first use in this function) src/os/unix/ngx_errno.c:36: error: (Each undeclared identifier is reported only once src/os/unix/ngx_errno.c:36: error: for each function it appears in.) src/os/unix/ngx_errno.c: In function ‘ngx_strerror_init’: src/os/unix/ngx_errno.c:57: error: ‘NGX_SYS_NERR’ undeclared (first use in this function) make[1]: *** [objs/src/os/unix/ngx_errno.o] Error 1 make[1]: Leaving directory/export/home/edho/tmp/nginx-0.9.1’
make: *** [build] Error 2


O< ascii ribbon campaign - stop html mail - www.asciiribbon.org

http://nginx.org/pipermail/nginx/2010-December/023926.html

Best regards,
Piotr S. < [email protected] >

On Sun, Dec 5, 2010 at 7:58 PM, Piotr S. [email protected]
wrote:

http://nginx.org/pipermail/nginx/2010-December/023926.html

Best regards,
Piotr S. < [email protected] >

tried and still fail - in fact the error message I copied is the
result of patched source. Same error unpatched.


O< ascii ribbon campaign - stop html mail - www.asciiribbon.org

2010/12/6 Igor S. [email protected]:

result of patched source. Same error unpatched.
{
printf("%d\n", sys_nerr);
return 0;
}


looks like there’s no sys_nerr in Nexenta.

[email protected]:~$ cat < test.c

EOF
[email protected]:~$ make test
cc test.c -o test
test.c: In function ‘main’:
test.c:8: error: ‘sys_nerr’ undeclared (first use in this function)
test.c:8: error: (Each undeclared identifier is reported only once
test.c:8: error: for each function it appears in.)
make: *** [test] Error 1
[email protected]:~$ uname -a
SunOS nexenta 5.11 NexentaOS_134f i86pc i386 i86pc Solaris


O< ascii ribbon campaign - stop html mail - www.asciiribbon.org

On Mon, Dec 06, 2010 at 09:07:31PM +0700, Edho P Arief wrote:

tried and still fail - in fact the error message I copied is the
main()
[email protected]:~$ cat < test.c
EOF
[email protected]:~$ make test
cc test.c -o test
test.c: In function ‘main’:
test.c:8: error: ‘sys_nerr’ undeclared (first use in this function)
test.c:8: error: (Each undeclared identifier is reported only once
test.c:8: error: for each function it appears in.)
make: *** [test] Error 1
[email protected]:~$ uname -a
SunOS nexenta 5.11 NexentaOS_134f i86pc i386 i86pc Solaris

As I understand it uses glibc which has sys_nerr.
What does
grep -r sys_nerr /usr/include
show ?


Igor S.
http://sysoev.ru/en/

On Sun, Dec 05, 2010 at 09:41:31PM +0700, Edho P Arief wrote:

On Sun, Dec 5, 2010 at 7:58 PM, Piotr S. [email protected] wrote:

http://nginx.org/pipermail/nginx/2010-December/023926.html

Best regards,
Piotr S. < [email protected] >

tried and still fail - in fact the error message I copied is the
result of patched source. Same error unpatched.

Could you try to build this program:


#include <errno.h>
#include <string.h>
#include <stdio.h>

int
main()
{
printf("%d\n", sys_nerr);
return 0;
}

On Mon, Dec 6, 2010 at 9:10 PM, Igor S. removed_em[email protected] wrote:

As I understand it uses glibc which has sys_nerr.
What does
grep -r sys_nerr /usr/include
show ?

I tried that yesterday, too. Also I believe it uses Solaris’ libc.

Wikipedia:

Nexenta OS is the first distribution that combines the OpenSolaris C library and
GNU userland with the OpenSolaris kernel.

Here’s the result:

[email protected]:~$ grep -r sys_nerr /usr/include
/usr/include/errno.h: * The symbols _sys_errlist and _sys_nerr are not
visible in the
/usr/include/iso/errno_iso.h: * The symbols _sys_errlist and _sys_nerr
are not visible in the
[email protected]:~$

[email protected]:~$ grep -C 3 -r sys_nerr /usr/include
/usr/include/errno.h-
/usr/include/errno.h-#if defined(_LP64)
/usr/include/errno.h-/*
/usr/include/errno.h: * The symbols _sys_errlist and _sys_nerr are not
visible in the
/usr/include/errno.h- * LP64 libc. Use strerror(3C) instead.
/usr/include/errno.h- /
/usr/include/errno.h-#endif /
_LP64 */

/usr/include/iso/errno_iso.h-
/usr/include/iso/errno_iso.h-#if defined(_LP64)
/usr/include/iso/errno_iso.h-/*
/usr/include/iso/errno_iso.h: * The symbols _sys_errlist and _sys_nerr
are not visible in the
/usr/include/iso/errno_iso.h- * LP64 libc. Use strerror(3C) instead.
/usr/include/iso/errno_iso.h- /
/usr/include/iso/errno_iso.h-#endif /
_LP64 */


O< ascii ribbon campaign - stop html mail - www.asciiribbon.org

On Mon, Dec 06, 2010 at 09:32:07PM +0700, Edho P Arief wrote:

Nexenta OS is the first distribution that combines the OpenSolaris C library
and GNU userland with the OpenSolaris kernel.

/usr/include/iso/errno_iso.h-
/usr/include/iso/errno_iso.h-#if defined(_LP64)
/usr/include/iso/errno_iso.h-/*
/usr/include/iso/errno_iso.h: * The symbols _sys_errlist and _sys_nerr
are not visible in the
/usr/include/iso/errno_iso.h- * LP64 libc. Use strerror(3C) instead.
/usr/include/iso/errno_iso.h- /
/usr/include/iso/errno_iso.h-#endif /
_LP64 */

Yes, I’ve just checked OpenSolaris, it has no sys_nerr.
I will detect maximum errno using EINVAL error from strerror().


Igor S.
http://sysoev.ru/en/

On Mon, Dec 06, 2010 at 06:00:57PM +0300, Maxim D. wrote:

p.s. If for some reason you’ll still prefer to continue attempts
to build async-signal-safe strerror() - please note that POSIX
doesn’t require strerror() to return EINVAL for invalid codes, it
only says “may”.

I believe it will be the last iteration.
Actually the current ngx_strerror_r() in 0.8.x is a set of hacks
and workarounds, collected during nginx development.
For example, Linux GNU strerror_r() is very different than POSIX one.


Igor S.
http://sysoev.ru/en/

Hello!

On Mon, Dec 06, 2010 at 05:36:13PM +0300, Igor S. wrote:

are not visible in the
/usr/include/errno.h-#endif /* _LP64 */
Yes, I’ve just checked OpenSolaris, it has no sys_nerr.
I will detect maximum errno using EINVAL error from strerror().

What about just not using strerror() while in signal handler (and
using normal one in other cases)? I believe we’ve already seen
too many problems while trying to build async-signal-safe version
of strerror().

Maxim D.

p.s. If for some reason you’ll still prefer to continue attempts
to build async-signal-safe strerror() - please note that POSIX
doesn’t require strerror() to return EINVAL for invalid codes, it
only says “may”.

On Mon, Dec 06, 2010 at 09:32:07PM +0700, Edho P Arief wrote:

Nexenta OS is the first distribution that combines the OpenSolaris C library
and GNU userland with the OpenSolaris kernel.
Could you test the attached patch ?

Hello!

On Mon, Dec 06, 2010 at 06:30:08PM +0300, Igor S. wrote:

Maxim D.

p.s. If for some reason you’ll still prefer to continue attempts
to build async-signal-safe strerror() - please note that POSIX
doesn’t require strerror() to return EINVAL for invalid codes, it
only says “may”.

I believe it will be the last iteration.

I wish it will… Unfortunately, I’m almost sure it won’t. POSIX
doesn’t specify anything about error codes, and it’s not really
safe to assume they are somehow ordered.

Actually the current ngx_strerror_r() in 0.8.x is a set of hacks
and workarounds, collected during nginx development.
For example, Linux GNU strerror_r() is very different than POSIX one.

Yes, I understand. My general idea is to use POSIX interface if
available, and use hacks/workarounds only if they are known to be
needed. This way it will be as portable as possible.

The only real problem with POSIX strerror_r() is that it isn’t
async-signal-safe. And I think it’s fair enough to don’t print
error message if an error happens in a signal handler.

Maxim D.

2010/12/6 Igor S. [email protected]:

Could you test the attached patch ?

it works.

[email protected]:~/tmp/nginx-0.9.2$ file /app/nginx/sbin/nginx
/app/nginx/sbin/nginx: ELF 32-bit LSB executable, Intel 80386, version
1 (SYSV), dynamically linked (uses shared libs), not stripped
[email protected]:~/tmp/nginx-0.9.2$ LD_LIBRARY_PATH=/app/pcre/lib
/app/nginx/sbin/nginx -V
nginx: nginx version: nginx/0.9.2
nginx: built by gcc 4.2.3 (Ubuntu 4.2.3-2nexenta7)
nginx: TLS SNI support enabled
nginx: configure arguments: --prefix=/app/nginx
–with-cc-opt=-I/app/pcre/include --with-ld-opt=-L/app/pcre/lib
–with-ipv6 --with-http_ssl_module


O< ascii ribbon campaign - stop html mail - www.asciiribbon.org

On Tue, Dec 07, 2010 at 12:15:57AM +0700, Edho P Arief wrote:

[email protected]:~/tmp/nginx-0.9.2$ LD_LIBRARY_PATH=/app/pcre/lib
/app/nginx/sbin/nginx -V
nginx: nginx version: nginx/0.9.2
nginx: built by gcc 4.2.3 (Ubuntu 4.2.3-2nexenta7)
nginx: TLS SNI support enabled
nginx: configure arguments: --prefix=/app/nginx
–with-cc-opt=-I/app/pcre/include --with-ld-opt=-L/app/pcre/lib
–with-ipv6 --with-http_ssl_module

BTW, you can build “–with-ld-opt=-R/app/pcre/lib -L/app/pcre/lib”
and omit LD_LIBRARY_PATH=/app/pcre/lib.


Igor S.
http://sysoev.ru/en/

The patch works for me. I was running into same problem when I was doing
“make” with nginx-0.9.2 on SunOS 5.10. “‘NGX_SYS_NERR’ undeclared”
occurred. But after patching auto/unix, make command finally works.
Thank you.

Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,155668,156105#msg-156105

On Tue, Dec 7, 2010 at 12:21 AM, Igor S. [email protected] wrote:

BTW, you can build “–with-ld-opt=-R/app/pcre/lib -L/app/pcre/lib”
and omit LD_LIBRARY_PATH=/app/pcre/lib.

ah right. Thanks!


O< ascii ribbon campaign - stop html mail - www.asciiribbon.org