/[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.129 Revision 1.135
1n Copyright 1999-2014 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.129 2014/10/15 22:30:56 blueness 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
82tc-getRANLIB() { tc-getPROG RANLIB ranlib "$@"; } 82tc-getRANLIB() { tc-getPROG RANLIB ranlib "$@"; }
83# @FUNCTION: tc-getOBJCOPY 83# @FUNCTION: tc-getOBJCOPY
84# @USAGE: [toolchain prefix] 84# @USAGE: [toolchain prefix]
85# @RETURN: name of the object copier 85# @RETURN: name of the object copier
86tc-getOBJCOPY() { tc-getPROG OBJCOPY objcopy "$@"; } 86tc-getOBJCOPY() { tc-getPROG OBJCOPY objcopy "$@"; }
87# @FUNCTION: tc-getOBJDUMP
88# @USAGE: [toolchain prefix]
89# @RETURN: name of the object dumper
90tc-getOBJDUMP() { tc-getPROG OBJDUMP objdump "$@"; }
87# @FUNCTION: tc-getF77 91# @FUNCTION: tc-getF77
88# @USAGE: [toolchain prefix] 92# @USAGE: [toolchain prefix]
89# @RETURN: name of the Fortran 77 compiler 93# @RETURN: name of the Fortran 77 compiler
90tc-getF77() { tc-getPROG F77 gfortran "$@"; } 94tc-getF77() { tc-getPROG F77 gfortran "$@"; }
91# @FUNCTION: tc-getFC 95# @FUNCTION: tc-getFC
295# fi 299# fi
296# ... normal build paths ... 300# ... normal build paths ...
297# } 301# }
298# @CODE 302# @CODE
299econf_build() { 303econf_build() {
304 local CBUILD=${CBUILD:-${CHOST}}
300 tc-env_build econf --build=${CBUILD:-${CHOST}} "$@" 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
301} 373}
302 374
303# @FUNCTION: tc-has-openmp 375# @FUNCTION: tc-has-openmp
304# @USAGE: [toolchain prefix] 376# @USAGE: [toolchain prefix]
305# @DESCRIPTION: 377# @DESCRIPTION:
371 aarch64*) echo arm64;; 443 aarch64*) echo arm64;;
372 alpha*) echo alpha;; 444 alpha*) echo alpha;;
373 arm*) echo arm;; 445 arm*) echo arm;;
374 avr*) ninj avr32 avr;; 446 avr*) ninj avr32 avr;;
375 bfin*) ninj blackfin bfin;; 447 bfin*) ninj blackfin bfin;;
376 c6x) echo c6x;; 448 c6x*) echo c6x;;
377 cris*) echo cris;; 449 cris*) echo cris;;
378 frv) echo frv;; 450 frv*) echo frv;;
379 hexagon) echo hexagon;; 451 hexagon*) echo hexagon;;
380 hppa*) ninj parisc hppa;; 452 hppa*) ninj parisc hppa;;
381 i?86*) 453 i?86*)
382 # Starting with linux-2.6.24, the 'x86_64' and 'i386' 454 # Starting with linux-2.6.24, the 'x86_64' and 'i386'
383 # trees have been unified into 'x86'. 455 # trees have been unified into 'x86'.
384 # FreeBSD still uses i386 456 # FreeBSD still uses i386
388 echo x86 460 echo x86
389 fi 461 fi
390 ;; 462 ;;
391 ia64*) echo ia64;; 463 ia64*) echo ia64;;
392 m68*) echo m68k;; 464 m68*) echo m68k;;
393 metag) echo metag;; 465 metag*) echo metag;;
466 microblaze*) echo microblaze;;
394 mips*) echo mips;; 467 mips*) echo mips;;
395 nios2*) echo nios2;; 468 nios2*) echo nios2;;
396 nios*) echo nios;; 469 nios*) echo nios;;
397 or32) echo openrisc;; 470 or32*) echo openrisc;;
398 powerpc*) 471 powerpc*)
399 # Starting with linux-2.6.15, the 'ppc' and 'ppc64' trees 472 # Starting with linux-2.6.15, the 'ppc' and 'ppc64' trees
400 # have been unified into simply 'powerpc', but until 2.6.16, 473 # have been unified into simply 'powerpc', but until 2.6.16,
401 # ppc32 is still using ARCH="ppc" as default 474 # ppc32 is still using ARCH="ppc" as default
402 if [[ ${type} == "kern" ]] && [[ $(KV_to_int ${KV}) -ge $(KV_to_int 2.6.16) ]] ; then 475 if [[ ${type} == "kern" ]] && [[ $(KV_to_int ${KV}) -ge $(KV_to_int 2.6.16) ]] ; then
413 ninj ppc64 ppc 486 ninj ppc64 ppc
414 else 487 else
415 echo ppc 488 echo ppc
416 fi 489 fi
417 ;; 490 ;;
491 riscv*) echo riscv;;
418 s390*) echo s390;; 492 s390*) echo s390;;
419 score) echo score;; 493 score*) echo score;;
420 sh64*) ninj sh64 sh;; 494 sh64*) ninj sh64 sh;;
421 sh*) echo sh;; 495 sh*) echo sh;;
422 sparc64*) ninj sparc64 sparc;; 496 sparc64*) ninj sparc64 sparc;;
423 sparc*) [[ ${PROFILE_ARCH} == "sparc64" ]] \ 497 sparc*) [[ ${PROFILE_ARCH} == "sparc64" ]] \
424 && ninj sparc64 sparc \ 498 && ninj sparc64 sparc \

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

  ViewVC Help
Powered by ViewVC 1.1.20