GNOME Bugzilla – Bug 140468
building libxslt 1.1.6 on Solaris
Last modified: 2009-08-15 18:40:50 UTC
Just a short note to report that libxslt 1.1.6 builds without problem on Solaris using the Sun ONE Studio 7 compiler, with just one warning: cc -DHAVE_CONFIG_H -I. -I. -I.. -I.. -I../libxslt -I../libexslt -I.. -I../libxslt -I../libexslt -I/usr/local/libxml2/include/libxml2 -O -O -c date.c -KPIC -DPIC -o .libs/date.o "date.c", line 748: warning: implicit function declaration: localtime_r This bug was already present in libxslt 1.1.5: http://bugzilla.gnome.org/show_bug.cgi?id=138095 I had written the warning could be caused by a missing <time.h> in date.c, but it's a bit more complicated than that. File date.c does include <time.h>: #ifdef HAVE_TIME_H #include <time.h> #endif after including "config.h": #if defined(WIN32) && [...] [...] #else #include "config.h" #endif which does define HAVE_TIME_H: /* Define to 1 if you have the <time.h> header file. */ #define HAVE_TIME_H 1 The problem is that unlike GNU systems, Unix systems don't always "export" newer APIs by default, for compatibility reasons. On Solaris /usr/include/time.h looks like: #if defined(__EXTENSIONS__) || defined(_REENTRANT) || \ (_POSIX_C_SOURCE - 0 >= 199506L) extern struct tm *gmtime_r(const time_t *, struct tm *); extern struct tm *localtime_r(const time_t *, struct tm *); #endif /* defined(__EXTENSIONS__) || defined(_REENTRANT) .. */ As far as I can tell, the idea here is that you don't need localtime_r if you don't write threaded programs that are supposed to define _REENTRANT or _POSIX_C_SOURCE. Of course that's stupid since libraries should use localtime_r even when they're not threaded themselves, because they may be later used in a threaded program. Anyway, I see no solution apart from defining __EXTENSIONS__ which is fairly standard on Solaris if you want to use the latest APIs without caring about compatibility. I'm not sure whether __EXTENSIONS__ should be defined in config.h or Makefile. Both should work, it's a question of taste and consistency.
*** Bug 138095 has been marked as a duplicate of this bug. ***
Okay, I see. To limit the amount of potential troubles related to the define I assume the following is a safe bet: --- date.c 26 Feb 2004 17:04:11 -0000 1.24 +++ date.c 16 May 2004 21:50:28 -0000 @@ -49,6 +49,13 @@ #include <math.h> #endif +/* needed to get localtime_r on Solaris */ +#ifdef sun +#ifndef __EXTENSION__ +#define __EXTENSION__ +#endif +#endif + #ifdef HAVE_TIME_H #include <time.h> #endif I have commited this, I hope this will close this bug for good :-) thanks a lot for the explanations, Daniel
This should be closed in libxslt-1.1.8, thanks, Daniel