/[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.107 Revision 1.136
1# Copyright 1999-2007 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.107 2011/09/12 21:42:08 vapier Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/toolchain-funcs.eclass,v 1.136 2015/03/31 04:27:29 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
11# for gleaning useful information about the toolchain and to simplify 11# for gleaning useful information about the toolchain and to simplify
12# ugly things like cross-compiling and multilib. All of this is done 12# ugly things like cross-compiling and multilib. All of this is done
13# in such a way that you can rely on the function always returning 13# in such a way that you can rely on the function always returning
14# something sane. 14# something sane.
15 15
16___ECLASS_RECUR_TOOLCHAIN_FUNCS="yes" 16if [[ -z ${_TOOLCHAIN_FUNCS_ECLASS} ]]; then
17[[ -z ${___ECLASS_RECUR_MULTILIB} ]] && inherit multilib 17_TOOLCHAIN_FUNCS_ECLASS=1
18 18
19DESCRIPTION="Based on the ${ECLASS} eclass" 19inherit multilib
20 20
21# tc-getPROG <VAR [search vars]> <default> [tuple] 21# tc-getPROG <VAR [search vars]> <default> [tuple]
22_tc-getPROG() { 22_tc-getPROG() {
23 local tuple=$1 23 local tuple=$1
24 local v var vars=$2 24 local v var vars=$2
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
167} 171}
168 172
169# @FUNCTION: tc-is-cross-compiler 173# @FUNCTION: tc-is-cross-compiler
170# @RETURN: Shell true if we are using a cross-compiler, shell false otherwise 174# @RETURN: Shell true if we are using a cross-compiler, shell false otherwise
171tc-is-cross-compiler() { 175tc-is-cross-compiler() {
172 return $([[ ${CBUILD:-${CHOST}} != ${CHOST} ]]) 176 [[ ${CBUILD:-${CHOST}} != ${CHOST} ]]
173} 177}
174 178
175# @FUNCTION: tc-is-softfloat 179# @FUNCTION: tc-is-softfloat
176# @DESCRIPTION: 180# @DESCRIPTION:
177# See if this toolchain is a softfloat based one. 181# See if this toolchain is a softfloat based one.
178# @CODE 182# @CODE
179# The possible return values: 183# The possible return values:
180# - only: the target is always softfloat (never had fpu) 184# - only: the target is always softfloat (never had fpu)
181# - yes: the target should support softfloat 185# - yes: the target should support softfloat
186# - softfp: (arm specific) the target should use hardfloat insns, but softfloat calling convention
182# - no: the target doesn't support softfloat 187# - no: the target doesn't support softfloat
183# @CODE 188# @CODE
184# This allows us to react differently where packages accept 189# This allows us to react differently where packages accept
185# softfloat flags in the case where support is optional, but 190# softfloat flags in the case where support is optional, but
186# rejects softfloat flags where the target always lacks an fpu. 191# rejects softfloat flags where the target always lacks an fpu.
187tc-is-softfloat() { 192tc-is-softfloat() {
193 local CTARGET=${CTARGET:-${CHOST}}
188 case ${CTARGET} in 194 case ${CTARGET} in
189 bfin*|h8300*) 195 bfin*|h8300*)
190 echo "only" ;; 196 echo "only" ;;
191 *) 197 *)
192 [[ ${CTARGET//_/-} == *-softfloat-* ]] \ 198 if [[ ${CTARGET//_/-} == *-softfloat-* ]] ; then
193 && echo "yes" \ 199 echo "yes"
200 elif [[ ${CTARGET//_/-} == *-softfp-* ]] ; then
201 echo "softfp"
202 else
194 || echo "no" 203 echo "no"
204 fi
195 ;; 205 ;;
196 esac 206 esac
197}
198
199# @FUNCTION: tc-is-hardfloat
200# @DESCRIPTION:
201# See if this toolchain is a hardfloat based one.
202# @CODE
203# The possible return values:
204# - yes: the target should support hardfloat
205# - no: the target doesn't support hardfloat
206tc-is-hardfloat() {
207 [[ ${CTARGET//_/-} == *-hardfloat-* ]] \
208 && echo "yes" \
209 || echo "no"
210} 207}
211 208
212# @FUNCTION: tc-is-static-only 209# @FUNCTION: tc-is-static-only
213# @DESCRIPTION: 210# @DESCRIPTION:
214# Return shell true if the target does not support shared libs, shell false 211# Return shell true if the target does not support shared libs, shell false
215# otherwise. 212# otherwise.
216tc-is-static-only() { 213tc-is-static-only() {
217 local host=${CTARGET:-${CHOST}} 214 local host=${CTARGET:-${CHOST}}
218 215
219 # *MiNT doesn't have shared libraries, only platform so far 216 # *MiNT doesn't have shared libraries, only platform so far
220 return $([[ ${host} == *-mint* ]]) 217 [[ ${host} == *-mint* ]]
218}
219
220# @FUNCTION: tc-export_build_env
221# @USAGE: [compiler variables]
222# @DESCRIPTION:
223# Export common build related compiler settings.
224tc-export_build_env() {
225 tc-export "$@"
226 # Some build envs will initialize vars like:
227 # : ${BUILD_LDFLAGS:-${LDFLAGS}}
228 # So make sure all variables are non-empty. #526734
229 : ${BUILD_CFLAGS:=-O1 -pipe}
230 : ${BUILD_CXXFLAGS:=-O1 -pipe}
231 : ${BUILD_CPPFLAGS:= }
232 : ${BUILD_LDFLAGS:= }
233 export BUILD_{C,CXX,CPP,LD}FLAGS
234
235 # Some packages use XXX_FOR_BUILD.
236 local v
237 for v in BUILD_{C,CXX,CPP,LD}FLAGS ; do
238 export ${v#BUILD_}_FOR_BUILD="${!v}"
239 done
240}
241
242# @FUNCTION: tc-env_build
243# @USAGE: <command> [command args]
244# @INTERNAL
245# @DESCRIPTION:
246# Setup the compile environment to the build tools and then execute the
247# specified command. We use tc-getBUILD_XX here so that we work with
248# all of the semi-[non-]standard env vars like $BUILD_CC which often
249# the target build system does not check.
250tc-env_build() {
251 tc-export_build_env
252 CFLAGS=${BUILD_CFLAGS} \
253 CXXFLAGS=${BUILD_CXXFLAGS} \
254 CPPFLAGS=${BUILD_CPPFLAGS} \
255 LDFLAGS=${BUILD_LDFLAGS} \
256 AR=$(tc-getBUILD_AR) \
257 AS=$(tc-getBUILD_AS) \
258 CC=$(tc-getBUILD_CC) \
259 CPP=$(tc-getBUILD_CPP) \
260 CXX=$(tc-getBUILD_CXX) \
261 LD=$(tc-getBUILD_LD) \
262 NM=$(tc-getBUILD_NM) \
263 PKG_CONFIG=$(tc-getBUILD_PKG_CONFIG) \
264 RANLIB=$(tc-getBUILD_RANLIB) \
265 "$@"
266}
267
268# @FUNCTION: econf_build
269# @USAGE: [econf flags]
270# @DESCRIPTION:
271# Sometimes we need to locally build up some tools to run on CBUILD because
272# the package has helper utils which are compiled+executed when compiling.
273# This won't work when cross-compiling as the CHOST is set to a target which
274# we cannot natively execute.
275#
276# For example, the python package will build up a local python binary using
277# a portable build system (configure+make), but then use that binary to run
278# local python scripts to build up other components of the overall python.
279# We cannot rely on the python binary in $PATH as that often times will be
280# a different version, or not even installed in the first place. Instead,
281# we compile the code in a different directory to run on CBUILD, and then
282# use that binary when compiling the main package to run on CHOST.
283#
284# For example, with newer EAPIs, you'd do something like:
285# @CODE
286# src_configure() {
287# ECONF_SOURCE=${S}
288# if tc-is-cross-compiler ; then
289# mkdir "${WORKDIR}"/${CBUILD}
290# pushd "${WORKDIR}"/${CBUILD} >/dev/null
291# econf_build --disable-some-unused-stuff
292# popd >/dev/null
293# fi
294# ... normal build paths ...
295# }
296# src_compile() {
297# if tc-is-cross-compiler ; then
298# pushd "${WORKDIR}"/${CBUILD} >/dev/null
299# emake one-or-two-build-tools
300# ln/mv build-tools to normal build paths in ${S}/
301# popd >/dev/null
302# fi
303# ... normal build paths ...
304# }
305# @CODE
306econf_build() {
307 local CBUILD=${CBUILD:-${CHOST}}
308 tc-env_build econf --build=${CBUILD} --host=${CBUILD} "$@"
309}
310
311# @FUNCTION: tc-ld-is-gold
312# @USAGE: [toolchain prefix]
313# @DESCRIPTION:
314# Return true if the current linker is set to gold.
315tc-ld-is-gold() {
316 local out
317
318 # First check the linker directly.
319 out=$($(tc-getLD "$@") --version 2>&1)
320 if [[ ${out} == *"GNU gold"* ]] ; then
321 return 0
322 fi
323
324 # Then see if they're selecting gold via compiler flags.
325 # Note: We're assuming they're using LDFLAGS to hold the
326 # options and not CFLAGS/CXXFLAGS.
327 local base="${T}/test-tc-gold"
328 cat <<-EOF > "${base}.c"
329 int main() { return 0; }
330 EOF
331 out=$($(tc-getCC "$@") ${CFLAGS} ${CPPFLAGS} ${LDFLAGS} -Wl,--version "${base}.c" -o "${base}" 2>&1)
332 rm -f "${base}"*
333 if [[ ${out} == *"GNU gold"* ]] ; then
334 return 0
335 fi
336
337 # No gold here!
338 return 1
339}
340
341# @FUNCTION: tc-ld-disable-gold
342# @USAGE: [toolchain prefix]
343# @DESCRIPTION:
344# If the gold linker is currently selected, configure the compilation
345# settings so that we use the older bfd linker instead.
346tc-ld-disable-gold() {
347 if ! tc-ld-is-gold "$@" ; then
348 # They aren't using gold, so nothing to do!
349 return
350 fi
351
352 ewarn "Forcing usage of the BFD linker instead of GOLD"
353
354 # Set up LD to point directly to bfd if it's available.
355 local bfd_ld="$(tc-getLD "$@").bfd"
356 local path_ld=$(which "${bfd_ld}" 2>/dev/null)
357 [[ -e ${path_ld} ]] && export LD=${bfd_ld}
358
359 # Set up LDFLAGS to select gold based on the gcc version.
360 local major=$(gcc-major-version "$@")
361 local minor=$(gcc-minor-version "$@")
362 if [[ ${major} -lt 4 ]] || [[ ${major} -eq 4 && ${minor} -lt 8 ]] ; then
363 # <=gcc-4.7 requires some coercion. Only works if bfd exists.
364 if [[ -e ${path_ld} ]] ; then
365 local d="${T}/bfd-linker"
366 mkdir -p "${d}"
367 ln -sf "${path_ld}" "${d}"/ld
368 export LDFLAGS="${LDFLAGS} -B${d}"
369 else
370 die "unable to locate a BFD linker to bypass gold"
371 fi
372 else
373 # gcc-4.8+ supports -fuse-ld directly.
374 export LDFLAGS="${LDFLAGS} -fuse-ld=bfd"
375 fi
221} 376}
222 377
223# @FUNCTION: tc-has-openmp 378# @FUNCTION: tc-has-openmp
224# @USAGE: [toolchain prefix] 379# @USAGE: [toolchain prefix]
225# @DESCRIPTION: 380# @DESCRIPTION:
281 436
282 local type=$1 437 local type=$1
283 local host=$2 438 local host=$2
284 [[ -z ${host} ]] && host=${CTARGET:-${CHOST}} 439 [[ -z ${host} ]] && host=${CTARGET:-${CHOST}}
285 440
441 local KV=${KV:-${KV_FULL}}
442 [[ ${type} == "kern" ]] && [[ -z ${KV} ]] && \
443 ewarn "QA: Kernel version could not be determined, please inherit kernel-2 or linux-info"
444
286 case ${host} in 445 case ${host} in
446 aarch64*) echo arm64;;
287 alpha*) echo alpha;; 447 alpha*) echo alpha;;
288 arm*) echo arm;; 448 arm*) echo arm;;
289 avr*) ninj avr32 avr;; 449 avr*) ninj avr32 avr;;
290 bfin*) ninj blackfin bfin;; 450 bfin*) ninj blackfin bfin;;
451 c6x*) echo c6x;;
291 cris*) echo cris;; 452 cris*) echo cris;;
453 frv*) echo frv;;
454 hexagon*) echo hexagon;;
292 hppa*) ninj parisc hppa;; 455 hppa*) ninj parisc hppa;;
293 i?86*) 456 i?86*)
294 # Starting with linux-2.6.24, the 'x86_64' and 'i386' 457 # Starting with linux-2.6.24, the 'x86_64' and 'i386'
295 # trees have been unified into 'x86'. 458 # trees have been unified into 'x86'.
296 # FreeBSD still uses i386 459 # FreeBSD still uses i386
300 echo x86 463 echo x86
301 fi 464 fi
302 ;; 465 ;;
303 ia64*) echo ia64;; 466 ia64*) echo ia64;;
304 m68*) echo m68k;; 467 m68*) echo m68k;;
468 metag*) echo metag;;
469 microblaze*) echo microblaze;;
305 mips*) echo mips;; 470 mips*) echo mips;;
306 nios2*) echo nios2;; 471 nios2*) echo nios2;;
307 nios*) echo nios;; 472 nios*) echo nios;;
473 or32*) echo openrisc;;
308 powerpc*) 474 powerpc*)
309 # Starting with linux-2.6.15, the 'ppc' and 'ppc64' trees 475 # Starting with linux-2.6.15, the 'ppc' and 'ppc64' trees
310 # have been unified into simply 'powerpc', but until 2.6.16, 476 # have been unified into simply 'powerpc', but until 2.6.16,
311 # ppc32 is still using ARCH="ppc" as default 477 # ppc32 is still using ARCH="ppc" as default
312 if [[ ${type} == "kern" ]] && [[ $(KV_to_int ${KV}) -ge $(KV_to_int 2.6.16) ]] ; then 478 if [[ ${type} == "kern" ]] && [[ $(KV_to_int ${KV}) -ge $(KV_to_int 2.6.16) ]] ; then
323 ninj ppc64 ppc 489 ninj ppc64 ppc
324 else 490 else
325 echo ppc 491 echo ppc
326 fi 492 fi
327 ;; 493 ;;
494 riscv*) echo riscv;;
328 s390*) echo s390;; 495 s390*) echo s390;;
496 score*) echo score;;
329 sh64*) ninj sh64 sh;; 497 sh64*) ninj sh64 sh;;
330 sh*) echo sh;; 498 sh*) echo sh;;
331 sparc64*) ninj sparc64 sparc;; 499 sparc64*) ninj sparc64 sparc;;
332 sparc*) [[ ${PROFILE_ARCH} == "sparc64" ]] \ 500 sparc*) [[ ${PROFILE_ARCH} == "sparc64" ]] \
333 && ninj sparc64 sparc \ 501 && ninj sparc64 sparc \
334 || echo sparc 502 || echo sparc
335 ;; 503 ;;
504 tile*) echo tile;;
336 vax*) echo vax;; 505 vax*) echo vax;;
337 x86_64*freebsd*) echo amd64;; 506 x86_64*freebsd*) echo amd64;;
338 x86_64*) 507 x86_64*)
339 # Starting with linux-2.6.24, the 'x86_64' and 'i386' 508 # Starting with linux-2.6.24, the 'x86_64' and 'i386'
340 # trees have been unified into 'x86'. 509 # trees have been unified into 'x86'.
342 echo x86 511 echo x86
343 else 512 else
344 ninj x86_64 amd64 513 ninj x86_64 amd64
345 fi 514 fi
346 ;; 515 ;;
516 xtensa*) echo xtensa;;
347 517
348 # since our usage of tc-arch is largely concerned with 518 # since our usage of tc-arch is largely concerned with
349 # normalizing inputs for testing ${CTARGET}, let's filter 519 # normalizing inputs for testing ${CTARGET}, let's filter
350 # other cross targets (mingw and such) into the unknown. 520 # other cross targets (mingw and such) into the unknown.
351 *) echo unknown;; 521 *) echo unknown;;
368 local host=$1 538 local host=$1
369 [[ -z ${host} ]] && host=${CTARGET:-${CHOST}} 539 [[ -z ${host} ]] && host=${CTARGET:-${CHOST}}
370 host=${host%%-*} 540 host=${host%%-*}
371 541
372 case ${host} in 542 case ${host} in
543 aarch64*be) echo big;;
544 aarch64) echo little;;
373 alpha*) echo big;; 545 alpha*) echo big;;
374 arm*b*) echo big;; 546 arm*b*) echo big;;
375 arm*) echo little;; 547 arm*) echo little;;
376 cris*) echo little;; 548 cris*) echo little;;
377 hppa*) echo big;; 549 hppa*) echo big;;
378 i?86*) echo little;; 550 i?86*) echo little;;
379 ia64*) echo little;; 551 ia64*) echo little;;
380 m68*) echo big;; 552 m68*) echo big;;
381 mips*l*) echo little;; 553 mips*l*) echo little;;
382 mips*) echo big;; 554 mips*) echo big;;
555 powerpc*le) echo little;;
383 powerpc*) echo big;; 556 powerpc*) echo big;;
384 s390*) echo big;; 557 s390*) echo big;;
385 sh*b*) echo big;; 558 sh*b*) echo big;;
386 sh*) echo little;; 559 sh*) echo little;;
387 sparc*) echo big;; 560 sparc*) echo big;;
480 653
481# Returns true if gcc sets relro 654# Returns true if gcc sets relro
482gcc-specs-relro() { 655gcc-specs-relro() {
483 local directive 656 local directive
484 directive=$(gcc-specs-directive link_command) 657 directive=$(gcc-specs-directive link_command)
485 return $([[ "${directive/\{!norelro:}" != "${directive}" ]]) 658 [[ "${directive/\{!norelro:}" != "${directive}" ]]
486} 659}
487# Returns true if gcc sets now 660# Returns true if gcc sets now
488gcc-specs-now() { 661gcc-specs-now() {
489 local directive 662 local directive
490 directive=$(gcc-specs-directive link_command) 663 directive=$(gcc-specs-directive link_command)
491 return $([[ "${directive/\{!nonow:}" != "${directive}" ]]) 664 [[ "${directive/\{!nonow:}" != "${directive}" ]]
492} 665}
493# Returns true if gcc builds PIEs 666# Returns true if gcc builds PIEs
494gcc-specs-pie() { 667gcc-specs-pie() {
495 local directive 668 local directive
496 directive=$(gcc-specs-directive cc1) 669 directive=$(gcc-specs-directive cc1)
497 return $([[ "${directive/\{!nopie:}" != "${directive}" ]]) 670 [[ "${directive/\{!nopie:}" != "${directive}" ]]
498} 671}
499# Returns true if gcc builds with the stack protector 672# Returns true if gcc builds with the stack protector
500gcc-specs-ssp() { 673gcc-specs-ssp() {
501 local directive 674 local directive
502 directive=$(gcc-specs-directive cc1) 675 directive=$(gcc-specs-directive cc1)
503 return $([[ "${directive/\{!fno-stack-protector:}" != "${directive}" ]]) 676 [[ "${directive/\{!fno-stack-protector:}" != "${directive}" ]]
504} 677}
505# Returns true if gcc upgrades fstack-protector to fstack-protector-all 678# Returns true if gcc upgrades fstack-protector to fstack-protector-all
506gcc-specs-ssp-to-all() { 679gcc-specs-ssp-to-all() {
507 local directive 680 local directive
508 directive=$(gcc-specs-directive cc1) 681 directive=$(gcc-specs-directive cc1)
509 return $([[ "${directive/\{!fno-stack-protector-all:}" != "${directive}" ]]) 682 [[ "${directive/\{!fno-stack-protector-all:}" != "${directive}" ]]
510} 683}
511# Returns true if gcc builds with fno-strict-overflow 684# Returns true if gcc builds with fno-strict-overflow
512gcc-specs-nostrict() { 685gcc-specs-nostrict() {
513 local directive 686 local directive
514 directive=$(gcc-specs-directive cc1) 687 directive=$(gcc-specs-directive cc1)
515 return $([[ "${directive/\{!fstrict-overflow:}" != "${directive}" ]]) 688 [[ "${directive/\{!fstrict-overflow:}" != "${directive}" ]]
689}
690# Returns true if gcc builds with fstack-check
691gcc-specs-stack-check() {
692 local directive
693 directive=$(gcc-specs-directive cc1)
694 [[ "${directive/\{!fno-stack-check:}" != "${directive}" ]]
516} 695}
517 696
518 697
519# @FUNCTION: gen_usr_ldscript 698# @FUNCTION: gen_usr_ldscript
520# @USAGE: [-a] <list of libs to create linker scripts for> 699# @USAGE: [-a] <list of libs to create linker scripts for>
534 local lib libdir=$(get_libdir) output_format="" auto=false suffix=$(get_libname) 713 local lib libdir=$(get_libdir) output_format="" auto=false suffix=$(get_libname)
535 [[ -z ${ED+set} ]] && local ED=${D%/}${EPREFIX}/ 714 [[ -z ${ED+set} ]] && local ED=${D%/}${EPREFIX}/
536 715
537 tc-is-static-only && return 716 tc-is-static-only && return
538 717
718 # Eventually we'd like to get rid of this func completely #417451
719 case ${CTARGET:-${CHOST}} in
720 *-darwin*) ;;
721 *linux*|*-freebsd*|*-openbsd*|*-netbsd*)
722 use prefix && return 0 ;;
723 *) return 0 ;;
724 esac
725
539 # Just make sure it exists 726 # Just make sure it exists
540 dodir /usr/${libdir} 727 dodir /usr/${libdir}
541 728
542 if [[ $1 == "-a" ]] ; then 729 if [[ $1 == "-a" ]] ; then
543 auto=true 730 auto=true
545 dodir /${libdir} 732 dodir /${libdir}
546 fi 733 fi
547 734
548 # OUTPUT_FORMAT gives hints to the linker as to what binary format 735 # OUTPUT_FORMAT gives hints to the linker as to what binary format
549 # is referenced ... makes multilib saner 736 # is referenced ... makes multilib saner
737 local flags=( ${CFLAGS} ${LDFLAGS} -Wl,--verbose )
738 if $(tc-getLD) --version | grep -q 'GNU gold' ; then
739 # If they're using gold, manually invoke the old bfd. #487696
740 local d="${T}/bfd-linker"
741 mkdir -p "${d}"
742 ln -sf $(which ${CHOST}-ld.bfd) "${d}"/ld
743 flags+=( -B"${d}" )
744 fi
550 output_format=$($(tc-getCC) ${CFLAGS} ${LDFLAGS} -Wl,--verbose 2>&1 | sed -n 's/^OUTPUT_FORMAT("\([^"]*\)",.*/\1/p') 745 output_format=$($(tc-getCC) "${flags[@]}" 2>&1 | sed -n 's/^OUTPUT_FORMAT("\([^"]*\)",.*/\1/p')
551 [[ -n ${output_format} ]] && output_format="OUTPUT_FORMAT ( ${output_format} )" 746 [[ -n ${output_format} ]] && output_format="OUTPUT_FORMAT ( ${output_format} )"
552 747
553 for lib in "$@" ; do 748 for lib in "$@" ; do
554 local tlib 749 local tlib
555 if ${auto} ; then 750 if ${auto} ; then
600 # understand linker scripts, just create a symlink. 795 # understand linker scripts, just create a symlink.
601 pushd "${ED}/usr/${libdir}" > /dev/null 796 pushd "${ED}/usr/${libdir}" > /dev/null
602 ln -snf "../../${libdir}/${tlib}" "${lib}" 797 ln -snf "../../${libdir}/${tlib}" "${lib}"
603 popd > /dev/null 798 popd > /dev/null
604 ;; 799 ;;
605 *-aix*|*-irix*|*64*-hpux*|*-interix*|*-winnt*)
606 if ${auto} ; then
607 mv "${ED}"/usr/${libdir}/${lib}* "${ED}"/${libdir}/ || die
608 # no way to retrieve soname on these platforms (?)
609 tlib=$(readlink "${ED}"/${libdir}/${lib})
610 tlib=${tlib##*/}
611 if [[ -z ${tlib} ]] ; then
612 # ok, apparently was not a symlink, don't remove it and
613 # just link to it
614 tlib=${lib}
615 else
616 rm -f "${ED}"/${libdir}/${lib}
617 fi
618 else
619 tlib=${lib}
620 fi
621
622 # we don't have GNU binutils on these platforms, so we symlink
623 # instead, which seems to work fine. Keep it relative, otherwise
624 # we break some QA checks in Portage
625 # on interix, the linker scripts would work fine in _most_
626 # situations. if a library links to such a linker script the
627 # absolute path to the correct library is inserted into the binary,
628 # which is wrong, since anybody linking _without_ libtool will miss
629 # some dependencies, since the stupid linker cannot find libraries
630 # hardcoded with absolute paths (as opposed to the loader, which
631 # seems to be able to do this).
632 # this has been seen while building shared-mime-info which needs
633 # libxml2, but links without libtool (and does not add libz to the
634 # command line by itself).
635 pushd "${ED}/usr/${libdir}" > /dev/null
636 ln -snf "../../${libdir}/${tlib}" "${lib}"
637 popd > /dev/null
638 ;;
639 hppa*-hpux*) # PA-RISC 32bit (SOM) only, others (ELF) match *64*-hpux* above.
640 if ${auto} ; then
641 tlib=$(chatr "${ED}"/usr/${libdir}/${lib} | sed -n '/internal name:/{n;s/^ *//;p;q}')
642 [[ -z ${tlib} ]] && tlib=${lib}
643 tlib=${tlib##*/} # 'internal name' can have a path component
644 mv "${ED}"/usr/${libdir}/${lib}* "${ED}"/${libdir}/ || die
645 # some SONAMEs are funky: they encode a version before the .so
646 if [[ ${tlib} != ${lib}* ]] ; then
647 mv "${ED}"/usr/${libdir}/${tlib}* "${ED}"/${libdir}/ || die
648 fi
649 [[ ${tlib} != ${lib} ]] &&
650 rm -f "${ED}"/${libdir}/${lib}
651 else
652 tlib=$(chatr "${ED}"/${libdir}/${lib} | sed -n '/internal name:/{n;s/^ *//;p;q}')
653 [[ -z ${tlib} ]] && tlib=${lib}
654 tlib=${tlib##*/} # 'internal name' can have a path component
655 fi
656 pushd "${ED}"/usr/${libdir} >/dev/null
657 ln -snf "../../${libdir}/${tlib}" "${lib}"
658 # need the internal name in usr/lib too, to be available at runtime
659 # when linked with /path/to/lib.sl (hardcode_direct_absolute=yes)
660 [[ ${tlib} != ${lib} ]] &&
661 ln -snf "../../${libdir}/${tlib}" "${tlib}"
662 popd >/dev/null
663 ;;
664 *) 800 *)
665 if ${auto} ; then 801 if ${auto} ; then
666 tlib=$(scanelf -qF'%S#F' "${ED}"/usr/${libdir}/${lib}) 802 tlib=$(scanelf -qF'%S#F' "${ED}"/usr/${libdir}/${lib})
667 [[ -z ${tlib} ]] && die "unable to read SONAME from ${lib}" 803 [[ -z ${tlib} ]] && die "unable to read SONAME from ${lib}"
668 mv "${ED}"/usr/${libdir}/${lib}* "${ED}"/${libdir}/ || die 804 mv "${ED}"/usr/${libdir}/${lib}* "${ED}"/${libdir}/ || die
690 ;; 826 ;;
691 esac 827 esac
692 fperms a+x "/usr/${libdir}/${lib}" || die "could not change perms on ${lib}" 828 fperms a+x "/usr/${libdir}/${lib}" || die "could not change perms on ${lib}"
693 done 829 done
694} 830}
831
832fi

Legend:
Removed from v.1.107  
changed lines
  Added in v.1.136

  ViewVC Help
Powered by ViewVC 1.1.20