Hi,
make-3.79.1, built on a recent glibc snapshot, links with the shared
library librt, but doesn't any symbol from this library! Of course this
costs startup time.
The reason is that the function file_timestamp_now() in file.c uses
clock_gettime, but that block depends on
if (FILE_TIMESTAMP_HI_RES)
which macroexpands into
if (0)
Here is a patch to convert this 'if' test to a configure time test, thus
avoiding the dependency on librt when the function clock_gettime is not
really used.
2000-07-14 Bruno Haible <[EMAIL PROTECTED]>
* configure.in: Add test evaluating FILE_TIMESTAMP_HI_RES. Define
HAVE_HI_RES_FILE_TIMESTAMP depending on the result. Check for
clock_gettime only if HAVE_HI_RES_FILE_TIMESTAMP is 1.
* filedef.h (FILE_TIMESTAMP_HI_RES): Remove macro.
(FILE_TIMESTAMPS_PER_S, FILE_TIMESTAMP_LO_BITS): Use
HAVE_HI_RES_FILE_TIMESTAMP in place of FILE_TIMESTAMP_HI_RES.
* file.c (file_timestamp_cons): Likewise.
(file_timestamp_now): Likewise.
*** make-3.79.1/configure.in.bak Fri Jun 23 18:09:41 2000
--- make-3.79.1/configure.in Sat Jul 15 19:31:47 2000
***************
*** 53,62 ****
[make_cv_nsec_timestamps="$enableval"],
[make_cv_nsec_timestamps="yes"])
if test "x$make_cv_nsec_timestamps" != xno; then
AC_STRUCT_ST_MTIM_NSEC
fi
- jm_AC_TYPE_UINTMAX_T
AC_SUBST(LIBOBJS)
--- 53,109 ----
[make_cv_nsec_timestamps="$enableval"],
[make_cv_nsec_timestamps="yes"])
+ jm_AC_TYPE_UINTMAX_T
if test "x$make_cv_nsec_timestamps" != xno; then
AC_STRUCT_ST_MTIM_NSEC
+ AC_MSG_CHECKING([for high resolution file timestamps])
+ AC_CACHE_VAL(make_cv_hi_res_file_timestamp, [
+ AC_TRY_RUN([
+ #if HAVE_INTTYPES_H
+ # include <inttypes.h>
+ #endif
+ #define FILE_TIMESTAMP uintmax_t
+
+ #if HAVE_LIMITS_H
+ # include <limits.h>
+ #endif
+ #ifndef CHAR_BIT
+ # define CHAR_BIT 8
+ #endif
+ #define INTEGER_TYPE_SIGNED(t) ((t) -1 < 0)
+ #define INTEGER_TYPE_MINIMUM(t) \
+ (! INTEGER_TYPE_SIGNED (t) ? (t) 0 : ~ (t) 0 << (sizeof (t) * CHAR_BIT - 1))
+ #define INTEGER_TYPE_MAXIMUM(t) (~ (t) 0 - INTEGER_TYPE_MINIMUM (t))
+
+ #ifdef ST_MTIM_NSEC
+ #define FILE_TIMESTAMP_HI_RES \
+ (2147483647 < INTEGER_TYPE_MAXIMUM (FILE_TIMESTAMP) >> 31)
+ #else
+ #define FILE_TIMESTAMP_HI_RES 0
+ #endif
+
+ int main () { exit(FILE_TIMESTAMP_HI_RES ? 0 : 1); }
+ ], make_cv_hi_res_file_timestamp=yes, make_cv_hi_res_file_timestamp=no,
+ make_cv_hi_res_file_timestamp=no)])
+ AC_MSG_RESULT($make_cv_hi_res_file_timestamp)
+ if test $make_cv_hi_res_file_timestamp = yes; then
+ val=1
+ else
+ val=0
+ fi
+ AC_DEFINE_UNQUOTED(HAVE_HI_RES_FILE_TIMESTAMP, $val,
+ [Define if files can have high resolution timestamps.])
+
+ if test $make_cv_hi_res_file_timestamp = yes; then
+ # Solaris 2.5.1 needs -lposix4 to get the clock_gettime function.
+ # Solaris 7 prefers the library name -lrt to the obsolescent name -lposix4.
+ AC_SEARCH_LIBS(clock_gettime, [rt posix4])
+ if test "$ac_cv_search_clock_gettime" != no; then
+ AC_DEFINE(HAVE_CLOCK_GETTIME, 1,
+ [Define if you have the clock_gettime function.])
+ fi
+ fi
fi
AC_SUBST(LIBOBJS)
***************
*** 73,86 ****
fi
AC_MSG_RESULT($ac_cv_check_symbol_$1)])dnl
- # Solaris 2.5.1 needs -lposix4 to get the clock_gettime function.
- # Solaris 7 prefers the library name -lrt to the obsolescent name -lposix4.
- AC_SEARCH_LIBS(clock_gettime, [rt posix4])
- if test "$ac_cv_search_clock_gettime" != no; then
- AC_DEFINE(HAVE_CLOCK_GETTIME, 1,
- [Define if you have the clock_gettime function.])
- fi
-
# See if we have a standard version of gettimeofday(). Since actual
# implementations can differ, just make sure we have the most common
# one.
--- 120,125 ----
*** make-3.79.1/filedef.h.bak Tue Jun 20 16:00:16 2000
--- make-3.79.1/filedef.h Sat Jul 15 19:34:36 2000
***************
*** 110,122 ****
extern void notice_finished_file PARAMS ((struct file *file));
! #ifdef ST_MTIM_NSEC
! # define FILE_TIMESTAMP_HI_RES \
! (2147483647 < INTEGER_TYPE_MAXIMUM (FILE_TIMESTAMP) >> 31)
# define FILE_TIMESTAMP_STAT_MODTIME(fname, st) \
file_timestamp_cons (fname, (st).st_mtime, (st).st_mtim.ST_MTIM_NSEC)
#else
- # define FILE_TIMESTAMP_HI_RES 0
# define FILE_TIMESTAMP_STAT_MODTIME(fname, st) \
file_timestamp_cons (fname, (st).st_mtime, 0)
#endif
--- 110,119 ----
extern void notice_finished_file PARAMS ((struct file *file));
! #if HAVE_HI_RES_FILE_TIMESTAMP
# define FILE_TIMESTAMP_STAT_MODTIME(fname, st) \
file_timestamp_cons (fname, (st).st_mtime, (st).st_mtim.ST_MTIM_NSEC)
#else
# define FILE_TIMESTAMP_STAT_MODTIME(fname, st) \
file_timestamp_cons (fname, (st).st_mtime, 0)
#endif
***************
*** 126,133 ****
slightly decreasing the number of available timestamps.) With
64-bit FILE_TIMESTAMP, this stops working on 2514-05-30 01:53:04
UTC, but by then uintmax_t should be larger than 64 bits. */
! #define FILE_TIMESTAMPS_PER_S (FILE_TIMESTAMP_HI_RES ? 1000000000 : 1)
! #define FILE_TIMESTAMP_LO_BITS (FILE_TIMESTAMP_HI_RES ? 30 : 0)
#define FILE_TIMESTAMP_S(ts) (((ts) - ORDINARY_MTIME_MIN) \
>> FILE_TIMESTAMP_LO_BITS)
--- 123,130 ----
slightly decreasing the number of available timestamps.) With
64-bit FILE_TIMESTAMP, this stops working on 2514-05-30 01:53:04
UTC, but by then uintmax_t should be larger than 64 bits. */
! #define FILE_TIMESTAMPS_PER_S (HAVE_HI_RES_FILE_TIMESTAMP ? 1000000000 : 1)
! #define FILE_TIMESTAMP_LO_BITS (HAVE_HI_RES_FILE_TIMESTAMP ? 30 : 0)
#define FILE_TIMESTAMP_S(ts) (((ts) - ORDINARY_MTIME_MIN) \
>> FILE_TIMESTAMP_LO_BITS)
*** make-3.79.1/file.c.bak Tue Jun 20 16:00:16 2000
--- make-3.79.1/file.c Sat Jul 15 19:33:47 2000
***************
*** 563,569 ****
time_t s;
int ns;
{
! int offset = ORDINARY_MTIME_MIN + (FILE_TIMESTAMP_HI_RES ? ns : 0);
FILE_TIMESTAMP product = (FILE_TIMESTAMP) s << FILE_TIMESTAMP_LO_BITS;
FILE_TIMESTAMP ts = product + offset;
--- 563,569 ----
time_t s;
int ns;
{
! int offset = ORDINARY_MTIME_MIN + (HAVE_HI_RES_FILE_TIMESTAMP ? ns : 0);
FILE_TIMESTAMP product = (FILE_TIMESTAMP) s << FILE_TIMESTAMP_LO_BITS;
FILE_TIMESTAMP ts = product + offset;
***************
*** 591,621 ****
/* Don't bother with high-resolution clocks if file timestamps have
only one-second resolution. The code below should work, but it's
not worth the hassle of debugging it on hosts where it fails. */
! if (FILE_TIMESTAMP_HI_RES)
! {
! #if HAVE_CLOCK_GETTIME && defined CLOCK_REALTIME
{
! struct timespec timespec;
! if (clock_gettime (CLOCK_REALTIME, ×pec) == 0)
! {
! s = timespec.tv_sec;
! ns = timespec.tv_nsec;
! goto got_time;
! }
}
! #endif
! #if HAVE_GETTIMEOFDAY
{
! struct timeval timeval;
! if (gettimeofday (&timeval, 0) == 0)
! {
! s = timeval.tv_sec;
! ns = timeval.tv_usec * 1000;
! goto got_time;
! }
}
#endif
- }
s = time ((time_t *) 0);
ns = 0;
--- 591,620 ----
/* Don't bother with high-resolution clocks if file timestamps have
only one-second resolution. The code below should work, but it's
not worth the hassle of debugging it on hosts where it fails. */
! #if HAVE_HI_RES_FILE_TIMESTAMP
! # if HAVE_CLOCK_GETTIME && defined CLOCK_REALTIME
! {
! struct timespec timespec;
! if (clock_gettime (CLOCK_REALTIME, ×pec) == 0)
{
! s = timespec.tv_sec;
! ns = timespec.tv_nsec;
! goto got_time;
}
! }
! # endif
! # if HAVE_GETTIMEOFDAY
! {
! struct timeval timeval;
! if (gettimeofday (&timeval, 0) == 0)
{
! s = timeval.tv_sec;
! ns = timeval.tv_usec * 1000;
! goto got_time;
}
+ }
+ # endif
#endif
s = time ((time_t *) 0);
ns = 0;