/[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.129 Revision 1.145
1# Copyright 1999-2009 Gentoo Foundation 1# Copyright 1999-2009 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.129 2009/01/04 17:22:16 vapier Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/flag-o-matic.eclass,v 1.145 2009/10/04 10:00:53 ssuominen 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
39 export ALLOWED_FLAGS="${ALLOWED_FLAGS} -fno-ident" 39 export ALLOWED_FLAGS="${ALLOWED_FLAGS} -fno-ident"
40 export ALLOWED_FLAGS="${ALLOWED_FLAGS} -W* -w" 40 export ALLOWED_FLAGS="${ALLOWED_FLAGS} -W* -w"
41 fi 41 fi
42 # allow a bunch of flags that negate features / control ABI 42 # allow a bunch of flags that negate features / control ABI
43 ALLOWED_FLAGS="${ALLOWED_FLAGS} -fno-stack-protector -fno-stack-protector-all \ 43 ALLOWED_FLAGS="${ALLOWED_FLAGS} -fno-stack-protector -fno-stack-protector-all \
44 -fno-strict-aliasing -fno-bounds-checking -fstrict-overflow" 44 -fno-strict-aliasing -fno-bounds-checking -fstrict-overflow -fno-omit-frame-pointer"
45 ALLOWED_FLAGS="${ALLOWED_FLAGS} -mregparm -mno-app-regs -mapp-regs \ 45 ALLOWED_FLAGS="${ALLOWED_FLAGS} -mregparm -mno-app-regs -mapp-regs \
46 -mno-mmx -mno-sse -mno-sse2 -mno-sse3 -mno-3dnow \ 46 -mno-mmx -mno-sse -mno-sse2 -mno-sse3 -mno-ssse3 -mno-sse4 -mno-sse4.1 \
47 -mno-sse4.2 -mno-avx -mno-aes -mno-pclmul -mno-sse4a -mno-3dnow \
48 -mno-popcnt -mno-abm \
47 -mips1 -mips2 -mips3 -mips4 -mips32 -mips64 -mips16 \ 49 -mips1 -mips2 -mips3 -mips4 -mips32 -mips64 -mips16 -mplt \
48 -msoft-float -mno-soft-float -mhard-float -mno-hard-float -mfpu \ 50 -msoft-float -mno-soft-float -mhard-float -mno-hard-float -mfpu \
49 -mieee -mieee-with-inexact -mschedule \ 51 -mieee -mieee-with-inexact -mschedule \
50 -mtls-direct-seg-refs -mno-tls-direct-seg-refs \ 52 -mtls-direct-seg-refs -mno-tls-direct-seg-refs \
51 -mflat -mno-flat -mno-faster-structs -mfaster-structs \ 53 -mflat -mno-flat -mno-faster-structs -mfaster-structs \
52 -m32 -m64 -mabi -mlittle-endian -mbig-endian -EL -EB -fPIC \ 54 -m32 -m64 -mabi -mlittle-endian -mbig-endian -EL -EB -fPIC \
71 -fPIC|-fpic|-fPIE|-fpie|-Wl,pie|-pie) 73 -fPIC|-fpic|-fPIE|-fpie|-Wl,pie|-pie)
72 gcc-specs-pie || continue 74 gcc-specs-pie || continue
73 is-flagq -nopie || append-flags -nopie;; 75 is-flagq -nopie || append-flags -nopie;;
74 -fstack-protector) 76 -fstack-protector)
75 gcc-specs-ssp || continue 77 gcc-specs-ssp || continue
76 is-flagq -fno-stack-protector || append-flags -fno-stack-protector;; 78 is-flagq -fno-stack-protector || append-flags $(test-flags -fno-stack-protector);;
77 -fstack-protector-all) 79 -fstack-protector-all)
78 gcc-specs-ssp-to-all || continue 80 gcc-specs-ssp-to-all || continue
79 is-flagq -fno-stack-protector-all || append-flags -fno-stack-protector-all;; 81 is-flagq -fno-stack-protector-all || append-flags $(test-flags -fno-stack-protector-all);;
80 -fno-strict-overflow) 82 -fno-strict-overflow)
81 gcc-specs-nostrict || continue 83 gcc-specs-nostrict || continue
82 is-flagq -fstrict-overflow || append-flags -fstrict-overflow;; 84 is-flagq -fstrict-overflow || append-flags $(test-flags -fstrict-overflow);;
83 esac 85 esac
84 done 86 done
85} 87}
86 88
87# Remove occurrences of strings from variable given in $1 89# Remove occurrences of strings from variable given in $1
134 [[ -z $* ]] && return 0 136 [[ -z $* ]] && return 0
135 export CPPFLAGS="${CPPFLAGS} $*" 137 export CPPFLAGS="${CPPFLAGS} $*"
136 return 0 138 return 0
137} 139}
138 140
141# @FUNCTION: append-cflags
142# @USAGE: <flags>
143# @DESCRIPTION:
144# Add extra <flags> to the current CFLAGS.
145append-cflags() {
146 [[ -z $* ]] && return 0
147 export CFLAGS="${CFLAGS} $*"
148 return 0
149}
150
151# @FUNCTION: append-cxxflags
152# @USAGE: <flags>
153# @DESCRIPTION:
154# Add extra <flags> to the current CXXFLAGS.
155append-cxxflags() {
156 [[ -z $* ]] && return 0
157 export CXXFLAGS="${CXXFLAGS} $*"
158 return 0
159}
160
139# @FUNCTION: append-fflags 161# @FUNCTION: append-fflags
140# @USAGE: <flags> 162# @USAGE: <flags>
141# @DESCRIPTION: 163# @DESCRIPTION:
142# Add extra <flags> to the current {F,FC}FLAGS. 164# Add extra <flags> to the current {F,FC}FLAGS.
143append-fflags() { 165append-fflags() {
159# @USAGE: <flags> 181# @USAGE: <flags>
160# @DESCRIPTION: 182# @DESCRIPTION:
161# Add extra <flags> to your current {C,CXX,F,FC}FLAGS. 183# Add extra <flags> to your current {C,CXX,F,FC}FLAGS.
162append-flags() { 184append-flags() {
163 [[ -z $* ]] && return 0 185 [[ -z $* ]] && return 0
164 export CFLAGS="${CFLAGS} $*" 186 append-cflags "$@"
165 export CXXFLAGS="${CXXFLAGS} $*" 187 append-cxxflags "$@"
166 export FFLAGS="${FFLAGS} $*" 188 append-fflags "$@"
167 export FCFLAGS="${FCFLAGS} $*"
168 return 0 189 return 0
169} 190}
170 191
171# @FUNCTION: replace-flags 192# @FUNCTION: replace-flags
172# @USAGE: <old> <new> 193# @USAGE: <old> <new>
302 local NEW_CXXFLAGS="" 323 local NEW_CXXFLAGS=""
303 local NEW_FFLAGS="" 324 local NEW_FFLAGS=""
304 local NEW_FCFLAGS="" 325 local NEW_FCFLAGS=""
305 326
306 # Allow unstable C[XX]FLAGS if we are using unstable profile ... 327 # Allow unstable C[XX]FLAGS if we are using unstable profile ...
307 if has ~$(tc-arch) ${ACCEPT_KEYWORDS} ; then 328 if has "~$(tc-arch)" ${ACCEPT_KEYWORDS} ; then
308 ALLOWED_FLAGS="${ALLOWED_FLAGS} ${UNSTABLE_FLAGS}" 329 ALLOWED_FLAGS="${ALLOWED_FLAGS} ${UNSTABLE_FLAGS}"
309 fi 330 fi
310 331
311 set -f # disable pathname expansion 332 set -f # disable pathname expansion
312 333
556 ewarn "has_ssp_all: deprecated, please use gcc-specs-ssp()!" >&2 577 ewarn "has_ssp_all: deprecated, please use gcc-specs-ssp()!" >&2
557 578
558 # note; this matches only -fstack-protector-all 579 # note; this matches only -fstack-protector-all
559 [[ ${CFLAGS/-fstack-protector-all} != ${CFLAGS} || \ 580 [[ ${CFLAGS/-fstack-protector-all} != ${CFLAGS} || \
560 -n $(echo | $(tc-getCC) ${CFLAGS} -E -dM - | grep __SSP_ALL__) ]] || \ 581 -n $(echo | $(tc-getCC) ${CFLAGS} -E -dM - | grep __SSP_ALL__) ]] || \
561 gcc-specs-ssp-all 582 gcc-specs-ssp-to-all
562} 583}
563 584
564# @FUNCTION: has_ssp 585# @FUNCTION: has_ssp
565# @DESCRIPTION: 586# @DESCRIPTION:
566# DEPRECATED - use gcc-specs-ssp from toolchain-funcs 587# DEPRECATED - use gcc-specs-ssp from toolchain-funcs
692# @FUNCTION: bindnow-flags 713# @FUNCTION: bindnow-flags
693# @RETURN: Returns the flags to enable "now" binding in the current selected linker. 714# @RETURN: Returns the flags to enable "now" binding in the current selected linker.
694# @DESCRIPTION: 715# @DESCRIPTION:
695# DEPRECATED - Gets the flags needed for "NOW" binding 716# DEPRECATED - Gets the flags needed for "NOW" binding
696bindnow-flags() { 717bindnow-flags() {
697 ewarn "QA: stop using the bindnow-flags function ... simply drop it from your ebuild" 718 eerror "QA: stop using the bindnow-flags function ... simply drop it from your ebuild"
719 die "Stop using bindnow-flags."
698} 720}
699 721
722# @FUNCTION: no-as-needed
723# @RETURN: Flag to disable asneeded behavior for use with append-ldflags.
724no-as-needed() {
725 case $($(tc-getLD) -v 2>&1 </dev/null) in
726 *GNU*) # GNU ld
727 echo "-Wl,--no-as-needed" ;;
728 esac
729}
700 730
701# Some tests for when we screw with things and want to make 731# Some tests for when we screw with things and want to make
702# sure we didn't break anything 732# sure we didn't break anything
703#TESTS() { 733#TESTS() {
704# CFLAGS="-a -b -c=1" 734# CFLAGS="-a -b -c=1"

Legend:
Removed from v.1.129  
changed lines
  Added in v.1.145

  ViewVC Help
Powered by ViewVC 1.1.20