From nobody@FreeBSD.org  Thu Sep  7 21:51:19 2006
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 56F7516A4E0
	for <freebsd-gnats-submit@FreeBSD.org>; Thu,  7 Sep 2006 21:51:19 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (www.freebsd.org [216.136.204.117])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 0B73543D53
	for <freebsd-gnats-submit@FreeBSD.org>; Thu,  7 Sep 2006 21:51:19 +0000 (GMT)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.13.1/8.13.1) with ESMTP id k87LpICA037562
	for <freebsd-gnats-submit@FreeBSD.org>; Thu, 7 Sep 2006 21:51:18 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.13.1/8.13.1/Submit) id k87LpIGL037561;
	Thu, 7 Sep 2006 21:51:18 GMT
	(envelope-from nobody)
Message-Id: <200609072151.k87LpIGL037561@www.freebsd.org>
Date: Thu, 7 Sep 2006 21:51:18 GMT
From: Peter Grehan <grehan@FreeBSD.org>
To: freebsd-gnats-submit@FreeBSD.org
Subject: powerpc cross-build fails on amd64 host, works fine on i386
X-Send-Pr-Version: www-2.3

>Number:         102996
>Category:       amd64
>Synopsis:       powerpc cross-build fails on amd64 host, works fine on i386
>Confidential:   no
>Severity:       serious
>Priority:       low
>Responsible:    obrien
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Sep 07 22:00:33 GMT 2006
>Closed-Date:    Wed Mar 28 02:45:56 GMT 2007
>Last-Modified:  Wed Mar 28 02:50:05 GMT 2007
>Originator:     Peter Grehan
>Release:        6.0
>Organization:
>Environment:
FreeBSD *redacted* 6.0-RELEASE FreeBSD 6.0-RELEASE #0: Wed Nov  2 19:07:38 UTC 2005     root@rat.samsco.home:/usr/obj/usr/src/sys/GENERIC  amd64
>Description:
A powerpc build (any release) fails on amd64. The same tree on a 32-bit host works fine. I believe it will fail on other 64-bit arches though I haven't verified this.

>How-To-Repeat:
make TARGET_ARCH=powerpc buildworld
>Fix:
I applied the following diff supplied by Ruslan Ermilov: worked fine.

%%%
Index: Makefile
===================================================================
RCS file: /home/ncvs/src/gnu/usr.bin/binutils/libbfd/Makefile,v
retrieving revision 1.33
diff -u -r1.33 Makefile
--- Makefile	24 Oct 2004 15:32:25 -0000	1.33
+++ Makefile	26 Aug 2006 00:48:26 -0000
@@ -48,6 +48,12 @@
 CFLAGS+= -DSELECT_VECS="${SELVEC}"
 CFLAGS+= -DDEFAULT_VECTOR=${DEFAULT_VECTOR}
 
+.if ${TARGET_ARCH:M*64}
+CFLAGS+= -DTARGET_64BIT=1
+.else
+CFLAGS+= -DTARGET_64BIT=0
+.endif
+
 # XXX:DEO should grab BFD_VERSION_DATE from ${VERSION}...
 bfdver.h: Makefile
 	echo '#define BFD_VERSION	215000000'	> ${.TARGET}
Index: bfd.h
===================================================================
RCS file: /home/ncvs/src/gnu/usr.bin/binutils/libbfd/bfd.h,v
retrieving revision 1.3
diff -u -r1.3 bfd.h
--- bfd.h	8 Jul 2004 17:05:32 -0000	1.3
+++ bfd.h	26 Aug 2006 00:44:29 -0000
@@ -57,15 +57,18 @@
 #define BFD_ARCH_SIZE 64
 
 
-#if defined(__i386__) || defined(__powerpc__) || defined(__arm__)
 /* The word size of the default bfd target.  */
+#if TARGET_64BIT
+#define BFD_DEFAULT_TARGET_SIZE 64
+#else
 #define BFD_DEFAULT_TARGET_SIZE 32
+#endif
+
+#if defined(__i386__) || defined(__powerpc__) || defined(__arm__)
 #define BFD_HOST_64BIT_LONG 0
 #define BFD_HOST_64_BIT long long
 #define BFD_HOST_U_64_BIT unsigned long long
 #elif defined(__alpha__) || defined(__sparc64__) || defined(__amd64__) || defined(__ia64__)
-/* The word size of the default bfd target.  */
-#define BFD_DEFAULT_TARGET_SIZE 64
 #define BFD_HOST_64BIT_LONG 1
 #define BFD_HOST_64_BIT long
 #define BFD_HOST_U_64_BIT unsigned long
%%%


>Release-Note:
>Audit-Trail:

From: John Baldwin <jhb@freebsd.org>
To: freebsd-amd64@freebsd.org
Cc: Peter Grehan <grehan@freebsd.org>, freebsd-gnats-submit@freebsd.org
Subject: Re: amd64/102996: powerpc cross-build fails on amd64 host, works fine on i386
Date: Fri, 8 Sep 2006 11:10:52 -0400

 On Thursday 07 September 2006 17:51, Peter Grehan wrote:
 > %%%
 > Index: Makefile
 > ===================================================================
 > RCS file: /home/ncvs/src/gnu/usr.bin/binutils/libbfd/Makefile,v
 > retrieving revision 1.33
 > diff -u -r1.33 Makefile
 > --- Makefile	24 Oct 2004 15:32:25 -0000	1.33
 > +++ Makefile	26 Aug 2006 00:48:26 -0000
 > @@ -48,6 +48,12 @@
 >  CFLAGS+= -DSELECT_VECS="${SELVEC}"
 >  CFLAGS+= -DDEFAULT_VECTOR=${DEFAULT_VECTOR}
 >  
 > +.if ${TARGET_ARCH:M*64}
 > +CFLAGS+= -DTARGET_64BIT=1
 > +.else
 > +CFLAGS+= -DTARGET_64BIT=0
 > +.endif
 > +
 
 This doesn't match alpha (though that only matters if you MFC this).  Seems 
 that a more general purpose solution would be to test TARGET_ARCH and use 
 that to set TARGET properties (i.e. the bug seems to be that it's setting 
 TARGET properties based on the host arch, which is wrong).
 
 -- 
 John Baldwin

From: Peter Grehan <grehan@freebsd.org>
To: John Baldwin <jhb@freebsd.org>
Cc: freebsd-amd64@freebsd.org, freebsd-gnats-submit@freebsd.org
Subject: Re: amd64/102996: powerpc cross-build fails on amd64 host, works
 fine on i386
Date: Fri, 08 Sep 2006 14:04:38 -0700

 > This doesn't match alpha (though that only matters if you MFC this).  Seems 
 > that a more general purpose solution would be to test TARGET_ARCH and use 
 > that to set TARGET properties
 
   Yes - setting TARGET_64BIT in the appropriate libbfd/Makefile.{arch} 
 would be another way. But it's Ruslan's/David's area so I'll leave it up 
 to them for the fix.
 
 > (i.e. the bug seems to be that it's setting 
 > TARGET properties based on the host arch, which is wrong).
 
   Agreed !!
 
 later,
 
 Peter.
 

From: Ruslan Ermilov <ru@FreeBSD.org>
To: bug-followup@FreeBSD.org
Cc: John Baldwin <jhb@FreeBSD.org>, Peter Grehan <grehan@FreeBSD.org>
Subject: Re: amd64/102996: powerpc cross-build fails on amd64 host, works fine on i386
Date: Thu, 14 Sep 2006 11:49:37 +0400

 On Fri, Sep 08, 2006 at 11:10:52AM -0400, John Baldwin wrote:
 > On Thursday 07 September 2006 17:51, Peter Grehan wrote:
 > > %%%
 > > Index: Makefile
 > > ===================================================================
 > > RCS file: /home/ncvs/src/gnu/usr.bin/binutils/libbfd/Makefile,v
 > > retrieving revision 1.33
 > > diff -u -r1.33 Makefile
 > > --- Makefile	24 Oct 2004 15:32:25 -0000	1.33
 > > +++ Makefile	26 Aug 2006 00:48:26 -0000
 > > @@ -48,6 +48,12 @@
 > >  CFLAGS+= -DSELECT_VECS="${SELVEC}"
 > >  CFLAGS+= -DDEFAULT_VECTOR=${DEFAULT_VECTOR}
 > >  
 > > +.if ${TARGET_ARCH:M*64}
 > > +CFLAGS+= -DTARGET_64BIT=1
 > > +.else
 > > +CFLAGS+= -DTARGET_64BIT=0
 > > +.endif
 > > +
 > 
 > This doesn't match alpha (though that only matters if you MFC this).  Seems 
 > that a more general purpose solution would be to test TARGET_ARCH and use 
 > that to set TARGET properties
 > 
 I just quickly prototyped the patch back then.  How's this instead?
 
 %%%
 Index: Makefile
 ===================================================================
 RCS file: /home/ncvs/src/gnu/usr.bin/binutils/libbfd/Makefile,v
 retrieving revision 1.33
 diff -u -p -u -r1.33 Makefile
 --- Makefile	24 Oct 2004 15:32:25 -0000	1.33
 +++ Makefile	14 Sep 2006 07:45:19 -0000
 @@ -48,6 +48,14 @@ SELVEC+= ,&${_v}
  CFLAGS+= -DSELECT_VECS="${SELVEC}"
  CFLAGS+= -DDEFAULT_VECTOR=${DEFAULT_VECTOR}
  
 +.if ${DEFAULT_VECTOR:Mbfd_elf64_*}
 +CFLAGS+= -DTARGET_64BIT=1
 +.elif ${DEFAULT_VECTOR:Mbfd_elf32_*}
 +CFLAGS+= -DTARGET_64BIT=0
 +.else
 +.error unknown DEFAULT_VECTOR=${DEFAULT_VECTOR}
 +.endif
 +
  # XXX:DEO should grab BFD_VERSION_DATE from ${VERSION}...
  bfdver.h: Makefile
  	echo '#define BFD_VERSION	215000000'	> ${.TARGET}
 Index: bfd.h
 ===================================================================
 RCS file: /home/ncvs/src/gnu/usr.bin/binutils/libbfd/bfd.h,v
 retrieving revision 1.3
 diff -u -p -u -r1.3 bfd.h
 --- bfd.h	8 Jul 2004 17:05:32 -0000	1.3
 +++ bfd.h	14 Sep 2006 07:34:28 -0000
 @@ -57,15 +57,18 @@ extern "C" {
  #define BFD_ARCH_SIZE 64
  
  
 -#if defined(__i386__) || defined(__powerpc__) || defined(__arm__)
  /* The word size of the default bfd target.  */
 +#if TARGET_64BIT
 +#define BFD_DEFAULT_TARGET_SIZE 64
 +#else
  #define BFD_DEFAULT_TARGET_SIZE 32
 +#endif
 +
 +#if defined(__i386__) || defined(__powerpc__) || defined(__arm__)
  #define BFD_HOST_64BIT_LONG 0
  #define BFD_HOST_64_BIT long long
  #define BFD_HOST_U_64_BIT unsigned long long
  #elif defined(__alpha__) || defined(__sparc64__) || defined(__amd64__) || defined(__ia64__)
 -/* The word size of the default bfd target.  */
 -#define BFD_DEFAULT_TARGET_SIZE 64
  #define BFD_HOST_64BIT_LONG 1
  #define BFD_HOST_64_BIT long
  #define BFD_HOST_U_64_BIT unsigned long
 %%%
 
 > (i.e. the bug seems to be that it's setting 
 > TARGET properties based on the host arch, which is wrong).
 > 
 Exactly!
 
 
 Cheers,
 -- 
 Ruslan Ermilov
 ru@FreeBSD.org
 FreeBSD committer
Responsible-Changed-From-To: freebsd-amd64->obrien 
Responsible-Changed-By: ru 
Responsible-Changed-When: Thu Sep 14 08:07:01 UTC 2006 
Responsible-Changed-Why:  
Pass over to the BU maintainer. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=102996 
State-Changed-From-To: open->patched 
State-Changed-By: marcel 
State-Changed-When: Sun Feb 11 07:15:39 UTC 2007 
State-Changed-Why:  
A fix has been committed to -CURRENT. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=102996 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: amd64/102996: commit references a PR
Date: Sun, 11 Feb 2007 07:15:15 +0000 (UTC)

 marcel      2007-02-11 07:15:06 UTC
 
   FreeBSD src repository
 
   Modified files:
     gnu/usr.bin/binutils Makefile.inc0 
     gnu/usr.bin/binutils/libbfd bfd.h 
   Log:
   Fix PowerPC-targeted cross-builds performed on 64-bit platforms.
   Only PowerPC supports both 32-bit and 64-bit targets and the
   BFD_DEFAULT_TARGET_SIZE is used by the binutils code to reflect
   the preferred ABI. We define BFD_DEFAULT_TARGET_SIZE for all
   platforms, but based on the build machine. As such 64-bit build
   machines defined BFD_DEFAULT_TARGET_SIZE incorrectly for 32-bit
   targets, but since this only affects PowerPC it went unnoticed
   for a long time.
   The fix is to define BFD_DEFAULT_TARGET_SIZE based on the target
   architecture.
   
   PR: amd64/102996
   MFC after: 1 month
   
   Revision  Changes    Path
   1.38      +6 -0      src/gnu/usr.bin/binutils/Makefile.inc0
   1.4       +0 -4      src/gnu/usr.bin/binutils/libbfd/bfd.h
 _______________________________________________
 cvs-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/cvs-all
 To unsubscribe, send any mail to "cvs-all-unsubscribe@freebsd.org"
 
State-Changed-From-To: patched->closed 
State-Changed-By: marcel 
State-Changed-When: Wed Mar 28 02:45:36 UTC 2007 
State-Changed-Why:  
MFC'd 

http://www.freebsd.org/cgi/query-pr.cgi?pr=102996 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: amd64/102996: commit references a PR
Date: Wed, 28 Mar 2007 02:44:46 +0000 (UTC)

 marcel      2007-03-28 02:44:37 UTC
 
   FreeBSD src repository
 
   Modified files:        (Branch: RELENG_6)
     gnu/usr.bin/binutils Makefile.inc0 
     gnu/usr.bin/binutils/libbfd bfd.h 
   Log:
   MFC: Fix PowerPC-targeted cross-builds performed on 64-bit platforms.
           Makefile.inc0:1.38
           libbfd/bfd.h:1.4
   
   PR: amd64/102996
   
   Revision  Changes    Path
   1.37.8.1  +6 -0      src/gnu/usr.bin/binutils/Makefile.inc0
   1.3.8.1   +0 -4      src/gnu/usr.bin/binutils/libbfd/bfd.h
 _______________________________________________
 cvs-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/cvs-all
 To unsubscribe, send any mail to "cvs-all-unsubscribe@freebsd.org"
 
>Unformatted:
