[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Static link failure lib/mktime.c
From: |
Jim Meyering |
Subject: |
Re: Static link failure lib/mktime.c |
Date: |
Tue Nov 19 03:00:02 2002 |
Greg Schafer <address@hidden> wrote:
> This is i686-pc-linux-gnu
>
> glibc-2.2.5
> gcc-3.2
>
> Trying a static link ("make LDFLAGS=-static") results in:-
>
> gcc -g -O2 -static -o dir ls.o ls-dir.o ../lib/libfetish.a
> ../lib/libfetish.a -lrt
> /usr/lib/gcc-lib/i686-pc-linux-gnu/3.2/../../../libc.a(mktime.o)(.rodata+0x0):
> multiple definition of `__mon_yday'
> ../lib/libfetish.a(mktime.o):/home/gws/src/temp/temp/coreutils-4.5.3/lib/mktime.c:120:
> first defined here
> /usr/lib/gcc-lib/i686-pc-linux-gnu/3.2/../../../libc.a(mktime.o): In function
> `__mktime_internal':
> mktime.o(.text+0x200): multiple definition of `__mktime_internal'
> ../lib/libfetish.a(mktime.o):/home/gws/src/temp/temp/coreutils-4.5.3/lib/mktime.c:220:
> first defined here
> /usr/bin/ld: Warning: size of symbol `__mktime_internal' changed from 1278 to
> 1129 in /usr/lib/gcc-lib/i686-pc-linux-gnu/3.2/../../../libc.a(mktime.o)
> collect2: ld returned 1 exit status
> make[3]: *** [dir] Error 1
Thank you for the nice bug report and suggested patch!
Here's the change I've made:
Avoid a link-time failure on some Linux systems.
* mktime.c (STATIC): Define to be empty (_LIBC) or `static' (otherwise).
(__mon_yday): Declare with the STATIC attribute.
(__mktime_internal): Likewise.
Based on a report from Greg Schafer.
Index: lib/mktime.c
===================================================================
RCS file: /fetish/cu/lib/mktime.c,v
retrieving revision 1.30
diff -u -p -u -p -r1.30 mktime.c
--- lib/mktime.c 31 Aug 2002 16:46:40 -0000 1.30
+++ lib/mktime.c 19 Nov 2002 07:54:33 -0000
@@ -29,6 +29,9 @@
#ifdef _LIBC
# define HAVE_LIMITS_H 1
# define STDC_HEADERS 1
+# define STATIC /* empty */
+#else
+# define STATIC static
#endif
/* Assume that leap seconds are possible, unless told otherwise.
@@ -100,7 +103,7 @@
#endif
/* How many days come before each month (0-12). */
-const unsigned short int __mon_yday[2][13] =
+STATIC const unsigned short int __mon_yday[2][13] =
{
/* Normal years. */
{ 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365 },
@@ -213,7 +216,7 @@ ranged_convert (struct tm *(*convert) (c
Use *OFFSET to keep track of a guess at the offset of the result,
compared to what the result would be for UTC without leap seconds.
If *OFFSET's guess is correct, only one CONVERT call is needed. */
-time_t
+STATIC time_t
__mktime_internal (struct tm *tp,
struct tm *(*convert) (const time_t *, struct tm *),
time_t *offset)