diff mbox

fix bootstrap on FreeBSD i386/arm

Message ID 5569828A.9080304@fgznet.ch
State New
Headers show

Commit Message

Andreas Tobler May 30, 2015, 9:27 a.m. UTC
Hi Steve,

On 29.05.15 19:18, Steve Ellcey wrote:
> On Thu, 2015-05-28 at 23:54 +0200, Eric Botcazou wrote:
>>> This patch restores bootstrap on i386-*-freebsd*.
>>> The build was failing after the introduction of -std=c++98
>>> configure/build flag. The -std=c++98 enables strict_ansi and on FreeBSD
>>> the libc function atoll is not defined for this.
>>
>> Solaris (x86 and SPARC) is also broken in various ways: for example, the "sun"
>> preprocessor macro is no more defined.  Why do we need strict ANSI exactly?
>
> Andreas,
>
> This patch (or the earlier one) is also breaking a build of my MIPS
> cross compiler.  On CentOS 5.11 (yes I know that is old) I can build a
> cross compiler where the executables are x86_64 objects but not when
> they are i386 objects (i.e. when using -m32 to build GCC).  The error
> is duplicate atoll definitions (one in read-rtl.c and one in stdlib.h).
>
> I may be mistaken but think when you moved the atoll check from
> AC_CHECK_FUNCS to gcc_AC_CHECK_DECLS you needed to change config.in and
> read-rtl.c because gcc_AC_CHECK_DECLS sets HAVE_DECL_ATOLL instead of
> HAVE_ATOLL.

I'm sorry. I totally forgot about autoheader...

I'm testing this one now. Would you mind giving it a try?

Thanks,
Andreas

Comments

Steve Ellcey June 1, 2015, 2:43 p.m. UTC | #1
On Sat, 2015-05-30 at 11:27 +0200, Andreas Tobler wrote:

> 
> I'm sorry. I totally forgot about autoheader...
> 
> I'm testing this one now. Would you mind giving it a try?
> 
> Thanks,
> Andreas

This patch worked for me.  I am curious about why you use
'!HAVE_DECL_ATOLL' in read-rtl.c instead of '!defined(HAVE_DECL_ATOLL)'.
The use of !defined seems more common and is used in the HAVE_ATOQ check
in the same #if statement.

Steve Ellcey
Andreas Tobler June 1, 2015, 3:07 p.m. UTC | #2
On 01.06.15 16:43, Steve Ellcey wrote:
> On Sat, 2015-05-30 at 11:27 +0200, Andreas Tobler wrote:
>
>>
>> I'm sorry. I totally forgot about autoheader...
>>
>> I'm testing this one now. Would you mind giving it a try?
>>
>> Thanks,
>> Andreas
>
> This patch worked for me.  I am curious about why you use
> '!HAVE_DECL_ATOLL' in read-rtl.c instead of '!defined(HAVE_DECL_ATOLL)'.
> The use of !defined seems more common and is used in the HAVE_ATOQ check
> in the same #if statement.

Because HAVE_DECL_ATOLL is either defined as 0 or 1. So it is always 
defined. HAVE_ATOQ on the other side is only defined if it is available.

 From config.in:
----
/* Define to 1 if we found a declaration for 'atoll', otherwise define to 0.
    */
#ifndef USED_FOR_TARGET
#undef HAVE_DECL_ATOLL
#endif
----

Andreas
Steve Ellcey June 1, 2015, 3:20 p.m. UTC | #3
On Mon, 2015-06-01 at 17:07 +0200, Andreas Tobler wrote:

> > This patch worked for me.  I am curious about why you use
> > '!HAVE_DECL_ATOLL' in read-rtl.c instead of '!defined(HAVE_DECL_ATOLL)'.
> > The use of !defined seems more common and is used in the HAVE_ATOQ check
> > in the same #if statement.
> 
> Because HAVE_DECL_ATOLL is either defined as 0 or 1. So it is always 
> defined. HAVE_ATOQ on the other side is only defined if it is available.
> 
>  From config.in:
> ----
> /* Define to 1 if we found a declaration for 'atoll', otherwise define to 0.
>     */
> #ifndef USED_FOR_TARGET
> #undef HAVE_DECL_ATOLL
> #endif
> ----
> 
> Andreas

Ah, I looked at the code but didn't read the comment.  When I look at
auto-host.h I see that the header does what the comment says it does.
Thanks for the explanation.

Steve Ellcey
sellcey@imgtec.com
diff mbox

Patch

Index: config.in
===================================================================
--- config.in	(revision 223885)
+++ config.in	(working copy)
@@ -624,12 +624,6 @@ 
 #endif
 
 
-/* Define to 1 if you have the `atoll' function. */
-#ifndef USED_FOR_TARGET
-#undef HAVE_ATOLL
-#endif
-
-
 /* Define to 1 if you have the `atoq' function. */
 #ifndef USED_FOR_TARGET
 #undef HAVE_ATOQ
@@ -686,9 +680,16 @@ 
 #endif
 
 
-/* Define to 1 if we found a declaration for 'basename', otherwise define to
-   0. */
+/* Define to 1 if we found a declaration for 'atoll', otherwise define to 0.
+   */
 #ifndef USED_FOR_TARGET
+#undef HAVE_DECL_ATOLL
+#endif
+
+
+/* Define to 1 if you have the declaration of `basename(const char*)', and to
+   0 if you don't. */
+#ifndef USED_FOR_TARGET
 #undef HAVE_DECL_BASENAME
 #endif
 
@@ -963,8 +964,8 @@ 
 #endif
 
 
-/* Define to 1 if we found a declaration for 'strstr', otherwise define to 0.
-   */
+/* Define to 1 if you have the declaration of `strstr(const char*,const
+   char*)', and to 0 if you don't. */
 #ifndef USED_FOR_TARGET
 #undef HAVE_DECL_STRSTR
 #endif
Index: read-rtl.c
===================================================================
--- read-rtl.c	(revision 223885)
+++ read-rtl.c	(working copy)
@@ -704,7 +704,7 @@ 
 
 /* Provide a version of a function to read a long long if the system does
    not provide one.  */
-#if HOST_BITS_PER_WIDE_INT > HOST_BITS_PER_LONG && !defined(HAVE_ATOLL) && !defined(HAVE_ATOQ)
+#if HOST_BITS_PER_WIDE_INT > HOST_BITS_PER_LONG && !HAVE_DECL_ATOLL && !defined(HAVE_ATOQ)
 HOST_WIDE_INT atoll (const char *);
 
 HOST_WIDE_INT
@@ -1328,7 +1328,7 @@ 
 #else
 	/* Prefer atoll over atoq, since the former is in the ISO C99 standard.
 	   But prefer not to use our hand-rolled function above either.  */
-#if defined(HAVE_ATOLL) || !defined(HAVE_ATOQ)
+#if HAVE_DECL_ATOLL || !defined(HAVE_ATOQ)
 	tmp_wide = atoll (name.string);
 #else
 	tmp_wide = atoq (name.string);