/[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.159 Revision 1.162
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.159 2011/12/07 06:42:40 vapier Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/flag-o-matic.eclass,v 1.162 2011/12/28 05:48:28 dirtyepic 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
9# @DESCRIPTION: 9# @DESCRIPTION:
10# This eclass contains a suite of functions to help developers sanely 10# This eclass contains a suite of functions to help developers sanely
11# and safely manage toolchain flags in their builds. 11# and safely manage toolchain flags in their builds.
12
13if [[ ${___ECLASS_ONCE_FLAG_O_MATIC} != "recur -_+^+_- spank" ]] ; then
14___ECLASS_ONCE_FLAG_O_MATIC="recur -_+^+_- spank"
12 15
13inherit eutils toolchain-funcs multilib 16inherit eutils toolchain-funcs multilib
14 17
15################ DEPRECATED functions ################ 18################ DEPRECATED functions ################
16# The following are still present to avoid breaking existing 19# The following are still present to avoid breaking existing
29# {C,CXX,F,FC}FLAGS that we allow in strip-flags 32# {C,CXX,F,FC}FLAGS that we allow in strip-flags
30# Note: shell globs and character lists are allowed 33# Note: shell globs and character lists are allowed
31setup-allowed-flags() { 34setup-allowed-flags() {
32 if [[ -z ${ALLOWED_FLAGS} ]] ; then 35 if [[ -z ${ALLOWED_FLAGS} ]] ; then
33 export ALLOWED_FLAGS="-pipe" 36 export ALLOWED_FLAGS="-pipe"
34 export ALLOWED_FLAGS="${ALLOWED_FLAGS} -O -O0 -O1 -O2 -mcpu -march -mtune" 37 export ALLOWED_FLAGS="${ALLOWED_FLAGS} -O -O1 -O2 -Os -mcpu -march -mtune"
35 export ALLOWED_FLAGS="${ALLOWED_FLAGS} -fstack-protector -fstack-protector-all" 38 export ALLOWED_FLAGS="${ALLOWED_FLAGS} -fstack-protector -fstack-protector-all"
36 export ALLOWED_FLAGS="${ALLOWED_FLAGS} -fbounds-checking -fno-strict-overflow" 39 export ALLOWED_FLAGS="${ALLOWED_FLAGS} -fbounds-checking -fno-strict-overflow"
37 export ALLOWED_FLAGS="${ALLOWED_FLAGS} -fno-PIE -fno-pie -fno-unit-at-a-time" 40 export ALLOWED_FLAGS="${ALLOWED_FLAGS} -fno-PIE -fno-pie -fno-unit-at-a-time"
38 export ALLOWED_FLAGS="${ALLOWED_FLAGS} -g -g[0-9] -ggdb -ggdb[0-9] -gstabs -gstabs+" 41 export ALLOWED_FLAGS="${ALLOWED_FLAGS} -g -g[0-9] -ggdb -ggdb[0-9] -gstabs -gstabs+"
39 export ALLOWED_FLAGS="${ALLOWED_FLAGS} -fno-ident -fpermissive" 42 export ALLOWED_FLAGS="${ALLOWED_FLAGS} -fno-ident -fpermissive"
59 ALLOWED_FLAGS="${ALLOWED_FLAGS} -mno-fma4 -mno-movbe -mno-xop -mno-lwp" 62 ALLOWED_FLAGS="${ALLOWED_FLAGS} -mno-fma4 -mno-movbe -mno-xop -mno-lwp"
60 # 4.6 63 # 4.6
61 ALLOWED_FLAGS="${ALLOWED_FLAGS} -mno-fsgsbase -mno-rdrnd -mno-f16c \ 64 ALLOWED_FLAGS="${ALLOWED_FLAGS} -mno-fsgsbase -mno-rdrnd -mno-f16c \
62 -mno-bmi -mno-tbm" 65 -mno-bmi -mno-tbm"
63 66
64 # {C,CXX,F,FC}FLAGS that we are think is ok, but needs testing
65 # NOTE: currently -Os have issues with gcc3 and K6* arch's
66 export UNSTABLE_FLAGS="-Os -O3 -freorder-blocks"
67 return 0 67 return 0
68} 68}
69 69
70# inverted filters for hardened compiler. This is trying to unpick 70# inverted filters for hardened compiler. This is trying to unpick
71# the hardened compiler defaults. 71# the hardened compiler defaults.
333 local NEW_CFLAGS="" 333 local NEW_CFLAGS=""
334 local NEW_CXXFLAGS="" 334 local NEW_CXXFLAGS=""
335 local NEW_FFLAGS="" 335 local NEW_FFLAGS=""
336 local NEW_FCFLAGS="" 336 local NEW_FCFLAGS=""
337 337
338 # Allow unstable C[XX]FLAGS if we are using unstable profile ...
339 if has "~$(tc-arch)" ${ACCEPT_KEYWORDS} ; then
340 ALLOWED_FLAGS="${ALLOWED_FLAGS} ${UNSTABLE_FLAGS}"
341 fi
342
343 set -f # disable pathname expansion 338 set -f # disable pathname expansion
344 339
345 for x in ${CFLAGS}; do 340 for x in ${CFLAGS}; do
346 for y in ${ALLOWED_FLAGS}; do 341 for y in ${ALLOWED_FLAGS}; do
347 flag=${x%%=*} 342 flag=${x%%=*}
682 *GNU*) # GNU ld 677 *GNU*) # GNU ld
683 echo "-Wl,--no-as-needed" ;; 678 echo "-Wl,--no-as-needed" ;;
684 esac 679 esac
685} 680}
686 681
687# Some tests for when we screw with things and want to make 682fi
688# sure we didn't break anything
689#TESTS() {
690# CFLAGS="-a -b -c=1"
691# CXXFLAGS="-x -y -z=2"
692# LDFLAGS="-l -m -n=3"
693#
694# die() { exit 1; }
695# (is-flag 1 2 3) && die
696# (is-ldflag 1 2 3) && die
697#
698# is-flagq -l && die
699# is-ldflagq -a && die
700# is-flagq -a || die
701# is-flagq -x || die
702# is-ldflagq -n=* || die
703# is-ldflagq -n && die
704#
705# strip-unsupported-flags
706# [[ ${CFLAGS} == "-c=1" ]] || die
707# [[ ${CXXFLAGS} == "-y -z=2" ]] || die
708#
709# echo "All tests pass"
710#}
711#TESTS

Legend:
Removed from v.1.159  
changed lines
  Added in v.1.162

  ViewVC Help
Powered by ViewVC 1.1.20