| 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.161 2011/12/15 05:23:15 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 |
| … | |
… | |
| 32 | # {C,CXX,F,FC}FLAGS that we allow in strip-flags |
32 | # {C,CXX,F,FC}FLAGS that we allow in strip-flags |
| 33 | # Note: shell globs and character lists are allowed |
33 | # Note: shell globs and character lists are allowed |
| 34 | setup-allowed-flags() { |
34 | setup-allowed-flags() { |
| 35 | if [[ -z ${ALLOWED_FLAGS} ]] ; then |
35 | if [[ -z ${ALLOWED_FLAGS} ]] ; then |
| 36 | export ALLOWED_FLAGS="-pipe" |
36 | export ALLOWED_FLAGS="-pipe" |
| 37 | 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" |
| 38 | export ALLOWED_FLAGS="${ALLOWED_FLAGS} -fstack-protector -fstack-protector-all" |
38 | export ALLOWED_FLAGS="${ALLOWED_FLAGS} -fstack-protector -fstack-protector-all" |
| 39 | export ALLOWED_FLAGS="${ALLOWED_FLAGS} -fbounds-checking -fno-strict-overflow" |
39 | export ALLOWED_FLAGS="${ALLOWED_FLAGS} -fbounds-checking -fno-strict-overflow" |
| 40 | 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" |
| 41 | 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+" |
| 42 | export ALLOWED_FLAGS="${ALLOWED_FLAGS} -fno-ident -fpermissive" |
42 | export ALLOWED_FLAGS="${ALLOWED_FLAGS} -fno-ident -fpermissive" |
| … | |
… | |
| 62 | 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" |
| 63 | # 4.6 |
63 | # 4.6 |
| 64 | ALLOWED_FLAGS="${ALLOWED_FLAGS} -mno-fsgsbase -mno-rdrnd -mno-f16c \ |
64 | ALLOWED_FLAGS="${ALLOWED_FLAGS} -mno-fsgsbase -mno-rdrnd -mno-f16c \ |
| 65 | -mno-bmi -mno-tbm" |
65 | -mno-bmi -mno-tbm" |
| 66 | |
66 | |
| 67 | # {C,CXX,F,FC}FLAGS that we are think is ok, but needs testing |
|
|
| 68 | # NOTE: currently -Os have issues with gcc3 and K6* arch's |
|
|
| 69 | export UNSTABLE_FLAGS="-Os -O3 -freorder-blocks" |
|
|
| 70 | return 0 |
67 | return 0 |
| 71 | } |
68 | } |
| 72 | |
69 | |
| 73 | # inverted filters for hardened compiler. This is trying to unpick |
70 | # inverted filters for hardened compiler. This is trying to unpick |
| 74 | # the hardened compiler defaults. |
71 | # the hardened compiler defaults. |
| … | |
… | |
| 336 | local NEW_CFLAGS="" |
333 | local NEW_CFLAGS="" |
| 337 | local NEW_CXXFLAGS="" |
334 | local NEW_CXXFLAGS="" |
| 338 | local NEW_FFLAGS="" |
335 | local NEW_FFLAGS="" |
| 339 | local NEW_FCFLAGS="" |
336 | local NEW_FCFLAGS="" |
| 340 | |
337 | |
| 341 | # Allow unstable C[XX]FLAGS if we are using unstable profile ... |
|
|
| 342 | if has "~$(tc-arch)" ${ACCEPT_KEYWORDS} ; then |
|
|
| 343 | ALLOWED_FLAGS="${ALLOWED_FLAGS} ${UNSTABLE_FLAGS}" |
|
|
| 344 | fi |
|
|
| 345 | |
|
|
| 346 | set -f # disable pathname expansion |
338 | set -f # disable pathname expansion |
| 347 | |
339 | |
| 348 | for x in ${CFLAGS}; do |
340 | for x in ${CFLAGS}; do |
| 349 | for y in ${ALLOWED_FLAGS}; do |
341 | for y in ${ALLOWED_FLAGS}; do |
| 350 | flag=${x%%=*} |
342 | flag=${x%%=*} |