Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 25 Aug 2010 05:59:21 GMT
From:      bf <bf1783@gmail.com>
To:        freebsd-gnats-submit@FreeBSD.org
Subject:   ports/149955: [PATCH] bsd.port.mk: add a knob to use the devel/binutils port, rather than the base system binutils
Message-ID:  <201008250559.o7P5xLSM039429@www.freebsd.org>
Resent-Message-ID: <201008250600.o7P60Nwf053189@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>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:    freebsd-ports-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed Aug 25 06:00:22 UTC 2010
>Closed-Date:
>Last-Modified:
>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:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201008250559.o7P5xLSM039429>