From mi@aldan.algebra.com  Mon May  1 01:07:43 2006
Return-Path: <mi@aldan.algebra.com>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id C0D5816A400;
	Mon,  1 May 2006 01:07:43 +0000 (UTC)
	(envelope-from mi@aldan.algebra.com)
Received: from aldan.algebra.com (aldan.algebra.com [216.254.65.224])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 523A843D53;
	Mon,  1 May 2006 01:07:43 +0000 (GMT)
	(envelope-from mi@aldan.algebra.com)
Received: from aldan.algebra.com (aldan [127.0.0.1])
	by aldan.algebra.com (8.13.6/8.13.6) with ESMTP id k4117gRV015743
	(version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO);
	Sun, 30 Apr 2006 21:07:42 -0400 (EDT)
	(envelope-from mi@aldan.algebra.com)
Received: (from mi@localhost)
	by aldan.algebra.com (8.13.6/8.13.6/Submit) id k4117fFP015742;
	Sun, 30 Apr 2006 21:07:41 -0400 (EDT)
	(envelope-from mi)
Message-Id: <200605010107.k4117fFP015742@aldan.algebra.com>
Date: Sun, 30 Apr 2006 21:07:41 -0400 (EDT)
From: "Mikhail T." <mi@aldan.algebra.com>
To: FreeBSD-gnats-submit@freebsd.org
Cc: re@freebsd.org
Subject: cc can't build 32-bit executables on amd64
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         96570
>Category:       gnu
>Synopsis:       [patch] cc can't build 32-bit executables on amd64
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    obrien
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon May 01 01:10:17 GMT 2006
>Closed-Date:    Sat May 06 23:32:07 GMT 2006
>Last-Modified:  Mon May  8 15:00:36 GMT 2006
>Originator:     Mikhail T.
>Release:        FreeBSD 6.1-RC amd64
>Organization:
Virtual Estates, Inc.
>Environment:
System: FreeBSD aldan.algebra.com 6.1-RC FreeBSD 6.1-RC #4: Sat Apr 15 14:53:29 EDT 2006 root@aldan.algebra.com:/meow/obj/var/src/sys/SILVER amd64

>Description:

	``cc -m32'' currently succeeds _compiling_, but fails linking
	the program, because it looks for libgcc.a in /usr/lib, where
	it finds the 64-bit flavor.

	This is a shame, because the 32-bit library is built and
	available in /usr/lib32 -- cc just needs to know to look
	there, when given the ``-m32'' flag.

>How-To-Repeat:

	echo 'main() {}' > t.c
	cc -m32 t.c
	/usr/bin/ld: skipping incompatible /usr/lib/libgcc.a when
	searching for -lgcc
	/usr/bin/ld: cannot find -lgcc

>Fix:

	The details of the contrib/gcc/gcc.c appear hairy to a novice
	like myself, but it should not be too difficult for a seasoned
	developer to fix this configuration problem. Or so I think :-)

	Renaming /usr/lib to /usr/lib64 and /usr/lib32 to /usr/lib
	allows creation of 32-bit executables, but, obviously, prevents
	creation of the 64-bit ones (and starting many programs).

	This has been a nuissance since the beginning of the
	FreeBSD/amd64, I guess. It would be nice to see it resolved
	in the upcoming 6.1.
>Release-Note:
>Audit-Trail:

From: Mikhail Teterin <mi+kde@aldan.algebra.com>
To: bug-followup@freebsd.org
Cc:  
Subject: Re: conf/96570: cc can't build 32-bit executables on amd64
Date: Sun, 30 Apr 2006 23:52:38 -0400

 --Boundary-00=_HYYVEiAWkBPnnPv
 Content-Type: text/plain;
   charset="us-ascii"
 Content-Transfer-Encoding: 7bit
 Content-Disposition: inline
 
 The attached patch is a little dirty, but works. It may be an acceptable 
 stop-gap for the upcoming release, until a knowledgeable person comes up with 
 something cleaner.
 
 The gcc produced with this patch, for example, allows to compile lame 
 with -m32, thus utilizing i386-only assembler optimizations.
 
 	-mi
 
 --Boundary-00=_HYYVEiAWkBPnnPv
 Content-Type: text/x-diff;
   charset="us-ascii";
   name="cc-m32.diff"
 Content-Transfer-Encoding: 7bit
 Content-Disposition: attachment;
 	filename="cc-m32.diff"
 
 Index: Makefile
 ===================================================================
 RCS file: /home/ncvs/src/gnu/usr.bin/cc/cc_tools/Makefile,v
 retrieving revision 1.81
 diff -d -U2 -r1.81 Makefile
 --- Makefile	3 Jun 2005 04:21:04 -0000	1.81
 +++ Makefile	1 May 2006 03:34:43 -0000
 @@ -371,8 +371,15 @@
  
  multilib.h:
 +.if ${TARGET_ARCH} == "amd64"
 +	echo 'static const char *const multilib_raw[] = { \
 +	    "aout maout;", "../lib32 32;", "elf !maout;", NULL };'	> ${.TARGET}
 +	echo 'static const char *const multilib_matches_raw[] = { \
 +	    "maout maout;", "m32 32;", "melf melf;", NULL };'	>> ${.TARGET}
 +.else
  	echo 'static const char *const multilib_raw[] = { \
  	    "aout maout;", "elf !maout;", NULL };'	> ${.TARGET}
  	echo 'static const char *const multilib_matches_raw[] = { \
  	    "maout maout;", "melf melf;", NULL };'	>> ${.TARGET}
 +.endif
  	echo 'static const char *multilib_extra = "";'	>> ${.TARGET}
  	echo 'static const char *multilib_options = "";'>> ${.TARGET}
 
 --Boundary-00=_HYYVEiAWkBPnnPv--

