/[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.163 Revision 1.166
1# Copyright 1999-2011 Gentoo Foundation 1# Copyright 1999-2011 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.163 2011/12/28 06:28:55 dirtyepic Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/flag-o-matic.eclass,v 1.166 2012/01/14 08:22:13 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
12 12
13if [[ ${___ECLASS_ONCE_FLAG_O_MATIC} != "recur -_+^+_- spank" ]] ; then 13if [[ ${___ECLASS_ONCE_FLAG_O_MATIC} != "recur -_+^+_- spank" ]] ; then
14___ECLASS_ONCE_FLAG_O_MATIC="recur -_+^+_- spank" 14___ECLASS_ONCE_FLAG_O_MATIC="recur -_+^+_- spank"
15 15
16inherit eutils toolchain-funcs multilib 16inherit eutils toolchain-funcs multilib
17
18################ DEPRECATED functions ################
19# The following are still present to avoid breaking existing
20# code more than necessary; however they are deprecated. Please
21# use gcc-specs-* from toolchain-funcs.eclass instead, if you
22# need to know which hardened techs are active in the compiler.
23# See bug #100974
24#
25# has_hardened
26# has_pie
27# has_pic
28# has_ssp_all
29# has_ssp
30
31 17
32# {C,CXX,F,FC}FLAGS that we allow in strip-flags 18# {C,CXX,F,FC}FLAGS that we allow in strip-flags
33# Note: shell globs and character lists are allowed 19# Note: shell globs and character lists are allowed
34setup-allowed-flags() { 20setup-allowed-flags() {
35 ALLOWED_FLAGS="-pipe" 21 ALLOWED_FLAGS="-pipe"
111} 97}
112 98
113# @FUNCTION: filter-flags 99# @FUNCTION: filter-flags
114# @USAGE: <flags> 100# @USAGE: <flags>
115# @DESCRIPTION: 101# @DESCRIPTION:
116# Remove particular <flags> from {C,CPP,CXX,F,FC}FLAGS. Accepts shell globs. 102# Remove particular <flags> from {C,CPP,CXX,F,FC,LD}FLAGS. Accepts shell globs.
117filter-flags() { 103filter-flags() {
118 _filter-hardened "$@" 104 _filter-hardened "$@"
105 local v
106 for v in C CPP CXX F FC LD ; do
119 _filter-var CFLAGS "$@" 107 _filter-var ${v}FLAGS "$@"
120 _filter-var CPPFLAGS "$@" 108 done
121 _filter-var CXXFLAGS "$@"
122 _filter-var FFLAGS "$@"
123 _filter-var FCFLAGS "$@"
124 return 0 109 return 0
125} 110}
126 111
127# @FUNCTION: filter-lfs-flags 112# @FUNCTION: filter-lfs-flags
128# @DESCRIPTION: 113# @DESCRIPTION:
526 fi 511 fi
527 done 512 done
528 return 1 513 return 1
529} 514}
530 515
531# DEAD FUNCS. Remove by Dec 2011.
532test_flag() { die "$0: deprecated, please use test-flags()!" ; }
533has_hardened() { die "$0: deprecated, please use gcc-specs-{relro,now}()!" ; }
534has_pic() { die "$0: deprecated, please use gcc-specs-pie()!" ; }
535has_pie() { die "$0: deprecated, please use gcc-specs-pie()!" ; }
536has_ssp_all() { die "$0: deprecated, please use gcc-specs-ssp()!" ; }
537has_ssp() { die "$0: deprecated, please use gcc-specs-ssp()!" ; }
538
539# @FUNCTION: has_m64 516# @FUNCTION: has_m64
540# @DESCRIPTION: 517# @DESCRIPTION:
541# This doesn't test if the flag is accepted, it tests if the flag actually 518# This doesn't test if the flag is accepted, it tests if the flag actually
542# WORKS. Non-multilib gcc will take both -m32 and -m64. If the flag works 519# WORKS. Non-multilib gcc will take both -m32 and -m64. If the flag works
543# return code is 0, else the return code is 1. 520# return code is 0, else the return code is 1.
544has_m64() { 521has_m64() {
522 eqawarn "${FUNCNAME}: don't use this anymore"
523
545 # this doesnt test if the flag is accepted, it tests if the flag 524 # this doesnt test if the flag is accepted, it tests if the flag
546 # actually -WORKS-. non-multilib gcc will take both -m32 and -m64! 525 # actually -WORKS-. non-multilib gcc will take both -m32 and -m64!
547 # please dont replace this function with test_flag in some future 526 # please dont replace this function with test_flag in some future
548 # clean-up! 527 # clean-up!
549 528
555 rm -f "${temp}".c 534 rm -f "${temp}".c
556 [[ ${ret} != 1 ]] && return 0 535 [[ ${ret} != 1 ]] && return 0
557 return 1 536 return 1
558} 537}
559 538
560# @FUNCTION: has_m32
561# @DESCRIPTION:
562# This doesn't test if the flag is accepted, it tests if the flag actually
563# WORKS. Non-mulilib gcc will take both -m32 and -64. If the flag works return
564# code is 0, else return code is 1.
565has_m32() { 539has_m32() {
566 # this doesnt test if the flag is accepted, it tests if the flag 540 die "${FUNCNAME}: don't use this anymore"
567 # actually -WORKS-. non-multilib gcc will take both -m32 and -m64!
568 # please dont replace this function with test_flag in some future
569 # clean-up!
570
571 [ "$(tc-arch)" = "amd64" ] && has_multilib_profile && return 0
572
573 local temp=$(emktemp)
574 echo "int main() { return(0); }" > "${temp}".c
575 MY_CC=$(tc-getCC)
576 ${MY_CC/ .*/} -m32 -o "$(emktemp)" "${temp}".c > /dev/null 2>&1
577 local ret=$?
578 rm -f "${temp}".c
579 [[ ${ret} != 1 ]] && return 0
580 return 1
581} 541}
582 542
583# @FUNCTION: replace-sparc64-flags 543# @FUNCTION: replace-sparc64-flags
584# @DESCRIPTION: 544# @DESCRIPTION:
585# Sets mcpu to v8 and uses the original value as mtune if none specified. 545# Sets mcpu to v8 and uses the original value as mtune if none specified.

Legend:
Removed from v.1.163  
changed lines
  Added in v.1.166

  ViewVC Help
Powered by ViewVC 1.1.20