From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id F2600138CC5 for ; Mon, 16 Mar 2015 21:12:36 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id E135DE09C4; Mon, 16 Mar 2015 21:12:35 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 38243E09C4 for ; Mon, 16 Mar 2015 21:12:35 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id E1D9C340942 for ; Mon, 16 Mar 2015 21:12:33 +0000 (UTC) Received: by oystercatcher.gentoo.org (Postfix, from userid 559) id 7AE0B13E34; Mon, 16 Mar 2015 21:12:27 +0000 (UTC) From: "Mike Frysinger (vapier)" To: gentoo-commits@lists.gentoo.org Reply-To: gentoo-dev@lists.gentoo.org, vapier@gentoo.org Subject: [gentoo-commits] gentoo-x86 commit in eclass: toolchain-funcs.eclass X-VCS-Repository: gentoo-x86 X-VCS-Files: toolchain-funcs.eclass X-VCS-Directories: eclass X-VCS-Committer: vapier X-VCS-Committer-Name: Mike Frysinger Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Message-Id: <20150316211228.7AE0B13E34@oystercatcher.gentoo.org> Date: Mon, 16 Mar 2015 21:12:27 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: c33a15ee-fa47-45df-95fb-15d734b08746 X-Archives-Hash: 9834306ce93ad6de739b17732e017524 vapier 15/03/16 21:12:27 Modified: toolchain-funcs.eclass Log: tc-ld-is-gold/tc-ld-disable-gold: add helpers for detecting & disabling gold Revision Changes Path 1.135 eclass/toolchain-funcs.eclass file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/toolchain-funcs.eclass?rev=1.135&view=markup plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/toolchain-funcs.eclass?rev=1.135&content-type=text/plain diff : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/toolchain-funcs.eclass?r1=1.134&r2=1.135 Index: toolchain-funcs.eclass =================================================================== RCS file: /var/cvsroot/gentoo-x86/eclass/toolchain-funcs.eclass,v retrieving revision 1.134 retrieving revision 1.135 diff -u -r1.134 -r1.135 --- toolchain-funcs.eclass 16 Mar 2015 19:26:39 -0000 1.134 +++ toolchain-funcs.eclass 16 Mar 2015 21:12:27 -0000 1.135 @@ -1,6 +1,6 @@ # Copyright 1999-2015 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 -# $Header: /var/cvsroot/gentoo-x86/eclass/toolchain-funcs.eclass,v 1.134 2015/03/16 19:26:39 vapier Exp $ +# $Header: /var/cvsroot/gentoo-x86/eclass/toolchain-funcs.eclass,v 1.135 2015/03/16 21:12:27 vapier Exp $ # @ECLASS: toolchain-funcs.eclass # @MAINTAINER: @@ -305,6 +305,73 @@ tc-env_build econf --build=${CBUILD} --host=${CBUILD} "$@" } +# @FUNCTION: tc-ld-is-gold +# @USAGE: [toolchain prefix] +# @DESCRIPTION: +# Return true if the current linker is set to gold. +tc-ld-is-gold() { + local out + + # First check the linker directly. + out=$($(tc-getLD "$@") --version 2>&1) + if [[ ${out} == *"GNU gold"* ]] ; then + return 0 + fi + + # Then see if they're selecting gold via compiler flags. + # Note: We're assuming they're using LDFLAGS to hold the + # options and not CFLAGS/CXXFLAGS. + local base="${T}/test-tc-gold" + cat <<-EOF > "${base}.c" + int main() { return 0; } + EOF + out=$($(tc-getCC "$@") ${CFLAGS} ${CPPFLAGS} ${LDFLAGS} -Wl,--version "${base}.c" -o "${base}" 2>&1) + rm -f "${base}"* + if [[ ${out} == *"GNU gold"* ]] ; then + return 0 + fi + + # No gold here! + return 1 +} + +# @FUNCTION: tc-ld-disable-gold +# @USAGE: [toolchain prefix] +# @DESCRIPTION: +# If the gold linker is currently selected, configure the compilation +# settings so that we use the older bfd linker instead. +tc-ld-disable-gold() { + if ! tc-ld-is-gold "$@" ; then + # They aren't using gold, so nothing to do! + return + fi + + ewarn "Forcing usage of the BFD linker instead of GOLD" + + # Set up LD to point directly to bfd if it's available. + local bfd_ld="$(tc-getLD "$@").bfd" + local path_ld=$(which "${bfd_ld}" 2>/dev/null) + [[ -e ${path_ld} ]] && export LD=${bfd_ld} + + # Set up LDFLAGS to select gold based on the gcc version. + local major=$(gcc-major-version "$@") + local minor=$(gcc-minor-version "$@") + if [[ ${major} -lt 4 ]] || [[ ${major} -eq 4 && ${minor} -lt 8 ]] ; then + # <=gcc-4.7 requires some coercion. Only works if bfd exists. + if [[ -e ${path_ld} ]] ; then + local d="${T}/bfd-linker" + mkdir -p "${d}" + ln -sf "${path_ld}" "${d}"/ld + export LDFLAGS="${LDFLAGS} -B${d}" + else + die "unable to locate a BFD linker to bypass gold" + fi + else + # gcc-4.8+ supports -fuse-ld directly. + export LDFLAGS="${LDFLAGS} -fuse-ld=bfd" + fi +} + # @FUNCTION: tc-has-openmp # @USAGE: [toolchain prefix] # @DESCRIPTION: