bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

mktime.c compilation error on Solaris 11


From: Bruno Haible
Subject: mktime.c compilation error on Solaris 11
Date: Sun, 08 Jan 2012 15:03:33 +0100
User-agent: KMail/4.7.4 (Linux/3.1.0-1.2-desktop; KDE/4.7.4; x86_64; ; )

On Solaris 11 2011-11 the vendor gcc 4.5.2 cannot compile gnulib's mktime.c:

$ make
...
gcc -std=gnu99 -DHAVE_CONFIG_H -I. -I..  -DGNULIB_STRICT_CHECKING=1  -Wall 
-D_REENTRANT  -g -O2 -MT mktime.o -MD -MP -MF $depbase.Tpo -c -o mktime.o 
mktime.c &&\
mv -f $depbase.Tpo $depbase.Po
Assembler: mktime.c
        "/var/tmp//ccGla4PN.s", line 10 : .align test amount has negative value
        "/var/tmp//ccGla4PN.s", line 131 : .align test amount has negative value
        "/var/tmp//ccGla4PN.s", line 355 : .align test amount has negative value
        "/var/tmp//ccGla4PN.s", line 1111 : .align test amount has negative 
value
*** Error code 1

Indeed, find attached the output of
$ gcc -std=gnu99 -DHAVE_CONFIG_H -I. -I..  -DGNULIB_STRICT_CHECKING=1  -Wall 
-D_REENTRANT  -O2 -S mktime.c -o mktime1.s
$ gcc -std=gnu99 -DHAVE_CONFIG_H -I. -I..  -DGNULIB_STRICT_CHECKING=1  -Wall 
-D_REENTRANT  -O2 -S mktime.c -DWRAPV -o mktime2.s

As you can see, the use of
  #pragma GCC optimize ("wrapv")
apparently replaces the valid asm statements
  .p2align 4,,15
with
  .p2align 4,,-1

For the semantics of .p2align, see
http://sourceware.org/binutils/docs/as/P2align.html

I can reproduce the effect with gcc-4.5.2 built from source on a glibc system.
The difference is that the GNU assembler accepts the .p2align 4,,-1
pseudo-instruction, while the Solaris assembler doesn't.

I've registered this bug as <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51793>.

As a workaround, I would propose to emit this #pragma only on platforms
where we can be sure that GNU as is used. Namely, glibc systems.


2012-01-08  Bruno Haible  <address@hidden>

        mktime: Avoid compilation error on Solaris 11.
        * lib/mktime.c (WRAPV): Define to 0 on all non-glibc systems.

--- lib/mktime.c.orig   Sun Jan  8 14:27:58 2012
+++ lib/mktime.c        Sun Jan  8 14:27:51 2012
@@ -25,24 +25,6 @@
 # include <config.h>
 #endif
 
-/* Some of the code in this file assumes that signed integer overflow
-   silently wraps around.  This assumption can't easily be programmed
-   around, nor can it be checked for portably at compile-time or
-   easily eliminated at run-time.
-
-   Define WRAPV to 1 if the assumption is valid.  Otherwise, define it
-   to 0; this forces the use of slower code that, while not guaranteed
-   by the C Standard, works on all production platforms that we know
-   about.  */
-#ifndef WRAPV
-# if (__GNUC__ == 4 && 4 <= __GNUC_MINOR__) || 4 < __GNUC__
-#  pragma GCC optimize ("wrapv")
-#  define WRAPV 1
-# else
-#  define WRAPV 0
-# endif
-#endif
-
 /* Assume that leap seconds are possible, unless told otherwise.
    If the host has a 'zic' command with a '-L leapsecondfilename' option,
    then it supports leap seconds; otherwise it probably doesn't.  */
@@ -64,6 +46,26 @@
 # define mktime my_mktime
 #endif /* DEBUG */
 
+/* Some of the code in this file assumes that signed integer overflow
+   silently wraps around.  This assumption can't easily be programmed
+   around, nor can it be checked for portably at compile-time or
+   easily eliminated at run-time.
+
+   Define WRAPV to 1 if the assumption is valid and if
+     #pragma GCC optimize ("wrapv")
+   does not trigger GCC bug 
<http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51793>.
+   Otherwise, define it to 0; this forces the use of slower code that,
+   while not guaranteed by the C Standard, works on all production
+   platforms that we know about.  */
+#ifndef WRAPV
+# if ((__GNUC__ == 4 && 4 <= __GNUC_MINOR__) || 4 < __GNUC__) && defined 
__GLIBC__
+#  pragma GCC optimize ("wrapv")
+#  define WRAPV 1
+# else
+#  define WRAPV 0
+# endif
+#endif
+
 /* Verify a requirement at compile-time (unlike assert, which is runtime).  */
 #define verify(name, assertion) struct name { char a[(assertion) ? 1 : -1]; }
 

Attachment: mktime1.s
Description: Text document

Attachment: mktime2.s
Description: Text document


reply via email to

[Prev in Thread] Current Thread [Next in Thread]