/[gentoo-x86]/eclass/toolchain-funcs.eclass
Gentoo

Diff of /eclass/toolchain-funcs.eclass

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.134 Revision 1.135
1# Copyright 1999-2015 Gentoo Foundation 1# Copyright 1999-2015 Gentoo Foundation
2# Distributed under the terms of the GNU General Public License v2 2# Distributed under the terms of the GNU General Public License v2
3# $Header: /var/cvsroot/gentoo-x86/eclass/toolchain-funcs.eclass,v 1.134 2015/03/16 19:26:39 vapier Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/toolchain-funcs.eclass,v 1.135 2015/03/16 21:12:27 vapier Exp $
4 4
5# @ECLASS: toolchain-funcs.eclass 5# @ECLASS: toolchain-funcs.eclass
6# @MAINTAINER: 6# @MAINTAINER:
7# Toolchain Ninjas <toolchain@gentoo.org> 7# Toolchain Ninjas <toolchain@gentoo.org>
8# @BLURB: functions to query common info about the toolchain 8# @BLURB: functions to query common info about the toolchain
301# } 301# }
302# @CODE 302# @CODE
303econf_build() { 303econf_build() {
304 local CBUILD=${CBUILD:-${CHOST}} 304 local CBUILD=${CBUILD:-${CHOST}}
305 tc-env_build econf --build=${CBUILD} --host=${CBUILD} "$@" 305 tc-env_build econf --build=${CBUILD} --host=${CBUILD} "$@"
306}
307
308# @FUNCTION: tc-ld-is-gold
309# @USAGE: [toolchain prefix]
310# @DESCRIPTION:
311# Return true if the current linker is set to gold.
312tc-ld-is-gold() {
313 local out
314
315 # First check the linker directly.
316 out=$($(tc-getLD "$@") --version 2>&1)
317 if [[ ${out} == *"GNU gold"* ]] ; then
318 return 0
319 fi
320
321 # Then see if they're selecting gold via compiler flags.
322 # Note: We're assuming they're using LDFLAGS to hold the
323 # options and not CFLAGS/CXXFLAGS.
324 local base="${T}/test-tc-gold"
325 cat <<-EOF > "${base}.c"
326 int main() { return 0; }
327 EOF
328 out=$($(tc-getCC "$@") ${CFLAGS} ${CPPFLAGS} ${LDFLAGS} -Wl,--version "${base}.c" -o "${base}" 2>&1)
329 rm -f "${base}"*
330 if [[ ${out} == *"GNU gold"* ]] ; then
331 return 0
332 fi
333
334 # No gold here!
335 return 1
336}
337
338# @FUNCTION: tc-ld-disable-gold
339# @USAGE: [toolchain prefix]
340# @DESCRIPTION:
341# If the gold linker is currently selected, configure the compilation
342# settings so that we use the older bfd linker instead.
343tc-ld-disable-gold() {
344 if ! tc-ld-is-gold "$@" ; then
345 # They aren't using gold, so nothing to do!
346 return
347 fi
348
349 ewarn "Forcing usage of the BFD linker instead of GOLD"
350
351 # Set up LD to point directly to bfd if it's available.
352 local bfd_ld="$(tc-getLD "$@").bfd"
353 local path_ld=$(which "${bfd_ld}" 2>/dev/null)
354 [[ -e ${path_ld} ]] && export LD=${bfd_ld}
355
356 # Set up LDFLAGS to select gold based on the gcc version.
357 local major=$(gcc-major-version "$@")
358 local minor=$(gcc-minor-version "$@")
359 if [[ ${major} -lt 4 ]] || [[ ${major} -eq 4 && ${minor} -lt 8 ]] ; then
360 # <=gcc-4.7 requires some coercion. Only works if bfd exists.
361 if [[ -e ${path_ld} ]] ; then
362 local d="${T}/bfd-linker"
363 mkdir -p "${d}"
364 ln -sf "${path_ld}" "${d}"/ld
365 export LDFLAGS="${LDFLAGS} -B${d}"
366 else
367 die "unable to locate a BFD linker to bypass gold"
368 fi
369 else
370 # gcc-4.8+ supports -fuse-ld directly.
371 export LDFLAGS="${LDFLAGS} -fuse-ld=bfd"
372 fi
306} 373}
307 374
308# @FUNCTION: tc-has-openmp 375# @FUNCTION: tc-has-openmp
309# @USAGE: [toolchain prefix] 376# @USAGE: [toolchain prefix]
310# @DESCRIPTION: 377# @DESCRIPTION:

Legend:
Removed from v.1.134  
changed lines
  Added in v.1.135

  ViewVC Help
Powered by ViewVC 1.1.20