Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 22 Jun 2017 21:03:27 +0000 (UTC)
From:      Bryan Drewery <bdrewery@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r320246 - head/share/mk
Message-ID:  <201706222103.v5ML3Rd1026602@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: bdrewery
Date: Thu Jun 22 21:03:27 2017
New Revision: 320246
URL: https://svnweb.freebsd.org/changeset/base/320246

Log:
  Support cached linker values in environment.
  
  This is similar to r289659 for bsd.compiler.mk.
  
  MFC after:	2 weeks
  Reviewed by:	emaste
  Sponsored by:	Dell EMC Isilon
  Differential Revision:	https://reviews.freebsd.org/D11310

Modified:
  head/share/mk/bsd.linker.mk

Modified: head/share/mk/bsd.linker.mk
==============================================================================
--- head/share/mk/bsd.linker.mk	Thu Jun 22 21:03:24 2017	(r320245)
+++ head/share/mk/bsd.linker.mk	Thu Jun 22 21:03:27 2017	(r320246)
@@ -19,6 +19,27 @@ __<bsd.linker.mk>__:
 
 .for ld X_ in LD $${_empty_var_} XLD X_
 .if ${ld} == "LD" || !empty(XLD)
+# Try to import LINKER_TYPE and LINKER_VERSION from parent make.
+# The value is only used/exported for the same environment that impacts
+# LD and LINKER_* settings here.
+_exported_vars=	${X_}LINKER_TYPE ${X_}LINKER_VERSION
+${X_}_ld_hash=	${${ld}}${MACHINE}${PATH}
+${X_}_ld_hash:=	${${X_}_ld_hash:hash}
+# Only import if none of the vars are set somehow else.
+_can_export=	yes
+.for var in ${_exported_vars}
+.if defined(${var})
+_can_export=	no
+.endif
+.endfor
+.if ${_can_export} == yes
+.for var in ${_exported_vars}
+.if defined(${var}.${${X_}_ld_hash})
+${var}=	${${var}.${${X_}_ld_hash}}
+.endif
+.endfor
+.endif
+
 .if ${ld} == "LD" || (${ld} == "XLD" && ${XLD} != ${LD})
 
 _ld_version!=	${${ld}} --version 2>/dev/null | head -n 1 || echo none
@@ -39,6 +60,14 @@ ${X_}LINKER_VERSION!=	echo "${_v:M[1-9].[0-9]*}" | \
 .undef _ld_version
 .undef _v
 .endif	# ${ld} == "LD" || (${ld} == "XLD" && ${XLD} != ${LD})
+
+# Export the values so sub-makes don't have to look them up again, using the
+# hash key computed above.
+.for var in ${_exported_vars}
+${var}.${${X_}_ld_hash}:=	${${var}}
+.export-env ${var}.${${X_}_ld_hash}
+.undef ${var}.${${X_}_ld_hash}
+.endfor
 
 .endif	# ${ld} == "LD" || !empty(XLD)
 .endfor	# .for ld in LD XLD



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