Adding to audit trail from misfiled PR gnu/96571:

Date: Sun, 30 Apr 2006 19:12:07 -0600
From: Scott Long <scottl@samsco.org>
 
 It's not going to be resolved in the upcoming 6.1 unless someone can
 produce a patch that reliably works and passes peer review in the next
 7 days.
 
 Scott

From: Doug White <dwhite@gumbysoft.com>
To: bug-followup@freebsd.org
Cc:  
Subject: Re: gnu/96570: [patch] cc can't build 32-bit executables on amd64
Date: Mon, 1 May 2006 15:34:39 -0700 (PDT)

 Sean Bryant <bryants@gmail.com> pointed out that if you run your cc as:
 
 cc -m32 -B/usr/lib32 -B/usr/local/lib32 t.c
 
 then you'll get a working binary.
 
 -- 
 Doug White                    |  FreeBSD: The Power to Serve
 dwhite@gumbysoft.com          |  www.FreeBSD.org
Responsible-Changed-From-To: freebsd-bugs->obrien 
Responsible-Changed-By: mi 
Responsible-Changed-When: Tue May 2 01:06:02 UTC 2006 
Responsible-Changed-Why:  
Assigned to David upon his request. 

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

From: Mikhail Teterin <mi+kde@aldan.algebra.com>
To: bug-followup@freebsd.org, Scott Long <scottl@samsco.org>
Cc:  
Subject: Re: gnu/96570: [patch] cc can't build 32-bit executables on amd64
Date: Thu, 4 May 2006 23:15:31 -0400

 The evidence of a successful buildworld with this patch is now available in
 
 	http://aldan.algebra.com/~mi/world-with-m32-patched-gcc.log.bz2
 
 Yours,
 
 	-mi

From: Mikhail Teterin <mi+kde@aldan.algebra.com>
To: portmgr@freebsd.org
Cc: bug-followup@freebsd.org
Subject: Re: gnu/96570: [patch] cc can't build 32-bit executables on amd64
Date: Thu, 4 May 2006 23:22:23 -0400

 Gentlemen!
 
 The PR in subject modifies (however slightly) the cc compiler on amd64. As 
 such, Release Engineers (Scott) insist, the change be tested on the ports 
 cluster in addition to the usual "buildworld" test.
 
 All the change does is it makes the /usr/lib/../lib32 the standard location of 
 libraries and the crt* objects, when the user specifies -m32 flag on amd64.
 
 Could such a test, please, be arranged some time soon? Thank you!
 
 	-mi

From: Kris Kennaway <kris@obsecurity.org>
To: Mikhail Teterin <mi+kde@aldan.algebra.com>
Cc: portmgr@freebsd.org, bug-followup@freebsd.org
Subject: Re: gnu/96570: [patch] cc can't build 32-bit executables on amd64
Date: Fri, 5 May 2006 13:50:02 -0400

 On Thu, May 04, 2006 at 11:22:23PM -0400, Mikhail Teterin wrote:
 > Gentlemen!
 > 
 > The PR in subject modifies (however slightly) the cc compiler on amd64. As 
 > such, Release Engineers (Scott) insist, the change be tested on the ports 
 > cluster in addition to the usual "buildworld" test.
 > 
 > All the change does is it makes the /usr/lib/../lib32 the standard location of 
 > libraries and the crt* objects, when the user specifies -m32 flag on amd64.
 > 
 > Could such a test, please, be arranged some time soon? Thank you!
 
 I'd be happy to test but it probably won't be soon due to lack of
 amd64 build resources.  I've put it on my list though.
 
 Kris
 
State-Changed-From-To: open->closed 
State-Changed-By: linimon 
State-Changed-When: Sat May 6 23:31:15 UTC 2006 
State-Changed-Why:  
Rejected by maintainer.  From email to freebsd-bugs: 

Date: Sat, 6 May 2006 15:58:56 -0700 
From: "David O'Brien" <obrien@FreeBSD.org> 
Message-ID: <20060506225856.GC9615@dragon.NUXI.org> 
References: <200605050320.k453KMBs012657@freefall.freebsd.org> 

The patch in the PR is too simplistic.  I already mentioned that. 
This patch is unsuitable to commit and will only generate tons more 
useless PRs. 

Please do not commit.  Thank you. 

--  
-- David  (obrien@FreeBSD.org) 

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

From: Mikhail Teterin <mi+mx@aldan.algebra.com>
To: Mark Linimon <linimon@freebsd.org>, bug-followup@freebsd.org
Cc: obrien@freebsd.org
Subject: Re: gnu/96570: [patch] cc can't build 32-bit executables on amd64
Date: Mon, 8 May 2006 10:57:51 -0400

 > The patch in the PR is too simplistic.  I already mentioned that.
 
 I can not understand from this comment, whether the patch is simply too small 
 a step, or whether it is in *the wrong direction*. If it is the equivalence 
 of adding the much-suggested ``-B/usr/lib32'' to the command line, than it 
 seems useful to me.
 
 > This patch is unsuitable to commit and will only generate tons more
 > useless PRs.
 
 Minimizing the number of PRs is not, in itself, a goal...
 
 	-mi
>Unformatted:
