/[gentoo-x86]/eclass/flag-o-matic.eclass
Gentoo

Diff of /eclass/flag-o-matic.eclass

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

Revision 1.173 Revision 1.183
1# Copyright 1999-2012 Gentoo Foundation 1# Copyright 1999-2012 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/flag-o-matic.eclass,v 1.173 2012/05/31 00:29:06 vapier Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/flag-o-matic.eclass,v 1.183 2012/11/18 08:29:17 vapier Exp $
4 4
5# @ECLASS: flag-o-matic.eclass 5# @ECLASS: flag-o-matic.eclass
6# @MAINTAINER: 6# @MAINTAINER:
7# toolchain@gentoo.org 7# toolchain@gentoo.org
8# @BLURB: common functions to manipulate and query toolchain flags 8# @BLURB: common functions to manipulate and query toolchain flags
18# Return all the flag variables that our high level funcs operate on. 18# Return all the flag variables that our high level funcs operate on.
19all-flag-vars() { 19all-flag-vars() {
20 echo {C,CPP,CXX,CCAS,F,FC,LD}FLAGS 20 echo {C,CPP,CXX,CCAS,F,FC,LD}FLAGS
21} 21}
22 22
23# {C,CXX,F,FC}FLAGS that we allow in strip-flags 23# {C,CPP,CXX,CCAS,F,FC,LD}FLAGS that we allow in strip-flags
24# Note: shell globs and character lists are allowed 24# Note: shell globs and character lists are allowed
25setup-allowed-flags() { 25setup-allowed-flags() {
26 ALLOWED_FLAGS="-pipe" 26 ALLOWED_FLAGS="-pipe"
27 ALLOWED_FLAGS+=" -O -O1 -O2 -Os -mcpu -march -mtune" 27 ALLOWED_FLAGS+=" -O -O1 -O2 -Os -mcpu -march -mtune"
28 ALLOWED_FLAGS+=" -fstack-protector -fstack-protector-all" 28 ALLOWED_FLAGS+=" -fstack-protector -fstack-protector-all"
43 -msoft-float -mno-soft-float -mhard-float -mno-hard-float -mfpu \ 43 -msoft-float -mno-soft-float -mhard-float -mno-hard-float -mfpu \
44 -mieee -mieee-with-inexact -mschedule -mfloat-gprs -mspe -mno-spe \ 44 -mieee -mieee-with-inexact -mschedule -mfloat-gprs -mspe -mno-spe \
45 -mtls-direct-seg-refs -mno-tls-direct-seg-refs -mflat -mno-flat \ 45 -mtls-direct-seg-refs -mno-tls-direct-seg-refs -mflat -mno-flat \
46 -mno-faster-structs -mfaster-structs -m32 -m64 -mx32 -mabi \ 46 -mno-faster-structs -mfaster-structs -m32 -m64 -mx32 -mabi \
47 -mlittle-endian -mbig-endian -EL -EB -fPIC -mlive-g0 -mcmodel \ 47 -mlittle-endian -mbig-endian -EL -EB -fPIC -mlive-g0 -mcmodel \
48 -mstack-bias -mno-stack-bias -msecure-plt -m*-toc -D* -U*" 48 -mstack-bias -mno-stack-bias -msecure-plt -m*-toc -mfloat-abi=* \
49 -D* -U*"
49 50
50 # 4.5 51 # 4.5
51 ALLOWED_FLAGS+=" -mno-fma4 -mno-movbe -mno-xop -mno-lwp" 52 ALLOWED_FLAGS+=" -mno-fma4 -mno-movbe -mno-xop -mno-lwp"
52 # 4.6 53 # 4.6
53 ALLOWED_FLAGS+=" -mno-fsgsbase -mno-rdrnd -mno-f16c -mno-bmi -mno-tbm" 54 ALLOWED_FLAGS+=" -mno-fsgsbase -mno-rdrnd -mno-f16c -mno-bmi -mno-tbm"
55 # 4.7
56 ALLOWED_FLAGS+=" -mno-avx2 -mno-bmi2 -mno-fma -mno-lzcnt"
57
58 # CPPFLAGS and LDFLAGS
59 ALLOWED_FLAGS+=" -I* -L* -R* -Wl,*"
54 60
55 export ALLOWED_FLAGS 61 export ALLOWED_FLAGS
56 return 0 62 return 0
57} 63}
58 64
189append-ldflags() { 195append-ldflags() {
190 [[ $# -eq 0 ]] && return 0 196 [[ $# -eq 0 ]] && return 0
191 local flag 197 local flag
192 for flag in "$@"; do 198 for flag in "$@"; do
193 [[ ${flag} == -l* ]] && \ 199 [[ ${flag} == -l* ]] && \
194 ewarn "Appending a library link instruction (${flag}); libraries to link to should not be passed through LDFLAGS" 200 eqawarn "Appending a library link instruction (${flag}); libraries to link to should not be passed through LDFLAGS"
195 done 201 done
196 202
197 export LDFLAGS="${LDFLAGS} $*" 203 export LDFLAGS="${LDFLAGS} $*"
198 return 0 204 return 0
199} 205}
257 done 263 done
258 return 0 264 return 0
259} 265}
260 266
261_is_flagq() { 267_is_flagq() {
262 local x 268 local x var
269 eval var=\""\${$1[*]}"\"
263 for x in ${!1} ; do 270 for x in ${var} ; do
264 [[ ${x} == $2 ]] && return 0 271 [[ ${x} == $2 ]] && return 0
265 done 272 done
266 return 1 273 return 1
267} 274}
268 275
339 return 0 346 return 0
340} 347}
341 348
342# @FUNCTION: strip-flags 349# @FUNCTION: strip-flags
343# @DESCRIPTION: 350# @DESCRIPTION:
344# Strip C[XX]FLAGS of everything except known good/safe flags. 351# Strip *FLAGS of everything except known good/safe flags. This runs over all
352# flags returned by all_flag_vars().
345strip-flags() { 353strip-flags() {
346 local x y var 354 local x y var
347 355
348 setup-allowed-flags 356 setup-allowed-flags
349 357
375 return 0 383 return 0
376} 384}
377 385
378test-flag-PROG() { 386test-flag-PROG() {
379 local comp=$1 387 local comp=$1
380 local flag=$2 388 local lang=$2
389 local flag=$3
381 390
382 [[ -z ${comp} || -z ${flag} ]] && return 1 391 [[ -z ${comp} || -z ${flag} ]] && return 1
383 392
384 # use -c so we can test the assembler as well 393 # use -c so we can test the assembler as well
385 local PROG=$(tc-get${comp}) 394 local PROG=$(tc-get${comp})
386 ${PROG} "${flag}" -c -o /dev/null -xc /dev/null \ 395 ${PROG} "${flag}" -c -o /dev/null -x${lang} /dev/null \
387 > /dev/null 2>&1 396 > /dev/null 2>&1
388} 397}
389 398
390# @FUNCTION: test-flag-CC 399# @FUNCTION: test-flag-CC
391# @USAGE: <flag> 400# @USAGE: <flag>
392# @DESCRIPTION: 401# @DESCRIPTION:
393# Returns shell true if <flag> is supported by the C compiler, else returns shell false. 402# Returns shell true if <flag> is supported by the C compiler, else returns shell false.
394test-flag-CC() { test-flag-PROG "CC" "$1"; } 403test-flag-CC() { test-flag-PROG "CC" c "$1"; }
395 404
396# @FUNCTION: test-flag-CXX 405# @FUNCTION: test-flag-CXX
397# @USAGE: <flag> 406# @USAGE: <flag>
398# @DESCRIPTION: 407# @DESCRIPTION:
399# Returns shell true if <flag> is supported by the C++ compiler, else returns shell false. 408# Returns shell true if <flag> is supported by the C++ compiler, else returns shell false.
400test-flag-CXX() { test-flag-PROG "CXX" "$1"; } 409test-flag-CXX() { test-flag-PROG "CXX" c++ "$1"; }
401 410
402# @FUNCTION: test-flag-F77 411# @FUNCTION: test-flag-F77
403# @USAGE: <flag> 412# @USAGE: <flag>
404# @DESCRIPTION: 413# @DESCRIPTION:
405# Returns shell true if <flag> is supported by the Fortran 77 compiler, else returns shell false. 414# Returns shell true if <flag> is supported by the Fortran 77 compiler, else returns shell false.
406test-flag-F77() { test-flag-PROG "F77" "$1"; } 415test-flag-F77() { test-flag-PROG "F77" f77 "$1"; }
407 416
408# @FUNCTION: test-flag-FC 417# @FUNCTION: test-flag-FC
409# @USAGE: <flag> 418# @USAGE: <flag>
410# @DESCRIPTION: 419# @DESCRIPTION:
411# Returns shell true if <flag> is supported by the Fortran 90 compiler, else returns shell false. 420# Returns shell true if <flag> is supported by the Fortran 90 compiler, else returns shell false.
412test-flag-FC() { test-flag-PROG "FC" "$1"; } 421test-flag-FC() { test-flag-PROG "FC" f95 "$1"; }
413 422
414test-flags-PROG() { 423test-flags-PROG() {
415 local comp=$1 424 local comp=$1
416 local flags 425 local flags=()
417 local x 426 local x
418 427
419 shift 428 shift
420 429
421 [[ -z ${comp} ]] && return 1 430 [[ -z ${comp} ]] && return 1
422 431
423 for x in "$@" ; do 432 for x ; do
424 test-flag-${comp} "${x}" && flags="${flags}${flags:+ }${x}" 433 test-flag-${comp} "${x}" && flags+=( "${x}" )
425 done 434 done
426 435
427 echo "${flags}" 436 echo "${flags[*]}"
428 437
429 # Just bail if we dont have any flags 438 # Just bail if we dont have any flags
430 [[ -n ${flags} ]] 439 [[ ${#flags[@]} -gt 0 ]]
431} 440}
432 441
433# @FUNCTION: test-flags-CC 442# @FUNCTION: test-flags-CC
434# @USAGE: <flags> 443# @USAGE: <flags>
435# @DESCRIPTION: 444# @DESCRIPTION:
589raw-ldflags() { 598raw-ldflags() {
590 local x input="$@" 599 local x input="$@"
591 [[ -z ${input} ]] && input=${LDFLAGS} 600 [[ -z ${input} ]] && input=${LDFLAGS}
592 set -- 601 set --
593 for x in ${input} ; do 602 for x in ${input} ; do
603 case ${x} in
604 -Wl,*)
594 x=${x#-Wl,} 605 x=${x#-Wl,}
595 set -- "$@" ${x//,/ } 606 set -- "$@" ${x//,/ }
607 ;;
608 *) # Assume it's a compiler driver flag, so throw it away #441808
609 ;;
610 esac
596 done 611 done
597 echo "$@" 612 echo "$@"
598} 613}
599 614
600# @FUNCTION: no-as-needed 615# @FUNCTION: no-as-needed

Legend:
Removed from v.1.173  
changed lines
  Added in v.1.183

  ViewVC Help
Powered by ViewVC 1.1.20