From nobody@FreeBSD.org  Wed Aug 25 05:59:22 2010
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 F391F1065670
	for <freebsd-gnats-submit@FreeBSD.org>; Wed, 25 Aug 2010 05:59:21 +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 E18AF8FC12
	for <freebsd-gnats-submit@FreeBSD.org>; Wed, 25 Aug 2010 05:59:21 +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 o7P5xLJE039430
	for <freebsd-gnats-submit@FreeBSD.org>; Wed, 25 Aug 2010 05:59:21 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.14.3/8.14.3/Submit) id o7P5xLSM039429;
	Wed, 25 Aug 2010 05:59:21 GMT
	(envelope-from nobody)
Message-Id: <201008250559.o7P5xLSM039429@www.freebsd.org>
Date: Wed, 25 Aug 2010 05:59:21 GMT
From: bf <bf1783@gmail.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: [PATCH] bsd.port.mk: add a knob to use the devel/binutils port, rather than the base system binutils
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         149955
>Category:       ports
>Synopsis:       [PATCH] bsd.port.mk: add a knob to use the devel/binutils port, rather than the base system binutils
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    portmgr
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed Aug 25 06:00:22 UTC 2010
>Closed-Date:    Wed Sep 15 10:55:08 UTC 2010
>Last-Modified:  Wed Sep 15 11:00:02 UTC 2010
>Originator:     bf
>Release:        9-CURRENT amd64
>Organization:
-
>Environment:
>Description:
A growing number of ports need to use the utilities from the devel/binutils port, rather than the old base system binutils.  Among them are many ports that USE_GCC=4.[456] or USE_FORTRAN.  ports/136607 solved part (but not all) of this problem by hard-coding a dependence on devel/binutils in the lang/gcc4[456] ports, ensuring that these compilers would use the linker and assembler from devel/binutils implicitly.  However, a number of ports still call the linker, assembler, and other utilities _explicitly_, and this was not addressed by ports/136607.  This can result in a problematic mixing of different tool-chains (for example, like in math/blas, math/atlas, and math/lapack), or a hard-coded dependency on the base system binutils, when the newer binutils are desired.  (This is because utilities like AR, AS, LD, OBJCOPY, OBJDUMP, and RANLIB are set in /usr/share/mk/sys.mk, ports/Mk/bsd.commands.mk, and ports/Mk/bsd.port.mk; and because the devel/binutils are usually preceded b
 y the like-named base system binutils in the system path.)

To address this problem without requiring redundant code in individual port Makefiles, I propose the attached patch to bsd.port.mk.  It will ensure that a choice of tool-chains is available, even in ports that do not use lang/gcc4[456].  With the patch, if USE_BINUTILS is defined in a port Makefile:

--devel/binutils is added to BUILD_DEPENDS
--the subset of utilities contained in BINUTILS (by default, all of them) is exposed to targets in port Makefiles, 
--added to the CONFIGURE_ENV (if the ports uses GNU_CONFIGURE or USE_BINUTILS_CONFIGURE is defined), and 
--added to the MAKE_ENV (if not contained in a blacklist BINUTILS_NO_MAKE_ENV).  

The whole can be disabled for debugging purposes by defining DISABLE_BINUTILS.
The small number of ports that have devel/binutils as a run-time dependency, like lang/gcc4[456], will still need to add a RUN_DEPENDS. ports/Mk/bsd.gcc.mk can be altered to add USE_BINUTILS when USE_GCC=4.[456] or USE_FORTRAN is defined, and other ports that don't use lang/gcc[456] can add a line or two to their Makefiles, and make use of the variables provided in patching sources, if necessary.







>How-To-Repeat:

>Fix:


Patch attached with submission follows:

Index: bsd.port.mk
===================================================================
RCS file: /home/pcvs/ports/Mk/bsd.port.mk,v
retrieving revision 1.644
diff -u -r1.644 bsd.port.mk
--- bsd.port.mk	20 Aug 2010 12:15:02 -0000	1.644
+++ bsd.port.mk	25 Aug 2010 04:43:17 -0000
@@ -1734,6 +1734,22 @@
 .include "${PORTSDIR}/Mk/bsd.gcc.mk"
 .endif
 
+.if defined(USE_BINUTILS) && !defined(DISABLE_BINUTILS)
+BUILD_DEPENDS+=	${LOCALBASE}/bin/as:${PORTSDIR}/devel/binutils
+BINUTILS?=	ADDR2LINE AR AS CPPFILT GPROF LD NM OBJCOPY OBJDUMP RANLIB \
+	READELF SIZE STRINGS
+BINUTILS_NO_MAKE_ENV?=
+. for b in ${BINUTILS}
+${b}=	${LOCALBASE}/bin/${b:C/PP/++/:L}
+.  if defined(GNU_CONFIGURE) || defined(BINUTILS_CONFIGURE)
+CONFIGURE_ENV+=	${b}="${${b}}"
+.  endif
+.  if ${BINUTILS_NO_MAKE_ENV:M${b}} == ""
+MAKE_ENV+=	${b}="${${b}}"
+.  endif
+. endfor
+.endif
+
 .if defined(USE_OPENLDAP) || defined(WANT_OPENLDAP_VER)
 .include "${PORTSDIR}/Mk/bsd.ldap.mk"
 .endif


>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-ports-bugs->portmgr 
Responsible-Changed-By: edwin 
Responsible-Changed-When: Wed Aug 25 06:00:42 UTC 2010 
Responsible-Changed-Why:  
bsd.port.mk is portmgr territory (via the GNATS Auto Assign Tool) 

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

From: "b. f." <bf1783@googlemail.com>
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: ports/149955: [PATCH] bsd.port.mk: add a knob to use the
 devel/binutils port, rather than the base system binutils
Date: Wed, 25 Aug 2010 06:05:37 +0000

 In my original description, s/USE_BINUTILS_CONFIGURE/BINUTILS_CONFIGURE/.
 
 b.
State-Changed-From-To: open->closed 
State-Changed-By: pav 
State-Changed-When: Wed Sep 15 10:53:31 UTC 2010 
State-Changed-Why:  
Committed, thanks.  I'm looking forward to some ports that use this. 

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

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: ports/149955: commit references a PR
Date: Wed, 15 Sep 2010 10:54:51 +0000 (UTC)

 pav         2010-09-15 10:54:46 UTC
 
   FreeBSD ports repository
 
   Modified files:
     Mk                   bsd.port.mk 
   Log:
   - Add USE_BINUTILS knob that makes the build process use binutils from port
     instead of the binutils in base
   
   PR:             ports/149955
   Submitted by:   bf
   
   Revision  Changes    Path
   1.645     +18 -1     ports/Mk/bsd.port.mk
 _______________________________________________
 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:
