From nobody@FreeBSD.org  Sat Sep 26 00:00:12 2009
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 212B0106566C
	for <freebsd-gnats-submit@FreeBSD.org>; Sat, 26 Sep 2009 00:00:12 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21])
	by mx1.freebsd.org (Postfix) with ESMTP id 106698FC17
	for <freebsd-gnats-submit@FreeBSD.org>; Sat, 26 Sep 2009 00:00:12 +0000 (UTC)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.14.3/8.14.3) with ESMTP id n8Q007hw037258
	for <freebsd-gnats-submit@FreeBSD.org>; Sat, 26 Sep 2009 00:00:07 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.14.3/8.14.3/Submit) id n8Q007bt037257;
	Sat, 26 Sep 2009 00:00:07 GMT
	(envelope-from nobody)
Message-Id: <200909260000.n8Q007bt037257@www.freebsd.org>
Date: Sat, 26 Sep 2009 00:00:07 GMT
From: "Philip M. Gollucci" <pgollucci@FreeBSD.org>
To: freebsd-gnats-submit@FreeBSD.org
Subject: gcc -m32 doesn't quite work
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         139146
>Category:       bin
>Synopsis:       gcc(1): gcc -m32 doesn't quite work
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sat Sep 26 00:10:01 UTC 2009
>Closed-Date:    Thu Aug 19 21:49:49 UTC 2010
>Last-Modified:  Thu Aug 19 21:49:49 UTC 2010
>Originator:     Philip M. Gollucci
>Release:        FreeBSD 7.2-STABLE
>Organization:
Apache Software Foundation
>Environment:
FreeBSD minotaur.apache.org 7.2-STABLE FreeBSD 7.2-STABLE #0: Wed Aug  5 01:05:27 UTC 2009     root@loki.apache.org:/usr/obj/usr/src/sys/MINOTAUR  amd64

>Description:
https://issues.apache.org/jira/browse/INFRA-2077

gcc can successfully generate 64-bit binaries but when invoked with the -m32 option to generate 32-bit code the linker fails to find the corresponding 32-bit libgcc.so (see below). It appears as though the compiler driver doesn't pass -L/usr/lib32 (the location of the 32-bit libgcc) to the linker. Unfortunately, specifying -L/usr/lib32 manually gives the error: /usr/bin/ld: skipping incompatible /usr/lib/libgcc.a when searching for -lgcc.

>How-To-Repeat:

$ uname -sr && echo "int main () { }" > t.c && gcc -v --help 2>&1 | grep m32 && gcc -m32 t.c
FreeBSD 7.2-STABLE
  -m32 Generate 32bit i386 code
/usr/bin/ld: skipping incompatible /usr/lib/libgcc.a when searching for -lgcc
/usr/bin/ld: skipping incompatible /usr/lib/libgcc.a when searching for -lgcc
/usr/bin/ld: cannot find -lgcc 
>Fix:


>Release-Note:
>Audit-Trail:

From: Bruce Cran <brucec@muon.cran.org.uk>
To: "Philip M. Gollucci" <pgollucci@FreeBSD.org>
Cc: freebsd-gnats-submit@FreeBSD.org
Subject: Re: bin/139146: gcc -m32 doesn't quite work
Date: Sat, 26 Sep 2009 11:01:15 +0000

 Does it work if you use "-B/usr/lib32" instead of "-L/usr/lib32"?  
 There's a thread at 
 http://lists.freebsd.org/pipermail/freebsd-amd64/2008-December/011766.html 
 with more details.
 
 -- 
 Bruce
 

From: "Philip M. Gollucci" <pgollucci@p6m7g8.com>
To: bug-followup@FreeBSD.org, pgollucci@FreeBSD.org
Cc:  
Subject: Re: bin/139146: gcc(1): gcc -m32 doesn't quite work
Date: Mon, 28 Sep 2009 21:59:57 -0400

 uname -sr && echo "int main () { }" > t.c && gcc -v --help 2>&1 | grep
 m32 && gcc -B/usr/lib32 -m32 t.c && file a.out
 FreeBSD 7.2-STABLE
   -m32                        Generate 32bit i386 code
 a.out: ELF 32-bit LSB executable, Intel 80386, version 1 (FreeBSD), for
 FreeBSD 7.2 (702104), dynamically linked (uses shared libs),
 FreeBSD-style, not stripped
 
 
 interesting.... documenation addition then ?
 
 -- 
 ------------------------------------------------------------------------
 1024D/DB9B8C1C B90B FBC3 A3A1 C71A 8E70  3F8C 75B8 8FFB DB9B 8C1C
 Philip M. Gollucci (pgollucci@p6m7g8.com) c: 703.336.9354
 Consultant          - P6M7G8 Inc.                http://p6m7g8.net
 Senior Sys Admin    - RideCharge, Inc.           http://ridecharge.com
 ASF Member          - Apache Software Foundation http://apache.org
 FreeBSD Committer   - FreeBSD Foundation         http://freebsd.org
 
 Work like you don't need the money,
 love like you'll never get hurt,
 and dance like nobody's watching.
State-Changed-From-To: open->suspended 
State-Changed-By: arundel 
State-Changed-When: Thu Aug 19 21:19:26 UTC 2010 
State-Changed-Why:  
Judging from the various threads on freebsd-amd64@, fixing this issue is non- 
trivial and requires some fundamental changes to gcc's include and linker search 
paths. 
Petter Wemm provided a patch in [1], but at the same time states that the patch 
doesn't fix the issue properly. Apart from him most of the developers seem to 
have abandoned the idea of fixing/discussing this issue: 

"Short summary: it never worked and will not work unless some non-trivial work 
is put into how GCC handles include and linker search paths." - Alexander Kabaev 

Thus suspend this PR for now. 

Everyone is welcome to work on this problem. However please gather information 
from the various freebsd mailinglists dealing with this issue BEFORE creating a 
new thread, unless you are prepared to making new enemies. ;) 

[1] http://lists.freebsd.org/pipermail/freebsd-amd64/2008-December/011775.html 

http://www.freebsd.org/cgi/query-pr.cgi?pr=139146 
State-Changed-From-To: suspended->closed 
State-Changed-By: arundel 
State-Changed-When: Thu Aug 19 21:43:34 UTC 2010 
State-Changed-Why:  
Duplicate of gnu/112215. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=139146 
>Unformatted:
