php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #50345 nanosleep not detected properly on some solaris versions
Submitted: 2009-11-30 22:51 UTC Modified: 2010-10-05 15:44 UTC
Votes:2
Avg. Score:4.0 ± 1.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: sle at ocf dot berkeley dot edu Assigned: tony2001
Status: Closed Package: Compile Failure
PHP Version: 5.3.1 OS: Solaris 10
Private report: No CVE-ID:
 [2009-11-30 22:51 UTC] sle at ocf dot berkeley dot edu
Description:
------------
Compiling PHP 5.3.1 on Solaris 10 with gcc version 3.4.3 (/usr/sfw/bin/gcc) produces the following error at the end of the compile:

Undefined                       first referenced
 symbol                             in file
nanosleep                           ext/standard/.libs/basic_functions.o
ld: fatal: Symbol referencing errors. No output written to sapi/cgi/php-cgi

I was able to successfully compile PHP 5.3.0 with the same configure/build options. I think this may be related to bug #49809. However, I've tried reversing the patch made to fix that bug and that does not fix the problem.


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-11-30 23:03 UTC] jani@php.net
Try this:

# make clean && make 

If it didn't work, what do you have in your main/php_config.h for HAVE_NANOSLEEP ?
 [2009-11-30 23:06 UTC] jani@php.net
Also, is -lrt in your Makefile LIBS ?
 [2009-11-30 23:23 UTC] sle at ocf dot berkeley dot edu
I've tried rebuilding multiple times without success. HAVE_NANOSLEEP is defined:

/* Define if you have the nanosleep function.  */
#define HAVE_NANOSLEEP 1

I don't see a variable named LIBS in my Makefile, however, I do see an EXTRA_LIBS and -lrt is not listed in that variable.
 [2009-12-01 03:04 UTC] sle at ocf dot berkeley dot edu
I was able to successfully compile PHP 5.3.1 by manually adding -lrt to 
EXTRA_LIBS.

Perhaps the configure script needs to be updated to add -lrt to the 
Makefile on Solaris?
 [2009-12-01 08:24 UTC] jani@php.net
Is there HAVE_LIBRT in your main/php_config.h ?
And if there is, it -lrt must be in EXTRA_LIBS as well.
 [2009-12-01 15:40 UTC] sle at ocf dot berkeley dot edu
HAVE_LIBRT is not defined:

/* #undef HAVE_LIBRT */

Is there anywhere I can look in config.log to find out why -lrt is not being detected?
 [2009-12-01 18:55 UTC] jani@php.net
Try grep for it..? Try also for nanosleep. Maybe it's found in libc somehow..
 [2009-12-01 23:52 UTC] sle at ocf dot berkeley dot edu
-lrt is only mentioned in config.log when searching for -lcurl. I suspect this is due to curl-config recommending -lrt for its linker flags.

With regards to nanosleep,
### snip from config.log ###
configure:15225: checking for nanosleep
configure:15253: /usr/sfw/bin/gcc -o conftest -I/opt/ocf/include -I/usr/sfw/incl
ude -I/opt/ocf/include -I/usr/sfw/include -D_POSIX_PTHREAD_SEMANTICS -L/opt/ocf/
lib -R/opt/ocf/lib -L/usr/sfw/lib -R/usr/sfw/lib -R/usr/ucblib -L/usr/ucblib con
ftest.c -lm -lnsl -lsocket  1>&5
Undefined                       first referenced
 symbol                             in file
nanosleep                           /var/tmp//ccYTdffo.o
ld: fatal: Symbol referencing errors. No output written to conftest
### end snip ###
since the test failed, it shouldn't have been defined.

However, I do see the following later:
### snip from config.log ###
configure:15271: checking for __nanosleep
configure:15299: /usr/sfw/bin/gcc -o conftest -I/opt/ocf/include -I/usr/sfw/incl
ude -I/opt/ocf/include -I/usr/sfw/include -D_POSIX_PTHREAD_SEMANTICS -L/opt/ocf/
lib -R/opt/ocf/lib -L/usr/sfw/lib -R/usr/sfw/lib -R/usr/ucblib -L/usr/ucblib con
ftest.c -lm -lnsl -lsocket  1>&5
### end snip ###

that test seems to be successful:

### snip from configure output ###
checking for nanosleep... no
checking for __nanosleep... yes
### end snip ###
 [2009-12-02 08:54 UTC] svn@php.net
Automatic comment from SVN on behalf of jani
Revision: http://svn.php.net/viewvc/?view=revision&revision=291584
Log: - Fixed bug #50345 (nanosleep not detected properly on some solaris versions)
 [2009-12-02 08:55 UTC] jani@php.net
Please try using this snapshot:

  http://snaps.php.net/php5.3-latest.tar.gz
 
For Windows:

  http://windows.php.net/snapshots/

But in about 35 minutes earliest so that the fix gets in it. :)
 [2009-12-02 16:23 UTC] sle at ocf dot berkeley dot edu
The patch appears to have fixed the bug. I am now able to successfully compile PHP 5.3 without modifying the generated Makefile. I'm running the test suites right now, but everything appears to be working.

Thanks for your help!
 [2009-12-02 18:01 UTC] jani@php.net
Closing then. Thanks for testing.
 [2010-07-23 13:51 UTC] rainer dot jung at kippdata dot de
Unfortunately the issue needs to be reopened.

The change in revision 297960 reintroduced this problem, at least on Solaris 8, but likely also on more modern Solaris.

Before the change library rt was added to EXTRA_LIBS, after the change the symbol __nanosleep is found and the library no longer added. During linking we then get (as expected):

Undefined                       first referenced
 symbol                             in file
nanosleep                           ext/standard/.libs/basic_functions.o
ld: fatal: Symbol referencing errors. No output written to sapi/cli/php
collect2: ld returned 1 exit status
make: *** [sapi/cli/php] Error 1

Observed for version 5.3.3.

Reverting the pseudo-optimization in r297960 fixes the issue.

Thanks for considering this,

Rainer
 [2010-07-23 13:52 UTC] rainer dot jung at kippdata dot de
Sorry: I meant r297961.

BTW: this is a regression, it was already fixed successful in 5.3.2.
 [2010-07-23 14:13 UTC] aharvey@php.net
-Status: Closed +Status: Re-Opened -Assigned To: jani +Assigned To:
 [2010-09-17 19:42 UTC] svinopas at gmail dot com
I am experiencing this issue on Solaris 09/10 SPARC and 5.3.3.
Is there fix available yet?
 [2010-10-04 13:19 UTC] uw@php.net
Manually setting -lrt will fix it, but maybe this could be fixed in the source? This breaks Solaris 8, 9 and 10 builds. Any PHP version since at least 5.3.1 is affected.



NAME
     nanosleep - high resolution sleep

SYNOPSIS
     cc [ flag... ] file... -lrt [ library... ]
     #include <time.h>

     int nanosleep(const struct timespec *rqtp,  struct  timespec
     *rmtp);
 [2010-10-04 13:28 UTC] uw@php.net
According to previous bug comments this commit should be reverted:

nixnutz@linux-fuxh:~/php/php-src/branches/PHP_5_3> svn diff -r297960:297961
Index: configure.in
===================================================================
--- configure.in        (Revision 297960)
+++ configure.in        (Revision 297961)
@@ -611,7 +611,7 @@
 )

 svn log -r297961
------------------------------------------------------------------------
r297961 | tony2001 | 2010-04-13 14:41:46 +0200 (Di, 13. Apr 2010) | 2 Zeilen

simplify configure check for nanosleep()

------------------------------------------------------------------------


 dnl Some systems (like OpenSolaris) do not have nanosleep in libc
-AC_CACHE_CHECK([for nanosleep], ac_cv_func_nanosleep, [PHP_CHECK_FUNC_LIB(nanosleep, rt)])
+PHP_CHECK_FUNC(nanosleep, rt)

 dnl Check for getaddrinfo, should be a better way, but...
 dnl Also check for working getaddrinfo


Antony, can you shed some light on it? Thanks!
 [2010-10-05 03:48 UTC] felipe@php.net
-Status: Re-Opened +Status: Assigned -Assigned To: +Assigned To: tony2001
 [2010-10-05 15:27 UTC] uw@php.net
-Status: Assigned +Status: Re-Opened
 [2010-10-05 15:27 UTC] uw@php.net
This would fix it, could someone double-check and apply the patch?

nixnutz@linux-fuxh:~/php/php-src/branches/PHP_5_3> svn diff configure.in
Index: configure.in
===================================================================
--- configure.in        (Revision 304085)
+++ configure.in        (Arbeitskopie)
@@ -611,7 +611,7 @@
 )

 dnl Some systems (like OpenSolaris) do not have nanosleep in libc
-PHP_CHECK_FUNC(nanosleep, rt)
+PHP_CHECK_FUNC_LIB(nanosleep, rt)

 dnl Check for getaddrinfo, should be a better way, but...
 dnl Also check for working getaddrinfo
 [2010-10-05 15:43 UTC] tony2001@php.net
Automatic comment from SVN on behalf of tony2001
Revision: http://svn.php.net/viewvc/?view=revision&amp;revision=304088
Log: fix bug #50345 (nanosleep not detected properly on some solaris versions)
 [2010-10-05 15:44 UTC] tony2001@php.net
-Status: Re-Opened +Status: Closed
 [2010-10-05 15:44 UTC] tony2001@php.net
Yep, that was a mistake (typo?) on my side, sorry.
Fix committed, thanks a lot.
 
PHP Copyright © 2001-2014 The PHP Group
All rights reserved.
Last updated: Sun Apr 20 15:01:54 2014 UTC