Ahmad Sharif | bca7f1a | 2010-08-18 16:36:56 -0700 | [diff] [blame^] | 1 | # Copyright 1999-2008 Gentoo Foundation |
| 2 | # Distributed under the terms of the GNU General Public License v2 |
| 3 | # $Header: /var/cvsroot/gentoo-x86/eclass/toolchain.eclass,v 1.425 2010/04/25 18:04:48 armin76 Exp $ |
| 4 | # |
| 5 | # Maintainer: Toolchain Ninjas <toolchain@gentoo.org> |
| 6 | |
| 7 | HOMEPAGE="http://gcc.gnu.org/" |
| 8 | LICENSE="GPL-2 LGPL-2.1" |
| 9 | RESTRICT="strip" # cross-compilers need controlled stripping |
| 10 | |
| 11 | #---->> eclass stuff <<---- |
| 12 | inherit eutils versionator libtool toolchain-funcs flag-o-matic gnuconfig multilib fixheadtails |
| 13 | |
| 14 | EXPORT_FUNCTIONS pkg_setup src_unpack src_compile src_test pkg_preinst src_install pkg_postinst pkg_prerm pkg_postrm |
| 15 | DESCRIPTION="Based on the ${ECLASS} eclass" |
| 16 | |
| 17 | FEATURES=${FEATURES/multilib-strict/} |
| 18 | |
| 19 | toolchain_hardened_pkg_setup() { |
| 20 | gcc_pkg_setup |
| 21 | } |
| 22 | toolchain_hardened_src_unpack() { |
| 23 | gcc_src_unpack |
| 24 | } |
| 25 | toolchain_hardened_src_compile() { |
| 26 | gcc_src_compile |
| 27 | } |
| 28 | toolchain_hardened_src_test() { |
| 29 | gcc_src_test |
| 30 | } |
| 31 | toolchain_hardened_pkg_preinst() { |
| 32 | ${ETYPE}_pkg_preinst |
| 33 | } |
| 34 | toolchain_hardened_src_install() { |
| 35 | ${ETYPE}_src_install |
| 36 | } |
| 37 | toolchain_hardened_pkg_postinst() { |
| 38 | ${ETYPE}_pkg_postinst |
| 39 | } |
| 40 | toolchain_hardened_pkg_prerm() { |
| 41 | ${ETYPE}_pkg_prerm |
| 42 | } |
| 43 | toolchain_hardened_pkg_postrm() { |
| 44 | ${ETYPE}_pkg_postrm |
| 45 | } |
| 46 | #----<< eclass stuff >>---- |
| 47 | |
| 48 | |
| 49 | #---->> globals <<---- |
| 50 | export CTARGET=${CTARGET:-${CHOST}} |
| 51 | if [[ ${CTARGET} = ${CHOST} ]] ; then |
| 52 | if [[ ${CATEGORY/cross-} != ${CATEGORY} ]] ; then |
| 53 | export CTARGET=${CATEGORY/cross-} |
| 54 | fi |
| 55 | fi |
| 56 | is_crosscompile() { |
| 57 | [[ ${CHOST} != ${CTARGET} ]] |
| 58 | } |
| 59 | |
| 60 | tc_version_is_at_least() { version_is_at_least "$1" "${2:-${GCC_PV}}" ; } |
| 61 | |
| 62 | |
| 63 | GCC_PV=${TOOLCHAIN_GCC_PV:-${PV}} |
| 64 | GCC_PVR=${GCC_PV} |
| 65 | [[ ${PR} != "r0" ]] && GCC_PVR=${GCC_PVR}-${PR} |
| 66 | GCC_RELEASE_VER=$(get_version_component_range 1-3 ${GCC_PV}) |
| 67 | GCC_BRANCH_VER=$(get_version_component_range 1-2 ${GCC_PV}) |
| 68 | GCCMAJOR=$(get_version_component_range 1 ${GCC_PV}) |
| 69 | GCCMINOR=$(get_version_component_range 2 ${GCC_PV}) |
| 70 | GCCMICRO=$(get_version_component_range 3 ${GCC_PV}) |
| 71 | [[ ${BRANCH_UPDATE-notset} == "notset" ]] && BRANCH_UPDATE=$(get_version_component_range 4 ${GCC_PV}) |
| 72 | |
| 73 | # According to gcc/c-cppbuiltin.c, GCC_CONFIG_VER MUST match this regex. |
| 74 | # ([^0-9]*-)?[0-9]+[.][0-9]+([.][0-9]+)?([- ].*)? |
| 75 | GCC_CONFIG_VER=${GCC_CONFIG_VER:-$(replace_version_separator 3 '-' ${GCC_PV})} |
| 76 | |
| 77 | # Pre-release support |
| 78 | if [[ ${GCC_PV} != ${GCC_PV/_pre/-} ]] ; then |
| 79 | PRERELEASE=${GCC_PV/_pre/-} |
| 80 | fi |
| 81 | # make _alpha and _beta ebuilds automatically use a snapshot |
| 82 | if [[ ${GCC_PV} == *_alpha* ]] ; then |
| 83 | SNAPSHOT=${GCC_BRANCH_VER}-${GCC_PV##*_alpha} |
| 84 | elif [[ ${GCC_PV} == *_beta* ]] ; then |
| 85 | SNAPSHOT=${GCC_BRANCH_VER}-${GCC_PV##*_beta} |
| 86 | elif [[ ${GCC_PV} == *_rc* ]] ; then |
| 87 | SNAPSHOT=${GCC_PV%_rc*}-RC-${GCC_PV##*_rc} |
| 88 | fi |
| 89 | export GCC_FILESDIR=${GCC_FILESDIR:-${FILESDIR}} |
| 90 | |
| 91 | if [[ ${ETYPE} == "gcc-library" ]] ; then |
| 92 | GCC_VAR_TYPE=${GCC_VAR_TYPE:-non-versioned} |
| 93 | GCC_LIB_COMPAT_ONLY=${GCC_LIB_COMPAT_ONLY:-true} |
| 94 | GCC_TARGET_NO_MULTILIB=${GCC_TARGET_NO_MULTILIB:-true} |
| 95 | else |
| 96 | GCC_VAR_TYPE=${GCC_VAR_TYPE:-versioned} |
| 97 | GCC_LIB_COMPAT_ONLY="false" |
| 98 | GCC_TARGET_NO_MULTILIB=${GCC_TARGET_NO_MULTILIB:-false} |
| 99 | fi |
| 100 | |
| 101 | PREFIX=${TOOLCHAIN_PREFIX:-/usr} |
| 102 | |
| 103 | if [[ ${GCC_VAR_TYPE} == "versioned" ]] ; then |
| 104 | if tc_version_is_at_least 3.4.0 ; then |
| 105 | LIBPATH=${TOOLCHAIN_LIBPATH:-${PREFIX}/lib/gcc/${CTARGET}/${GCC_CONFIG_VER}} |
| 106 | else |
| 107 | LIBPATH=${TOOLCHAIN_LIBPATH:-${PREFIX}/lib/gcc-lib/${CTARGET}/${GCC_CONFIG_VER}} |
| 108 | fi |
| 109 | INCLUDEPATH=${TOOLCHAIN_INCLUDEPATH:-${LIBPATH}/include} |
| 110 | if is_crosscompile ; then |
| 111 | BINPATH=${TOOLCHAIN_BINPATH:-${PREFIX}/${CHOST}/${CTARGET}/gcc-bin/${GCC_CONFIG_VER}} |
| 112 | else |
| 113 | BINPATH=${TOOLCHAIN_BINPATH:-${PREFIX}/${CTARGET}/gcc-bin/${GCC_CONFIG_VER}} |
| 114 | fi |
| 115 | DATAPATH=${TOOLCHAIN_DATAPATH:-${PREFIX}/share/gcc-data/${CTARGET}/${GCC_CONFIG_VER}} |
| 116 | # Dont install in /usr/include/g++-v3/, but in gcc internal directory. |
| 117 | # We will handle /usr/include/g++-v3/ with gcc-config ... |
| 118 | STDCXX_INCDIR=${TOOLCHAIN_STDCXX_INCDIR:-${LIBPATH}/include/g++-v${GCC_BRANCH_VER/\.*/}} |
| 119 | elif [[ ${GCC_VAR_TYPE} == "non-versioned" ]] ; then |
| 120 | # using non-versioned directories to install gcc, like what is currently |
| 121 | # done for ppc64 and 3.3.3_pre, is a BAD IDEA. DO NOT do it!! However... |
| 122 | # setting up variables for non-versioned directories might be useful for |
| 123 | # specific gcc targets, like libffi. Note that we dont override the value |
| 124 | # returned by get_libdir here. |
| 125 | LIBPATH=${TOOLCHAIN_LIBPATH:-${PREFIX}/$(get_libdir)} |
| 126 | INCLUDEPATH=${TOOLCHAIN_INCLUDEPATH:-${PREFIX}/include} |
| 127 | BINPATH=${TOOLCHAIN_BINPATH:-${PREFIX}/bin} |
| 128 | DATAPATH=${TOOLCHAIN_DATAPATH:-${PREFIX}/share} |
| 129 | STDCXX_INCDIR=${TOOLCHAIN_STDCXX_INCDIR:-${PREFIX}/include/g++-v3} |
| 130 | fi |
| 131 | |
| 132 | #----<< globals >>---- |
| 133 | |
| 134 | |
| 135 | #---->> SLOT+IUSE logic <<---- |
| 136 | if [[ ${ETYPE} == "gcc-library" ]] ; then |
| 137 | IUSE="nls build test" |
| 138 | SLOT="${CTARGET}-${SO_VERSION_SLOT:-5}" |
| 139 | else |
| 140 | IUSE="multislot nptl test" |
| 141 | |
| 142 | if [[ ${PN} != "kgcc64" && ${PN} != gcc-* ]] ; then |
| 143 | IUSE="${IUSE} altivec build fortran nls nocxx" |
| 144 | [[ -n ${PIE_VER} ]] && IUSE="${IUSE} nopie" |
| 145 | [[ -n ${PP_VER} ]] && IUSE="${IUSE} nossp" |
| 146 | [[ -n ${SPECS_VER} ]] && IUSE="${IUSE} nossp" |
| 147 | [[ -n ${HTB_VER} ]] && IUSE="${IUSE} boundschecking" |
| 148 | [[ -n ${D_VER} ]] && IUSE="${IUSE} d" |
| 149 | |
| 150 | if tc_version_is_at_least 3 ; then |
| 151 | IUSE="${IUSE} bootstrap doc gcj gtk hardened libffi multilib objc vanilla" |
| 152 | |
| 153 | # gcc-{nios2,bfin} don't accept these |
| 154 | if [[ ${PN} == "gcc" ]] ; then |
| 155 | IUSE="${IUSE} n32 n64" |
| 156 | fi |
| 157 | |
| 158 | tc_version_is_at_least "4.0" && IUSE="${IUSE} objc-gc mudflap" |
| 159 | tc_version_is_at_least "4.1" && IUSE="${IUSE} objc++" |
| 160 | tc_version_is_at_least "4.2" && IUSE="${IUSE} openmp" |
| 161 | tc_version_is_at_least "4.3" && IUSE="${IUSE} fixed-point" |
| 162 | tc_version_is_at_least "4.4" && IUSE="${IUSE} graphite" |
| 163 | tc_version_is_at_least "4.5" && IUSE="${IUSE} lto" |
| 164 | fi |
| 165 | fi |
| 166 | |
| 167 | # Support upgrade paths here or people get pissed |
| 168 | if use multislot ; then |
| 169 | SLOT="${CTARGET}-${GCC_CONFIG_VER}" |
| 170 | elif is_crosscompile; then |
| 171 | SLOT="${CTARGET}-${GCC_BRANCH_VER}" |
| 172 | else |
| 173 | SLOT="${GCC_BRANCH_VER}" |
| 174 | fi |
| 175 | fi |
| 176 | #----<< SLOT+IUSE logic >>---- |
| 177 | |
| 178 | |
| 179 | #---->> S + SRC_URI essentials <<---- |
| 180 | |
| 181 | # This function sets the source directory depending on whether we're using |
| 182 | # a prerelease, snapshot, or release tarball. To use it, just set S with: |
| 183 | # |
| 184 | # S="$(gcc_get_s_dir)" |
| 185 | # |
| 186 | # Travis Tilley <lv@gentoo.org> (03 Sep 2004) |
| 187 | # |
| 188 | gcc_get_s_dir() { |
| 189 | local GCC_S |
| 190 | if [[ -n ${PRERELEASE} ]] ; then |
| 191 | GCC_S=${WORKDIR}/gcc-${PRERELEASE} |
| 192 | elif [[ -n ${SNAPSHOT} ]] ; then |
| 193 | GCC_S=${WORKDIR}/gcc-${SNAPSHOT} |
| 194 | else |
| 195 | GCC_S=${WORKDIR}/gcc-${GCC_RELEASE_VER} |
| 196 | fi |
| 197 | echo "${GCC_S}" |
| 198 | } |
| 199 | |
| 200 | # This function handles the basics of setting the SRC_URI for a gcc ebuild. |
| 201 | # To use, set SRC_URI with: |
| 202 | # |
| 203 | # SRC_URI="$(get_gcc_src_uri)" |
| 204 | # |
| 205 | # Other than the variables normally set by portage, this function's behavior |
| 206 | # can be altered by setting the following: |
| 207 | # |
| 208 | # SNAPSHOT |
| 209 | # If set, this variable signals that we should be using a snapshot |
| 210 | # of gcc from ftp://sources.redhat.com/pub/gcc/snapshots/. It is |
| 211 | # expected to be in the format "YYYY-MM-DD". Note that if the ebuild |
| 212 | # has a _pre suffix, this variable is ignored and the prerelease |
| 213 | # tarball is used instead. |
| 214 | # |
| 215 | # BRANCH_UPDATE |
| 216 | # If set, this variable signals that we should be using the main |
| 217 | # release tarball (determined by ebuild version) and applying a |
| 218 | # CVS branch update patch against it. The location of this branch |
| 219 | # update patch is assumed to be in ${GENTOO_TOOLCHAIN_BASE_URI}. |
| 220 | # Just like with SNAPSHOT, this variable is ignored if the ebuild |
| 221 | # has a _pre suffix. |
| 222 | # |
| 223 | # PATCH_VER |
| 224 | # PATCH_GCC_VER |
| 225 | # This should be set to the version of the gentoo patch tarball. |
| 226 | # The resulting filename of this tarball will be: |
| 227 | # gcc-${PATCH_GCC_VER:-${GCC_RELEASE_VER}}-patches-${PATCH_VER}.tar.bz2 |
| 228 | # |
| 229 | # PIE_VER |
| 230 | # PIE_GCC_VER |
| 231 | # obsoleted: PIE_CORE |
| 232 | # These variables control patching in various updates for the logic |
| 233 | # controlling Position Independant Executables. PIE_VER is expected |
| 234 | # to be the version of this patch, PIE_GCC_VER the gcc version of |
| 235 | # the patch, and PIE_CORE (obsoleted) the actual filename of the patch. |
| 236 | # An example: |
| 237 | # PIE_VER="8.7.6.5" |
| 238 | # PIE_GCC_VER="3.4.0" |
| 239 | # The resulting filename of this tarball will be: |
| 240 | # gcc-${PIE_GCC_VER:-${GCC_RELEASE_VER}}-piepatches-v${PIE_VER}.tar.bz2 |
| 241 | # old syntax (do not define PIE_CORE anymore): |
| 242 | # PIE_CORE="gcc-3.4.0-piepatches-v${PIE_VER}.tar.bz2" |
| 243 | # |
| 244 | # SPECS_VER |
| 245 | # SPECS_GCC_VER |
| 246 | # This is for the minispecs files included in the hardened gcc-4.x |
| 247 | # |
| 248 | # PP_VER |
| 249 | # PP_GCC_VER |
| 250 | # obsoleted: PP_FVER |
| 251 | # These variables control patching in stack smashing protection |
| 252 | # support. They both control the version of ProPolice to download. |
| 253 | # |
| 254 | # PP_VER / PP_GCC_VER |
| 255 | # Used to roll our own custom tarballs of ssp. |
| 256 | # PP_FVER / PP_VER |
| 257 | # Used for mirroring ssp straight from IBM. |
| 258 | # PP_VER sets the version of the directory in which to find the |
| 259 | # patch, and PP_FVER sets the version of the patch itself. For |
| 260 | # example: |
| 261 | # PP_VER="3_4" |
| 262 | # PP_FVER="${PP_VER//_/.}-2" |
| 263 | # would download gcc3_4/protector-3.4-2.tar.gz |
| 264 | # |
| 265 | # HTB_VER |
| 266 | # HTB_GCC_VER |
| 267 | # These variables control whether or not an ebuild supports Herman |
| 268 | # ten Brugge's bounds-checking patches. If you want to use a patch |
| 269 | # for an older gcc version with a new gcc, make sure you set |
| 270 | # HTB_GCC_VER to that version of gcc. |
| 271 | # |
| 272 | # MAN_VER |
| 273 | # The version of gcc for which we will download manpages. This will |
| 274 | # default to ${GCC_RELEASE_VER}, but we may not want to pre-generate man pages |
| 275 | # for prerelease test ebuilds for example. This allows you to |
| 276 | # continue using pre-generated manpages from the last stable release. |
| 277 | # If set to "none", this will prevent the downloading of manpages, |
| 278 | # which is useful for individual library targets. |
| 279 | # |
| 280 | gentoo_urls() { |
| 281 | local devspace="HTTP~lv/GCC/URI HTTP~eradicator/gcc/URI HTTP~vapier/dist/URI |
| 282 | HTTP~halcy0n/patches/URI HTTP~zorry/patches/gcc/URI" |
| 283 | devspace=${devspace//HTTP/http:\/\/dev.gentoo.org\/} |
| 284 | echo mirror://gentoo/$1 ${devspace//URI/$1} |
| 285 | } |
| 286 | get_gcc_src_uri() { |
| 287 | export PATCH_GCC_VER=${PATCH_GCC_VER:-${GCC_RELEASE_VER}} |
| 288 | export UCLIBC_GCC_VER=${UCLIBC_GCC_VER:-${PATCH_GCC_VER}} |
| 289 | export PIE_GCC_VER=${PIE_GCC_VER:-${GCC_RELEASE_VER}} |
| 290 | export PP_GCC_VER=${PP_GCC_VER:-${GCC_RELEASE_VER}} |
| 291 | export HTB_GCC_VER=${HTB_GCC_VER:-${GCC_RELEASE_VER}} |
| 292 | export SPECS_GCC_VER=${SPECS_GCC_VER:-${GCC_RELEASE_VER}} |
| 293 | |
| 294 | # Set where to download gcc itself depending on whether we're using a |
| 295 | # prerelease, snapshot, or release tarball. |
| 296 | if [[ -n ${PRERELEASE} ]] ; then |
| 297 | GCC_SRC_URI="ftp://gcc.gnu.org/pub/gcc/prerelease-${PRERELEASE}/gcc-${PRERELEASE}.tar.bz2" |
| 298 | elif [[ -n ${SNAPSHOT} ]] ; then |
| 299 | GCC_SRC_URI="ftp://sources.redhat.com/pub/gcc/snapshots/${SNAPSHOT}/gcc-${SNAPSHOT}.tar.bz2" |
| 300 | else |
| 301 | GCC_SRC_URI="mirror://gnu/gcc/gcc-${GCC_PV}/gcc-${GCC_RELEASE_VER}.tar.bz2" |
| 302 | # we want all branch updates to be against the main release |
| 303 | [[ -n ${BRANCH_UPDATE} ]] && \ |
| 304 | GCC_SRC_URI="${GCC_SRC_URI} $(gentoo_urls gcc-${GCC_RELEASE_VER}-branch-update-${BRANCH_UPDATE}.patch.bz2)" |
| 305 | fi |
| 306 | |
| 307 | # propolice aka stack smashing protection |
| 308 | if [[ -n ${PP_VER} ]] ; then |
| 309 | if [[ -n ${PP_FVER} ]] ; then |
| 310 | GCC_SRC_URI="${GCC_SRC_URI} |
| 311 | !nossp? ( |
| 312 | http://www.research.ibm.com/trl/projects/security/ssp/gcc${PP_VER}/protector-${PP_FVER}.tar.gz |
| 313 | $(gentoo_urls protector-${PP_FVER}.tar.gz) |
| 314 | )" |
| 315 | else |
| 316 | GCC_SRC_URI="${GCC_SRC_URI} $(gentoo_urls gcc-${PP_GCC_VER}-ssp-${PP_VER}.tar.bz2)" |
| 317 | fi |
| 318 | fi |
| 319 | |
| 320 | # uclibc lovin |
| 321 | [[ -n ${UCLIBC_VER} ]] && \ |
| 322 | GCC_SRC_URI="${GCC_SRC_URI} $(gentoo_urls gcc-${UCLIBC_GCC_VER}-uclibc-patches-${UCLIBC_VER}.tar.bz2)" |
| 323 | |
| 324 | # PERL cannot be present at bootstrap, and is used to build the man pages. |
| 325 | # So... lets include some pre-generated ones, shall we? |
| 326 | [[ -n ${MAN_VER} ]] && \ |
| 327 | GCC_SRC_URI="${GCC_SRC_URI} $(gentoo_urls gcc-${MAN_VER}-manpages.tar.bz2)" |
| 328 | |
| 329 | # various gentoo patches |
| 330 | [[ -n ${PATCH_VER} ]] && \ |
| 331 | GCC_SRC_URI="${GCC_SRC_URI} $(gentoo_urls gcc-${PATCH_GCC_VER}-patches-${PATCH_VER}.tar.bz2)" |
| 332 | |
| 333 | # strawberry pie, Cappuccino and a Gauloises (it's a good thing) |
| 334 | [[ -n ${PIE_VER} ]] && \ |
| 335 | PIE_CORE=${PIE_CORE:-gcc-${PIE_GCC_VER}-piepatches-v${PIE_VER}.tar.bz2} && \ |
| 336 | GCC_SRC_URI="${GCC_SRC_URI} $(gentoo_urls ${PIE_CORE})" |
| 337 | |
| 338 | # gcc minispec for the hardened gcc 4 compiler |
| 339 | [[ -n ${SPECS_VER} ]] && \ |
| 340 | GCC_SRC_URI="${GCC_SRC_URI} $(gentoo_urls gcc-${SPECS_GCC_VER}-specs-${SPECS_VER}.tar.bz2)" |
| 341 | |
| 342 | # gcc bounds checking patch |
| 343 | if [[ -n ${HTB_VER} ]] ; then |
| 344 | local HTBFILE="bounds-checking-gcc-${HTB_GCC_VER}-${HTB_VER}.patch.bz2" |
| 345 | GCC_SRC_URI="${GCC_SRC_URI} |
| 346 | boundschecking? ( |
| 347 | mirror://sourceforge/boundschecking/${HTBFILE} |
| 348 | $(gentoo_urls ${HTBFILE}) |
| 349 | )" |
| 350 | fi |
| 351 | |
| 352 | # support for the D language |
| 353 | [[ -n ${D_VER} ]] && \ |
| 354 | GCC_SRC_URI="${GCC_SRC_URI} d? ( mirror://sourceforge/dgcc/gdc-${D_VER}-src.tar.bz2 )" |
| 355 | |
| 356 | # >= gcc-4.3 uses ecj.jar and we only add gcj as a use flag under certain |
| 357 | # conditions |
| 358 | if [[ ${PN} != "kgcc64" && ${PN} != gcc-* ]] ; then |
| 359 | tc_version_is_at_least "4.3" && \ |
| 360 | GCC_SRC_URI="${GCC_SRC_URI} |
| 361 | gcj? ( ftp://sourceware.org/pub/java/ecj-4.3.jar )" |
| 362 | fi |
| 363 | |
| 364 | echo "${GCC_SRC_URI}" |
| 365 | } |
| 366 | S=$(gcc_get_s_dir) |
| 367 | SRC_URI=$(get_gcc_src_uri) |
| 368 | #---->> S + SRC_URI essentials >>---- |
| 369 | |
| 370 | |
| 371 | #---->> support checks <<---- |
| 372 | |
| 373 | # Grab a variable from the build system (taken from linux-info.eclass) |
| 374 | get_make_var() { |
| 375 | local var=$1 makefile=${2:-${WORKDIR}/build/Makefile} |
| 376 | echo -e "e:\\n\\t@echo \$(${var})\\ninclude ${makefile}" | \ |
| 377 | r=${makefile%/*} emake --no-print-directory -s -f - 2>/dev/null |
| 378 | } |
| 379 | XGCC() { get_make_var GCC_FOR_TARGET ; } |
| 380 | |
| 381 | # The gentoo piessp patches allow for 3 configurations: |
| 382 | # 1) PIE+SSP by default |
| 383 | # 2) PIE by default |
| 384 | # 3) SSP by default |
| 385 | hardened_gcc_works() { |
| 386 | if [[ $1 == "pie" ]] ; then |
| 387 | # $gcc_cv_ld_pie is unreliable as it simply take the output of |
| 388 | # `ld --help | grep -- -pie`, that reports the option in all cases, also if |
| 389 | # the loader doesn't actually load the resulting executables. |
| 390 | # To avoid breakage, blacklist FreeBSD here at least |
| 391 | [[ ${CTARGET} == *-freebsd* ]] && return 1 |
| 392 | |
| 393 | want_pie || return 1 |
| 394 | tc_version_is_at_least 4.3.2 && use nopie && return 1 |
| 395 | hardened_gcc_is_stable pie && return 0 |
| 396 | if has "~$(tc-arch)" ${ACCEPT_KEYWORDS} ; then |
| 397 | hardened_gcc_check_unsupported pie && return 1 |
| 398 | ewarn "Allowing pie-by-default for an unstable arch ($(tc-arch))" |
| 399 | return 0 |
| 400 | fi |
| 401 | return 1 |
| 402 | elif [[ $1 == "ssp" ]] ; then |
| 403 | want_ssp || return 1 |
| 404 | hardened_gcc_is_stable ssp && return 0 |
| 405 | if has "~$(tc-arch)" ${ACCEPT_KEYWORDS} ; then |
| 406 | hardened_gcc_check_unsupported ssp && return 1 |
| 407 | ewarn "Allowing ssp-by-default for an unstable arch ($(tc-arch))" |
| 408 | return 0 |
| 409 | fi |
| 410 | return 1 |
| 411 | else |
| 412 | # laziness ;) |
| 413 | hardened_gcc_works pie || return 1 |
| 414 | hardened_gcc_works ssp || return 1 |
| 415 | return 0 |
| 416 | fi |
| 417 | } |
| 418 | |
| 419 | hardened_gcc_is_stable() { |
| 420 | if [[ $1 == "pie" ]] ; then |
| 421 | # HARDENED_* variables are deprecated and here for compatibility |
| 422 | local tocheck="${HARDENED_PIE_WORKS} ${HARDENED_GCC_WORKS}" |
| 423 | if [[ ${CTARGET} == *-uclibc* ]] ; then |
| 424 | tocheck="${tocheck} ${PIE_UCLIBC_STABLE}" |
| 425 | else |
| 426 | tocheck="${tocheck} ${PIE_GLIBC_STABLE}" |
| 427 | fi |
| 428 | elif [[ $1 == "ssp" ]] ; then |
| 429 | # ditto |
| 430 | local tocheck="${HARDENED_SSP_WORKS} ${HARDENED_GCC_WORKS}" |
| 431 | if [[ ${CTARGET} == *-uclibc* ]] ; then |
| 432 | tocheck="${tocheck} ${SSP_UCLIBC_STABLE}" |
| 433 | else |
| 434 | tocheck="${tocheck} ${SSP_STABLE}" |
| 435 | fi |
| 436 | else |
| 437 | die "hardened_gcc_stable needs to be called with pie or ssp" |
| 438 | fi |
| 439 | |
| 440 | hasq $(tc-arch) ${tocheck} && return 0 |
| 441 | return 1 |
| 442 | } |
| 443 | |
| 444 | hardened_gcc_check_unsupported() { |
| 445 | local tocheck="" |
| 446 | # if a variable is unset, we assume that all archs are unsupported. since |
| 447 | # this function is never called if hardened_gcc_is_stable returns true, |
| 448 | # this shouldn't cause problems... however, allowing this logic to work |
| 449 | # even with the variables unset will break older ebuilds that dont use them. |
| 450 | if [[ $1 == "pie" ]] ; then |
| 451 | if [[ ${CTARGET} == *-uclibc* ]] ; then |
| 452 | [[ -z ${PIE_UCLIBC_UNSUPPORTED} ]] && return 0 |
| 453 | tocheck="${tocheck} ${PIE_UCLIBC_UNSUPPORTED}" |
| 454 | else |
| 455 | [[ -z ${PIE_GLIBC_UNSUPPORTED} ]] && return 0 |
| 456 | tocheck="${tocheck} ${PIE_GLIBC_UNSUPPORTED}" |
| 457 | fi |
| 458 | elif [[ $1 == "ssp" ]] ; then |
| 459 | if [[ ${CTARGET} == *-uclibc* ]] ; then |
| 460 | [[ -z ${SSP_UCLIBC_UNSUPPORTED} ]] && return 0 |
| 461 | tocheck="${tocheck} ${SSP_UCLIBC_UNSUPPORTED}" |
| 462 | else |
| 463 | [[ -z ${SSP_UNSUPPORTED} ]] && return 0 |
| 464 | tocheck="${tocheck} ${SSP_UNSUPPORTED}" |
| 465 | fi |
| 466 | else |
| 467 | die "hardened_gcc_check_unsupported needs to be called with pie or ssp" |
| 468 | fi |
| 469 | |
| 470 | hasq $(tc-arch) ${tocheck} && return 0 |
| 471 | return 1 |
| 472 | } |
| 473 | |
| 474 | has_libssp() { |
| 475 | [[ -e /$(get_libdir)/libssp.so ]] && return 0 |
| 476 | return 1 |
| 477 | } |
| 478 | |
| 479 | want_libssp() { |
| 480 | [[ ${GCC_LIBSSP_SUPPORT} == "true" ]] || return 1 |
| 481 | has_libssp || return 1 |
| 482 | [[ -n ${PP_VER} ]] || return 1 |
| 483 | return 0 |
| 484 | } |
| 485 | |
| 486 | _want_stuff() { |
| 487 | local var=$1 flag=$2 |
| 488 | [[ -z ${!var} ]] && return 1 |
| 489 | use ${flag} && return 0 |
| 490 | return 1 |
| 491 | } |
| 492 | want_boundschecking() { _want_stuff HTB_VER boundschecking ; } |
| 493 | want_pie() { |
| 494 | if tc_version_is_at_least 4.3.2 ; then |
| 495 | ! use hardened && use nopie && [[ -n ${PIE_VER} ]] && return 1 |
| 496 | [[ -n ${PIE_VER} ]] && [[ -n ${SPECS_VER} ]] && return 0 || return 1 |
| 497 | else |
| 498 | _want_stuff PIE_VER !nopie |
| 499 | fi |
| 500 | } |
| 501 | want_ssp() { |
| 502 | if tc_version_is_at_least 4.3.4 ; then |
| 503 | _want_stuff SPECS_VER !nossp |
| 504 | else |
| 505 | _want_stuff PP_VER !nossp |
| 506 | fi |
| 507 | } |
| 508 | |
| 509 | want_split_specs() { |
| 510 | [[ ${SPLIT_SPECS} == "true" ]] && want_pie |
| 511 | } |
| 512 | want_minispecs() { |
| 513 | if tc_version_is_at_least 4.3.2 && use hardened ; then |
| 514 | if ! want_pie ; then |
| 515 | ewarn "PIE_VER or SPECS_VER is not defiend in the GCC ebuild." |
| 516 | elif use vanilla ; then |
| 517 | ewarn "You will not get hardened features if you have the vanilla USE-flag." |
| 518 | elif use nopie && use nossp ; then |
| 519 | ewarn "You will not get hardened features if you have the nopie and nossp USE-flag." |
| 520 | elif ! hardened_gcc_works pie && ! hardened_gcc_works ssp && ! use nopie ; then |
| 521 | ewarn "Your $(tc-arch) arch is not supported." |
| 522 | else |
| 523 | return 0 |
| 524 | fi |
| 525 | ewarn "Hope you know what you are doing. Hardened will not work." |
| 526 | return 0 |
| 527 | fi |
| 528 | return 1 |
| 529 | } |
| 530 | # This function checks whether or not glibc has the support required to build |
| 531 | # Position Independant Executables with gcc. |
| 532 | glibc_have_pie() { |
| 533 | if [[ ! -f ${ROOT}/usr/$(get_libdir)/Scrt1.o ]] ; then |
| 534 | echo |
| 535 | ewarn "Your glibc does not have support for pie, the file Scrt1.o is missing" |
| 536 | ewarn "Please update your glibc to a proper version or disable hardened" |
| 537 | echo |
| 538 | return 1 |
| 539 | fi |
| 540 | } |
| 541 | |
| 542 | # This function determines whether or not libc has been patched with stack |
| 543 | # smashing protection support. |
| 544 | libc_has_ssp() { |
| 545 | [[ ${ROOT} != "/" ]] && return 0 |
| 546 | |
| 547 | # lib hacks taken from sandbox configure |
| 548 | echo 'int main(){}' > "${T}"/libctest.c |
| 549 | LC_ALL=C gcc "${T}"/libctest.c -lc -o libctest -Wl,-verbose &> "${T}"/libctest.log || return 1 |
| 550 | local libc_file=$(awk '/attempt to open/ { if (($4 ~ /\/libc\.so/) && ($5 == "succeeded")) LIBC = $4; }; END {print LIBC}' "${T}"/libctest.log) |
| 551 | |
| 552 | [[ -z ${libc_file} ]] && die "Unable to find a libc !?" |
| 553 | |
| 554 | # Check for gcc-4.x style ssp support |
| 555 | if [[ -n $(readelf -s "${libc_file}" 2>/dev/null | \ |
| 556 | grep 'FUNC.*GLOBAL.*__stack_chk_fail') ]] |
| 557 | then |
| 558 | return 0 |
| 559 | else |
| 560 | # Check for gcc-3.x style ssp support |
| 561 | if [[ -n $(readelf -s "${libc_file}" 2>/dev/null | \ |
| 562 | grep 'OBJECT.*GLOBAL.*__guard') ]] && \ |
| 563 | [[ -n $(readelf -s "${libc_file}" 2>/dev/null | \ |
| 564 | grep 'FUNC.*GLOBAL.*__stack_smash_handler') ]] |
| 565 | then |
| 566 | return 0 |
| 567 | elif is_crosscompile ; then |
| 568 | die "'${libc_file}' was detected w/out ssp, that sucks (a lot)" |
| 569 | else |
| 570 | return 1 |
| 571 | fi |
| 572 | fi |
| 573 | } |
| 574 | |
| 575 | # This is to make sure we don't accidentally try to enable support for a |
| 576 | # language that doesnt exist. GCC 3.4 supports f77, while 4.0 supports f95, etc. |
| 577 | # |
| 578 | # Also add a hook so special ebuilds (kgcc64) can control which languages |
| 579 | # exactly get enabled |
| 580 | gcc-lang-supported() { |
| 581 | grep ^language=\"${1}\" "${S}"/gcc/*/config-lang.in > /dev/null || return 1 |
| 582 | [[ -z ${TOOLCHAIN_ALLOWED_LANGS} ]] && return 0 |
| 583 | has $1 ${TOOLCHAIN_ALLOWED_LANGS} |
| 584 | } |
| 585 | |
| 586 | #----<< support checks >>---- |
| 587 | |
| 588 | #---->> specs + env.d logic <<---- |
| 589 | |
| 590 | # defaults to enable for all hardened toolchains |
| 591 | gcc_common_hard="-DEFAULT_RELRO -DEFAULT_BIND_NOW" |
| 592 | |
| 593 | # configure to build with the hardened GCC specs as the default |
| 594 | make_gcc_hard() { |
| 595 | if hardened_gcc_works ; then |
| 596 | einfo "Updating gcc to use automatic PIE + SSP building ..." |
| 597 | sed -e "s|^HARD_CFLAGS = |HARD_CFLAGS = -DEFAULT_PIE_SSP ${gcc_common_hard} |" \ |
| 598 | -i "${S}"/gcc/Makefile.in || die "Failed to update gcc!" |
| 599 | elif hardened_gcc_works pie ; then |
| 600 | einfo "Updating gcc to use automatic PIE building ..." |
| 601 | ewarn "SSP has not been enabled by default" |
| 602 | sed -e "s|^HARD_CFLAGS = |HARD_CFLAGS = -DEFAULT_PIE ${gcc_common_hard} |" \ |
| 603 | -i "${S}"/gcc/Makefile.in || die "Failed to update gcc!" |
| 604 | elif hardened_gcc_works ssp ; then |
| 605 | einfo "Updating gcc to use automatic SSP building ..." |
| 606 | ewarn "PIE has not been enabled by default" |
| 607 | sed -e "s|^HARD_CFLAGS = |HARD_CFLAGS = -DEFAULT_SSP ${gcc_common_hard} |" \ |
| 608 | -i "${S}"/gcc/Makefile.in || die "Failed to update gcc!" |
| 609 | else |
| 610 | # do nothing if hardened isnt supported, but dont die either |
| 611 | ewarn "hardened is not supported for this arch in this gcc version" |
| 612 | ebeep |
| 613 | return 0 |
| 614 | fi |
| 615 | |
| 616 | # rebrand to make bug reports easier |
| 617 | BRANDING_GCC_PKGVERSION=${BRANDING_GCC_PKGVERSION/Gentoo/Gentoo Hardened} |
| 618 | } |
| 619 | |
| 620 | # now we generate different spec files so that the user can select a compiler |
| 621 | # that enforces certain features in gcc itself and so we don't have to worry |
| 622 | # about a certain package ignoring CFLAGS/LDFLAGS |
| 623 | _create_specs_file() { |
| 624 | # Usage: _create_specs_file <USE flag> <specs name> <CFLAGS> |
| 625 | local uflag=$1 name=$2 flags=${*:3} |
| 626 | ebegin "Creating a ${name} gcc specs file" |
| 627 | pushd "${WORKDIR}"/build/gcc > /dev/null |
| 628 | if [[ -z ${uflag} ]] || use ${uflag} ; then |
| 629 | # backup the compiler first |
| 630 | cp Makefile Makefile.orig |
| 631 | sed -i -e '/^HARD_CFLAGS/s:=.*:='"${flags}"':' Makefile |
| 632 | mv xgcc xgcc.foo |
| 633 | mv gcc.o gcc.o.foo |
| 634 | emake -s xgcc |
| 635 | $(XGCC) -dumpspecs > "${WORKDIR}"/build/${name}.specs |
| 636 | # restore everything to normal |
| 637 | mv gcc.o.foo gcc.o |
| 638 | mv xgcc.foo xgcc |
| 639 | mv Makefile.orig Makefile |
| 640 | else |
| 641 | $(XGCC) -dumpspecs > "${WORKDIR}"/build/${name}.specs |
| 642 | fi |
| 643 | popd > /dev/null |
| 644 | eend $([[ -s ${WORKDIR}/build/${name}.specs ]] ; echo $?) |
| 645 | } |
| 646 | create_vanilla_specs_file() { _create_specs_file hardened vanilla ; } |
| 647 | create_hardened_specs_file() { _create_specs_file !hardened hardened ${gcc_common_hard} -DEFAULT_PIE_SSP ; } |
| 648 | create_hardenednossp_specs_file() { _create_specs_file "" hardenednossp ${gcc_common_hard} -DEFAULT_PIE ; } |
| 649 | create_hardenednopie_specs_file() { _create_specs_file "" hardenednopie ${gcc_common_hard} -DEFAULT_SSP ; } |
| 650 | create_hardenednopiessp_specs_file() { _create_specs_file "" hardenednopiessp ${gcc_common_hard} ; } |
| 651 | |
| 652 | split_out_specs_files() { |
| 653 | local s spec_list="hardenednopiessp vanilla" |
| 654 | if hardened_gcc_works ; then |
| 655 | spec_list="${spec_list} hardened hardenednossp hardenednopie" |
| 656 | elif hardened_gcc_works pie ; then |
| 657 | spec_list="${spec_list} hardenednossp" |
| 658 | elif hardened_gcc_works ssp ; then |
| 659 | spec_list="${spec_list} hardenednopie" |
| 660 | fi |
| 661 | for s in ${spec_list} ; do |
| 662 | create_${s}_specs_file || return 1 |
| 663 | done |
| 664 | } |
| 665 | |
| 666 | create_gcc_env_entry() { |
| 667 | dodir /etc/env.d/gcc |
| 668 | local gcc_envd_base="/etc/env.d/gcc/${CTARGET}-${GCC_CONFIG_VER}" |
| 669 | |
| 670 | if [[ -z $1 ]] ; then |
| 671 | gcc_envd_file="${D}${gcc_envd_base}" |
| 672 | # I'm leaving the following commented out to remind me that it |
| 673 | # was an insanely -bad- idea. Stuff broke. GCC_SPECS isnt unset |
| 674 | # on chroot or in non-toolchain.eclass gcc ebuilds! |
| 675 | #gcc_specs_file="${LIBPATH}/specs" |
| 676 | gcc_specs_file="" |
| 677 | else |
| 678 | gcc_envd_file="${D}${gcc_envd_base}-$1" |
| 679 | gcc_specs_file="${LIBPATH}/$1.specs" |
| 680 | fi |
| 681 | |
| 682 | # phase PATH/ROOTPATH out ... |
| 683 | echo "PATH=\"${BINPATH}\"" > ${gcc_envd_file} |
| 684 | echo "ROOTPATH=\"${BINPATH}\"" >> ${gcc_envd_file} |
| 685 | echo "GCC_PATH=\"${BINPATH}\"" >> ${gcc_envd_file} |
| 686 | |
| 687 | if use multilib && ! has_multilib_profile; then |
| 688 | LDPATH="${LIBPATH}" |
| 689 | for path in 32 64 ; do |
| 690 | [[ -d ${LIBPATH}/${path} ]] && LDPATH="${LDPATH}:${LIBPATH}/${path}" |
| 691 | done |
| 692 | else |
| 693 | local MULTIDIR |
| 694 | LDPATH="${LIBPATH}" |
| 695 | |
| 696 | # We want to list the default ABI's LIBPATH first so libtool |
| 697 | # searches that directory first. This is a temporary |
| 698 | # workaround for libtool being stupid and using .la's from |
| 699 | # conflicting ABIs by using the first one in the search path |
| 700 | |
| 701 | local abi=${DEFAULT_ABI} |
| 702 | local MULTIDIR=$($(XGCC) $(get_abi_CFLAGS ${abi}) --print-multi-directory) |
| 703 | if [[ ${MULTIDIR} == "." ]] ; then |
| 704 | LDPATH=${LIBPATH} |
| 705 | else |
| 706 | LDPATH=${LIBPATH}/${MULTIDIR} |
| 707 | fi |
| 708 | |
| 709 | for abi in $(get_all_abis) ; do |
| 710 | [[ ${abi} == ${DEFAULT_ABI} ]] && continue |
| 711 | |
| 712 | MULTIDIR=$($(XGCC) $(get_abi_CFLAGS ${abi}) --print-multi-directory) |
| 713 | if [[ ${MULTIDIR} == "." ]] ; then |
| 714 | LDPATH=${LDPATH}:${LIBPATH} |
| 715 | else |
| 716 | LDPATH=${LDPATH}:${LIBPATH}/${MULTIDIR} |
| 717 | fi |
| 718 | done |
| 719 | fi |
| 720 | |
| 721 | echo "LDPATH=\"${LDPATH}\"" >> ${gcc_envd_file} |
| 722 | echo "MANPATH=\"${DATAPATH}/man\"" >> ${gcc_envd_file} |
| 723 | echo "INFOPATH=\"${DATAPATH}/info\"" >> ${gcc_envd_file} |
| 724 | echo "STDCXX_INCDIR=\"${STDCXX_INCDIR##*/}\"" >> ${gcc_envd_file} |
| 725 | |
| 726 | is_crosscompile && echo "CTARGET=${CTARGET}" >> ${gcc_envd_file} |
| 727 | |
| 728 | # Set which specs file to use |
| 729 | [[ -n ${gcc_specs_file} ]] && echo "GCC_SPECS=\"${gcc_specs_file}\"" >> ${gcc_envd_file} |
| 730 | } |
| 731 | setup_minispecs_gcc_build_specs() { |
| 732 | # Setup the "build.specs" file for gcc to use when building. |
| 733 | if want_minispecs && ! tc_version_is_at_least 4.4.3 ; then |
| 734 | if hardened_gcc_works pie ; then |
| 735 | cat "${WORKDIR}"/specs/pie.specs >> "${WORKDIR}"/build.specs |
| 736 | fi |
| 737 | if hardened_gcc_works ssp ; then |
| 738 | for s in ssp sspall ; do |
| 739 | cat "${WORKDIR}"/specs/${s}.specs >> "${WORKDIR}"/build.specs |
| 740 | done |
| 741 | fi |
| 742 | for s in nostrict znow ; do |
| 743 | cat "${WORKDIR}"/specs/${s}.specs >> "${WORKDIR}"/build.specs |
| 744 | done |
| 745 | export GCC_SPECS="${WORKDIR}"/build.specs |
| 746 | fi |
| 747 | } |
| 748 | copy_minispecs_gcc_specs() { |
| 749 | # Build system specs file which, if it exists, must be a complete set of |
| 750 | # specs as it completely and unconditionally overrides the builtin specs. |
| 751 | # For gcc 4 |
| 752 | if want_minispecs ; then |
| 753 | insinto ${LIBPATH} |
| 754 | if ! tc_version_is_at_least 4.4.3 ; then |
| 755 | $(XGCC) -dumpspecs > "${WORKDIR}"/specs/specs |
| 756 | cat "${WORKDIR}"/build.specs >> "${WORKDIR}"/specs/specs |
| 757 | doins "${WORKDIR}"/specs/specs || die "failed to install specs" |
| 758 | fi |
| 759 | doins "${WORKDIR}"/specs/*.specs || die "failed to install specs" |
| 760 | fi |
| 761 | } |
| 762 | add_profile_eselect_conf() { |
| 763 | local compiler_config_file=$1 |
| 764 | local abi=$2 |
| 765 | local specs=$3 |
| 766 | local gcc_specs_file |
| 767 | local var |
| 768 | |
| 769 | if [[ -z ${specs} ]] ; then |
| 770 | # I'm leaving the following commented out to remind me that it |
| 771 | # was an insanely -bad- idea. Stuff broke. GCC_SPECS isnt unset |
| 772 | # on chroot or in non-toolchain.eclass gcc ebuilds! |
| 773 | #gcc_specs_file="${LIBPATH}/specs" |
| 774 | gcc_specs_file="" |
| 775 | |
| 776 | if use hardened ; then |
| 777 | specs="hardened" |
| 778 | else |
| 779 | specs="vanilla" |
| 780 | fi |
| 781 | else |
| 782 | gcc_specs_file="${LIBPATH}/${specs}.specs" |
| 783 | fi |
| 784 | |
| 785 | echo >> ${compiler_config_file} |
| 786 | if ! is_multilib ; then |
| 787 | echo "[${specs}]" >> ${compiler_config_file} |
| 788 | echo " ctarget=${CTARGET}" >> ${compiler_config_file} |
| 789 | else |
| 790 | echo "[${abi}-${specs}]" >> ${compiler_config_file} |
| 791 | var="CTARGET_${abi}" |
| 792 | if [[ -n ${!var} ]] ; then |
| 793 | echo " ctarget=${!var}" >> ${compiler_config_file} |
| 794 | else |
| 795 | var="CHOST_${abi}" |
| 796 | if [[ -n ${!var} ]] ; then |
| 797 | echo " ctarget=${!var}" >> ${compiler_config_file} |
| 798 | else |
| 799 | echo " ctarget=${CTARGET}" >> ${compiler_config_file} |
| 800 | fi |
| 801 | fi |
| 802 | fi |
| 803 | |
| 804 | local MULTIDIR=$($(XGCC) $(get_abi_CFLAGS ${abi}) --print-multi-directory) |
| 805 | local LDPATH=${LIBPATH} |
| 806 | if [[ ${MULTIDIR} != "." ]] ; then |
| 807 | LDPATH="${LIBPATH}/${MULTIDIR}" |
| 808 | fi |
| 809 | |
| 810 | echo " ldpath=${LDPATH}" >> ${compiler_config_file} |
| 811 | |
| 812 | if [[ -n ${gcc_specs_file} ]] ; then |
| 813 | echo " specs=${gcc_specs_file}" >> ${compiler_config_file} |
| 814 | fi |
| 815 | |
| 816 | var="CFLAGS_${abi}" |
| 817 | if [[ -n ${!var} ]] ; then |
| 818 | echo " cflags=${!var}" >> ${compiler_config_file} |
| 819 | fi |
| 820 | } |
| 821 | |
| 822 | create_eselect_conf() { |
| 823 | local config_dir="/etc/eselect/compiler" |
| 824 | local compiler_config_file="${D}/${config_dir}/${CTARGET}-${GCC_CONFIG_VER}.conf" |
| 825 | local abi |
| 826 | |
| 827 | dodir ${config_dir} |
| 828 | |
| 829 | echo "[global]" > ${compiler_config_file} |
| 830 | echo " version=${CTARGET}-${GCC_CONFIG_VER}" >> ${compiler_config_file} |
| 831 | echo " binpath=${BINPATH}" >> ${compiler_config_file} |
| 832 | echo " manpath=${DATAPATH}/man" >> ${compiler_config_file} |
| 833 | echo " infopath=${DATAPATH}/info" >> ${compiler_config_file} |
| 834 | echo " alias_cc=gcc" >> ${compiler_config_file} |
| 835 | echo " stdcxx_incdir=${STDCXX_INCDIR##*/}" >> ${compiler_config_file} |
| 836 | echo " bin_prefix=${CTARGET}" >> ${compiler_config_file} |
| 837 | |
| 838 | # Per spyderous, it is best not to alias the fortran compilers |
| 839 | #if [[ -x "${D}/${BINPATH}/${CTARGET}-g77" ]] ; then |
| 840 | # echo " alias_gfortran=g77" >> ${compiler_config_file} |
| 841 | #elif [[ -x "${D}/${BINPATH}/${CTARGET}-gfortran" ]] ; then |
| 842 | # echo " alias_g77=gfortran" >> ${compiler_config_file} |
| 843 | #fi |
| 844 | |
| 845 | for abi in $(get_all_abis) ; do |
| 846 | add_profile_eselect_conf "${compiler_config_file}" "${abi}" |
| 847 | |
| 848 | if want_split_specs ; then |
| 849 | if use hardened ; then |
| 850 | add_profile_eselect_conf "${compiler_config_file}" "${abi}" vanilla |
| 851 | elif hardened_gcc_works ; then |
| 852 | add_profile_eselect_conf "${compiler_config_file}" "${abi}" hardened |
| 853 | fi |
| 854 | |
| 855 | if hardened_gcc_works || hardened_gcc_works pie ; then |
| 856 | add_profile_eselect_conf "${compiler_config_file}" "${abi}" hardenednossp |
| 857 | fi |
| 858 | |
| 859 | if hardened_gcc_works || hardened_gcc_works ssp ; then |
| 860 | add_profile_eselect_conf "${compiler_config_file}" "${abi}" hardenednopie |
| 861 | fi |
| 862 | |
| 863 | add_profile_eselect_conf "${compiler_config_file}" "${abi}" hardenednopiessp |
| 864 | fi |
| 865 | done |
| 866 | } |
| 867 | |
| 868 | #----<< specs + env.d logic >>---- |
| 869 | |
| 870 | #---->> pkg_* <<---- |
| 871 | gcc_pkg_setup() { |
| 872 | [[ -z ${ETYPE} ]] && die "Your ebuild needs to set the ETYPE variable" |
| 873 | |
| 874 | if [[ ( $(tc-arch) == "amd64" || $(tc-arch) == "ppc64" ) && ( ${LD_PRELOAD} == "/lib/libsandbox.so" || ${LD_PRELOAD} == "/usr/lib/libsandbox.so" ) ]] && is_multilib ; then |
| 875 | eerror "Sandbox in your installed portage does not support compilation." |
| 876 | eerror "of a multilib gcc. Please set FEATURES=-sandbox and try again." |
| 877 | eerror "After you have a multilib gcc, re-emerge portage to have a working sandbox." |
| 878 | die "No 32bit sandbox. Retry with FEATURES=-sandbox." |
| 879 | fi |
| 880 | |
| 881 | if [[ ${ETYPE} == "gcc-compiler" ]] ; then |
| 882 | case $(tc-arch) in |
| 883 | mips) |
| 884 | # Must compile for mips64-linux target if we want n32/n64 support |
| 885 | case "${CTARGET}" in |
| 886 | mips64*) ;; |
| 887 | *) |
| 888 | if use n32 || use n64; then |
| 889 | eerror "n32/n64 can only be used when target host is mips64*-*-linux-*"; |
| 890 | die "Invalid USE flags for CTARGET ($CTARGET)"; |
| 891 | fi |
| 892 | ;; |
| 893 | esac |
| 894 | |
| 895 | #cannot have both n32 & n64 without multilib |
| 896 | if use n32 && use n64 && ! is_multilib; then |
| 897 | eerror "Please enable multilib if you want to use both n32 & n64"; |
| 898 | die "Invalid USE flag combination"; |
| 899 | fi |
| 900 | ;; |
| 901 | esac |
| 902 | |
| 903 | # Setup variables which would normally be in the profile |
| 904 | if is_crosscompile ; then |
| 905 | multilib_env ${CTARGET} |
| 906 | if ! use multilib ; then |
| 907 | MULTILIB_ABIS=${DEFAULT_ABI} |
| 908 | fi |
| 909 | fi |
| 910 | |
| 911 | # we dont want to use the installed compiler's specs to build gcc! |
| 912 | unset GCC_SPECS |
| 913 | fi |
| 914 | |
| 915 | want_libssp && libc_has_ssp && \ |
| 916 | die "libssp cannot be used with a glibc that has been patched to provide ssp symbols" |
| 917 | want_minispecs |
| 918 | |
| 919 | unset LANGUAGES #265283 |
| 920 | } |
| 921 | |
| 922 | gcc-compiler_pkg_preinst() { |
| 923 | : |
| 924 | } |
| 925 | |
| 926 | gcc-compiler_pkg_postinst() { |
| 927 | if has_version 'app-admin/eselect-compiler' ; then |
| 928 | do_eselect_compiler |
| 929 | else |
| 930 | do_gcc_config |
| 931 | fi |
| 932 | |
| 933 | if ! is_crosscompile ; then |
| 934 | echo |
| 935 | ewarn "If you have issues with packages unable to locate libstdc++.la," |
| 936 | ewarn "then try running 'fix_libtool_files.sh' on the old gcc versions." |
| 937 | echo |
| 938 | fi |
| 939 | |
| 940 | # If our gcc-config version doesn't like '-' in it's version string, |
| 941 | # tell our users that gcc-config will yell at them, but it's all good. |
| 942 | if ! has_version '>=sys-devel/gcc-config-1.3.10-r1' && [[ ${GCC_CONFIG_VER/-/} != ${GCC_CONFIG_VER} ]] ; then |
| 943 | ewarn "Your version of gcc-config will issue about having an invalid profile" |
| 944 | ewarn "when switching to this profile. It is safe to ignore this warning," |
| 945 | ewarn "and this problem has been corrected in >=sys-devel/gcc-config-1.3.10-r1." |
| 946 | fi |
| 947 | |
| 948 | if ! is_crosscompile && ! use multislot && [[ ${GCCMAJOR}.${GCCMINOR} == 3.4 ]] ; then |
| 949 | echo |
| 950 | ewarn "You should make sure to rebuild all your C++ packages when" |
| 951 | ewarn "upgrading between different versions of gcc. For example," |
| 952 | ewarn "when moving to gcc-3.4 from gcc-3.3, emerge gentoolkit and run:" |
| 953 | ewarn " # revdep-rebuild --library libstdc++.so.5" |
| 954 | echo |
| 955 | ewarn "For more information on the steps to take when upgrading " |
| 956 | ewarn "from gcc-3.3 please refer to: " |
| 957 | ewarn "http://www.gentoo.org/doc/en/gcc-upgrading.xml" |
| 958 | echo |
| 959 | fi |
| 960 | |
| 961 | if ! is_crosscompile ; then |
| 962 | # hack to prevent collisions between SLOT |
| 963 | [[ ! -d ${ROOT}/lib/rcscripts/awk ]] \ |
| 964 | && mkdir -p "${ROOT}"/lib/rcscripts/awk |
| 965 | [[ ! -d ${ROOT}/sbin ]] \ |
| 966 | && mkdir -p "${ROOT}"/sbin |
| 967 | cp "${ROOT}/${DATAPATH}"/fixlafiles.awk "${ROOT}"/lib/rcscripts/awk/ || die "installing fixlafiles.awk" |
| 968 | cp "${ROOT}/${DATAPATH}"/fix_libtool_files.sh "${ROOT}"/sbin/ || die "installing fix_libtool_files.sh" |
| 969 | |
| 970 | [[ ! -d ${ROOT}/usr/bin ]] \ |
| 971 | && mkdir -p "${ROOT}"/usr/bin |
| 972 | # Since these aren't critical files and portage sucks with |
| 973 | # handling of binpkgs, don't require these to be found |
| 974 | for x in "${ROOT}/${DATAPATH}"/c{89,99} ; do |
| 975 | if [[ -e ${x} ]]; then |
| 976 | cp ${x} "${ROOT}"/usr/bin/ || die "installing c89/c99" |
| 977 | fi |
| 978 | done |
| 979 | fi |
| 980 | } |
| 981 | |
| 982 | gcc-compiler_pkg_prerm() { |
| 983 | # Don't let these files be uninstalled #87647 |
| 984 | touch -c "${ROOT}"/sbin/fix_libtool_files.sh \ |
| 985 | "${ROOT}"/lib/rcscripts/awk/fixlafiles.awk |
| 986 | } |
| 987 | |
| 988 | gcc-compiler_pkg_postrm() { |
| 989 | # to make our lives easier (and saner), we do the fix_libtool stuff here. |
| 990 | # rather than checking SLOT's and trying in upgrade paths, we just see if |
| 991 | # the common libstdc++.la exists in the ${LIBPATH} of the gcc that we are |
| 992 | # unmerging. if it does, that means this was a simple re-emerge. |
| 993 | |
| 994 | # clean up the cruft left behind by cross-compilers |
| 995 | if is_crosscompile ; then |
| 996 | if [[ -z $(ls "${ROOT}"/etc/env.d/gcc/${CTARGET}* 2>/dev/null) ]] ; then |
| 997 | rm -f "${ROOT}"/etc/env.d/gcc/config-${CTARGET} |
| 998 | rm -f "${ROOT}"/etc/env.d/??gcc-${CTARGET} |
| 999 | rm -f "${ROOT}"/usr/bin/${CTARGET}-{gcc,{g,c}++}{,32,64} |
| 1000 | fi |
| 1001 | return 0 |
| 1002 | fi |
| 1003 | |
| 1004 | # ROOT isnt handled by the script |
| 1005 | [[ ${ROOT} != "/" ]] && return 0 |
| 1006 | |
| 1007 | if [[ ! -e ${LIBPATH}/libstdc++.so ]] ; then |
| 1008 | # make sure the profile is sane during same-slot upgrade #289403 |
| 1009 | do_gcc_config |
| 1010 | |
| 1011 | einfo "Running 'fix_libtool_files.sh ${GCC_RELEASE_VER}'" |
| 1012 | /sbin/fix_libtool_files.sh ${GCC_RELEASE_VER} |
| 1013 | if [[ -n ${BRANCH_UPDATE} ]] ; then |
| 1014 | einfo "Running 'fix_libtool_files.sh ${GCC_RELEASE_VER}-${BRANCH_UPDATE}'" |
| 1015 | /sbin/fix_libtool_files.sh ${GCC_RELEASE_VER}-${BRANCH_UPDATE} |
| 1016 | fi |
| 1017 | fi |
| 1018 | |
| 1019 | return 0 |
| 1020 | } |
| 1021 | |
| 1022 | #---->> pkg_* <<---- |
| 1023 | |
| 1024 | #---->> src_* <<---- |
| 1025 | |
| 1026 | # generic GCC src_unpack, to be called from the ebuild's src_unpack. |
| 1027 | # BIG NOTE regarding hardened support: ebuilds with support for hardened are |
| 1028 | # expected to export the following variable: |
| 1029 | # |
| 1030 | # HARDENED_GCC_WORKS |
| 1031 | # This variable should be set to the archs on which hardened should |
| 1032 | # be allowed. For example: HARDENED_GCC_WORKS="x86 sparc amd64" |
| 1033 | # This allows for additional archs to be supported by hardened when |
| 1034 | # ready. |
| 1035 | # |
| 1036 | # Travis Tilley <lv@gentoo.org> (03 Sep 2004) |
| 1037 | # |
| 1038 | gcc-compiler_src_unpack() { |
| 1039 | # fail if using pie patches, building hardened, and glibc doesnt have |
| 1040 | # the necessary support |
| 1041 | want_pie && use hardened && glibc_have_pie |
| 1042 | |
| 1043 | if use hardened && ! want_minispecs ; then |
| 1044 | einfo "updating configuration to build hardened GCC" |
| 1045 | make_gcc_hard || die "failed to make gcc hard" |
| 1046 | fi |
| 1047 | |
| 1048 | # Rebrand to make bug reports easier |
| 1049 | want_minispecs && BRANDING_GCC_PKGVERSION=${BRANDING_GCC_PKGVERSION/Gentoo/Gentoo Hardened} |
| 1050 | |
| 1051 | if is_libffi ; then |
| 1052 | # move the libffi target out of gcj and into all |
| 1053 | sed -i \ |
| 1054 | -e '/^libgcj=/s:target-libffi::' \ |
| 1055 | -e '/^target_lib/s:=":="target-libffi :' \ |
| 1056 | "${S}"/configure || die |
| 1057 | fi |
| 1058 | } |
| 1059 | gcc-library_src_unpack() { |
| 1060 | : |
| 1061 | } |
| 1062 | guess_patch_type_in_dir() { |
| 1063 | [[ -n $(ls "$1"/*.bz2 2>/dev/null) ]] \ |
| 1064 | && EPATCH_SUFFIX="patch.bz2" \ |
| 1065 | || EPATCH_SUFFIX="patch" |
| 1066 | } |
| 1067 | do_gcc_rename_java_bins() { |
| 1068 | # bug #139918 - conflict between gcc and java-config-2 for ownership of |
| 1069 | # /usr/bin/rmi{c,registry}. Done with mv & sed rather than a patch |
| 1070 | # because patches would be large (thanks to the rename of man files), |
| 1071 | # and it's clear from the sed invocations that all that changes is the |
| 1072 | # rmi{c,registry} names to grmi{c,registry} names. |
| 1073 | # Kevin F. Quinn 2006-07-12 |
| 1074 | einfo "Renaming jdk executables rmic and rmiregistry to grmic and grmiregistry." |
| 1075 | # 1) Move the man files if present (missing prior to gcc-3.4) |
| 1076 | for manfile in rmic rmiregistry; do |
| 1077 | [[ -f ${S}/gcc/doc/${manfile}.1 ]] || continue |
| 1078 | mv "${S}"/gcc/doc/${manfile}.1 "${S}"/gcc/doc/g${manfile}.1 |
| 1079 | done |
| 1080 | # 2) Fixup references in the docs if present (mission prior to gcc-3.4) |
| 1081 | for jfile in gcc/doc/gcj.info gcc/doc/grmic.1 gcc/doc/grmiregistry.1 gcc/java/gcj.texi; do |
| 1082 | [[ -f ${S}/${jfile} ]] || continue |
| 1083 | sed -i -e 's:rmiregistry:grmiregistry:g' "${S}"/${jfile} || |
| 1084 | die "Failed to fixup file ${jfile} for rename to grmiregistry" |
| 1085 | sed -i -e 's:rmic:grmic:g' "${S}"/${jfile} || |
| 1086 | die "Failed to fixup file ${jfile} for rename to grmic" |
| 1087 | done |
| 1088 | # 3) Fixup Makefiles to build the changed executable names |
| 1089 | # These are present in all 3.x versions, and are the important bit |
| 1090 | # to get gcc to build with the new names. |
| 1091 | for jfile in libjava/Makefile.am libjava/Makefile.in gcc/java/Make-lang.in; do |
| 1092 | sed -i -e 's:rmiregistry:grmiregistry:g' "${S}"/${jfile} || |
| 1093 | die "Failed to fixup file ${jfile} for rename to grmiregistry" |
| 1094 | # Careful with rmic on these files; it's also the name of a directory |
| 1095 | # which should be left unchanged. Replace occurrences of 'rmic$', |
| 1096 | # 'rmic_' and 'rmic '. |
| 1097 | sed -i -e 's:rmic\([$_ ]\):grmic\1:g' "${S}"/${jfile} || |
| 1098 | die "Failed to fixup file ${jfile} for rename to grmic" |
| 1099 | done |
| 1100 | } |
| 1101 | gcc_src_unpack() { |
| 1102 | export BRANDING_GCC_PKGVERSION="Gentoo ${GCC_PVR}" |
| 1103 | |
| 1104 | [[ -z ${UCLIBC_VER} ]] && [[ ${CTARGET} == *-uclibc* ]] && die "Sorry, this version does not support uClibc" |
| 1105 | |
| 1106 | gcc_quick_unpack |
| 1107 | exclude_gcc_patches |
| 1108 | |
| 1109 | cd "${S}" |
| 1110 | |
| 1111 | if ! use vanilla ; then |
| 1112 | if [[ -n ${PATCH_VER} ]] ; then |
| 1113 | guess_patch_type_in_dir "${WORKDIR}"/patch |
| 1114 | EPATCH_MULTI_MSG="Applying Gentoo patches ..." \ |
| 1115 | epatch "${WORKDIR}"/patch |
| 1116 | BRANDING_GCC_PKGVERSION="${BRANDING_GCC_PKGVERSION} p${PATCH_VER}" |
| 1117 | fi |
| 1118 | if [[ -n ${UCLIBC_VER} ]] ; then |
| 1119 | guess_patch_type_in_dir "${WORKDIR}"/uclibc |
| 1120 | EPATCH_MULTI_MSG="Applying uClibc patches ..." \ |
| 1121 | epatch "${WORKDIR}"/uclibc |
| 1122 | fi |
| 1123 | fi |
| 1124 | do_gcc_HTB_patches |
| 1125 | do_gcc_SSP_patches |
| 1126 | do_gcc_PIE_patches |
| 1127 | epatch_user |
| 1128 | |
| 1129 | ${ETYPE}_src_unpack || die "failed to ${ETYPE}_src_unpack" |
| 1130 | |
| 1131 | # protoize don't build on FreeBSD, skip it |
| 1132 | ## removed in 4.5, bug #270558 --de. |
| 1133 | if [[ ${GCCMAJOR}.${GCCMINOR} < 4.5 ]]; then |
| 1134 | if ! is_crosscompile && ! use elibc_FreeBSD ; then |
| 1135 | # enable protoize / unprotoize |
| 1136 | sed -i -e '/^LANGUAGES =/s:$: proto:' "${S}"/gcc/Makefile.in |
| 1137 | fi |
| 1138 | fi |
| 1139 | |
| 1140 | fix_files="" |
| 1141 | for x in contrib/test_summary libstdc++-v3/scripts/check_survey.in ; do |
| 1142 | [[ -e ${x} ]] && fix_files="${fix_files} ${x}" |
| 1143 | done |
| 1144 | ht_fix_file ${fix_files} */configure *.sh */Makefile.in |
| 1145 | |
| 1146 | if ! is_crosscompile && is_multilib && \ |
| 1147 | [[ ( $(tc-arch) == "amd64" || $(tc-arch) == "ppc64" ) && -z ${SKIP_MULTILIB_HACK} ]] ; then |
| 1148 | disgusting_gcc_multilib_HACK || die "multilib hack failed" |
| 1149 | fi |
| 1150 | |
| 1151 | gcc_version_patch |
| 1152 | if [[ ${GCCMAJOR}.${GCCMINOR} > 4.0 ]] ; then |
| 1153 | if [[ -n ${SNAPSHOT} || -n ${PRERELEASE} ]] ; then |
| 1154 | echo ${PV/_/-} > "${S}"/gcc/BASE-VER |
| 1155 | fi |
| 1156 | fi |
| 1157 | |
| 1158 | # >= gcc-4.3 doesn't bundle ecj.jar, so copy it |
| 1159 | if [[ ${GCCMAJOR}.${GCCMINOR} > 4.2 ]] && |
| 1160 | use gcj ; then |
| 1161 | cp -pPR "${DISTDIR}/ecj-4.3.jar" "${S}/ecj.jar" || die |
| 1162 | fi |
| 1163 | |
| 1164 | # disable --as-needed from being compiled into gcc specs |
| 1165 | # natively when using a gcc version < 3.4.4 |
| 1166 | # http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14992 |
| 1167 | if ! tc_version_is_at_least 3.4.4 ; then |
| 1168 | sed -i -e s/HAVE_LD_AS_NEEDED/USE_LD_AS_NEEDED/g "${S}"/gcc/config.in |
| 1169 | fi |
| 1170 | |
| 1171 | # In gcc 3.3.x and 3.4.x, rename the java bins to gcc-specific names |
| 1172 | # in line with gcc-4. |
| 1173 | if [[ ${GCCMAJOR} == 3 ]] && |
| 1174 | [[ ${GCCMINOR} -ge 3 ]] |
| 1175 | then |
| 1176 | do_gcc_rename_java_bins |
| 1177 | fi |
| 1178 | |
| 1179 | # Fixup libtool to correctly generate .la files with portage |
| 1180 | cd "${S}" |
| 1181 | elibtoolize --portage --shallow --no-uclibc |
| 1182 | |
| 1183 | gnuconfig_update |
| 1184 | |
| 1185 | # update configure files |
| 1186 | local f |
| 1187 | einfo "Fixing misc issues in configure files" |
| 1188 | tc_version_is_at_least 4.1 && epatch "${GCC_FILESDIR}"/gcc-configure-texinfo.patch |
| 1189 | for f in $(grep -l 'autoconf version 2.13' $(find "${S}" -name configure)) ; do |
| 1190 | ebegin " Updating ${f/${S}\/} [LANG]" |
| 1191 | patch "${f}" "${GCC_FILESDIR}"/gcc-configure-LANG.patch >& "${T}"/configure-patch.log \ |
| 1192 | || eerror "Please file a bug about this" |
| 1193 | eend $? |
| 1194 | done |
| 1195 | sed -i 's|A-Za-z0-9|[:alnum:]|g' "${S}"/gcc/*.awk #215828 |
| 1196 | |
| 1197 | if [[ -x contrib/gcc_update ]] ; then |
| 1198 | einfo "Touching generated files" |
| 1199 | ./contrib/gcc_update --touch | \ |
| 1200 | while read f ; do |
| 1201 | einfo " ${f%%...}" |
| 1202 | done |
| 1203 | fi |
| 1204 | |
| 1205 | disable_multilib_libjava || die "failed to disable multilib java" |
| 1206 | } |
| 1207 | |
| 1208 | gcc-library-configure() { |
| 1209 | # multilib support |
| 1210 | [[ ${GCC_TARGET_NO_MULTILIB} == "true" ]] \ |
| 1211 | && confgcc="${confgcc} --disable-multilib" \ |
| 1212 | || confgcc="${confgcc} --enable-multilib" |
| 1213 | } |
| 1214 | |
| 1215 | gcc-compiler-configure() { |
| 1216 | # multilib support |
| 1217 | if is_multilib ; then |
| 1218 | confgcc="${confgcc} --enable-multilib" |
| 1219 | elif [[ ${CTARGET} == *-linux* ]] ; then |
| 1220 | confgcc="${confgcc} --disable-multilib" |
| 1221 | fi |
| 1222 | |
| 1223 | if tc_version_is_at_least "4.0" ; then |
| 1224 | if has mudflap ${IUSE} ; then |
| 1225 | confgcc="${confgcc} $(use_enable mudflap libmudflap)" |
| 1226 | else |
| 1227 | confgcc="${confgcc} --disable-libmudflap" |
| 1228 | fi |
| 1229 | |
| 1230 | if want_libssp ; then |
| 1231 | confgcc="${confgcc} --enable-libssp" |
| 1232 | else |
| 1233 | export gcc_cv_libc_provides_ssp=yes |
| 1234 | confgcc="${confgcc} --disable-libssp" |
| 1235 | fi |
| 1236 | |
| 1237 | # If we want hardened support with the newer pie-patchset for >=gcc 4.4.3 |
| 1238 | if tc_version_is_at_least 4.4.3 && want_minispecs && ! use vanilla ; then |
| 1239 | if hardened_gcc_works ; then |
| 1240 | confgcc="${confgcc} --enable-esp=all" |
| 1241 | elif ! hardened_gcc_works pie && hardened_gcc_works ssp ; then |
| 1242 | confgcc="${confgcc} --enable-esp=nopie" |
| 1243 | elif ! hardened_gcc_works ssp && hardened_gcc_works pie ; then |
| 1244 | confgcc="${confgcc} --enable-esp=nossp" |
| 1245 | else |
| 1246 | confgcc="${confgcc} --disable-esp" |
| 1247 | fi |
| 1248 | fi |
| 1249 | |
| 1250 | if tc_version_is_at_least "4.2" ; then |
| 1251 | confgcc="${confgcc} $(use_enable openmp libgomp)" |
| 1252 | fi |
| 1253 | |
| 1254 | # enable the cld workaround until we move things to stable. |
| 1255 | # by that point, the rest of the software out there should |
| 1256 | # have caught up. |
| 1257 | if tc_version_is_at_least "4.3" ; then |
| 1258 | if ! has ${ARCH} ${KEYWORDS} ; then |
| 1259 | confgcc="${confgcc} --enable-cld" |
| 1260 | fi |
| 1261 | fi |
| 1262 | |
| 1263 | # Stick the python scripts in their own slotted directory |
| 1264 | # bug #279252 |
| 1265 | if tc_version_is_at_least "4.4" ; then |
| 1266 | confgcc="${confgcc} --with-python-dir=${DATAPATH/$PREFIX/}/python" |
| 1267 | fi |
| 1268 | fi |
| 1269 | |
| 1270 | # GTK+ is preferred over xlib in 3.4.x (xlib is unmaintained |
| 1271 | # right now). Much thanks to <csm@gnu.org> for the heads up. |
| 1272 | # Travis Tilley <lv@gentoo.org> (11 Jul 2004) |
| 1273 | if ! is_gcj ; then |
| 1274 | confgcc="${confgcc} --disable-libgcj" |
| 1275 | elif use gtk ; then |
| 1276 | confgcc="${confgcc} --enable-java-awt=gtk" |
| 1277 | fi |
| 1278 | |
| 1279 | case $(tc-arch) in |
| 1280 | arm) #264534 |
| 1281 | local arm_arch="${CTARGET%%-*}" |
| 1282 | # Only do this if arm_arch is armv* |
| 1283 | if [[ ${arm_arch} == armv* ]] ; then |
| 1284 | # Convert armv7{a,r,m} to armv7-{a,r,m} |
| 1285 | [[ ${arm_arch} == armv7? ]] && arm_arch=${arm_arch/7/7-} |
| 1286 | # Remove endian ('l' / 'eb') |
| 1287 | [[ ${arm_arch} == *l ]] && arm_arch=${arm_arch%l} |
| 1288 | [[ ${arm_arch} == *eb ]] && arm_arch=${arm_arch%eb} |
| 1289 | confgcc="${confgcc} --with-arch=${arm_arch}" |
| 1290 | fi |
| 1291 | |
| 1292 | # Enable hardvfp |
| 1293 | if [[ ${CTARGET##*-} == *eabi ]] && [[ $(tc-is-hardfloat) == yes ]] && \ |
| 1294 | tc_version_is_at_least "4.5" ; then |
| 1295 | confgcc="${confgcc} --with-float=hard" |
| 1296 | fi |
| 1297 | ;; |
| 1298 | # Add --with-abi flags to set default MIPS ABI |
| 1299 | mips) |
| 1300 | local mips_abi="" |
| 1301 | use n64 && mips_abi="--with-abi=64" |
| 1302 | use n32 && mips_abi="--with-abi=n32" |
| 1303 | [[ -n ${mips_abi} ]] && confgcc="${confgcc} ${mips_abi}" |
| 1304 | ;; |
| 1305 | # Default arch for x86 is normally i386, lets give it a bump |
| 1306 | # since glibc will do so based on CTARGET anyways |
| 1307 | x86) |
| 1308 | confgcc="${confgcc} --with-arch=${CTARGET%%-*}" |
| 1309 | ;; |
| 1310 | # Enable sjlj exceptions for backward compatibility on hppa |
| 1311 | hppa) |
| 1312 | [[ ${GCCMAJOR} == "3" ]] && confgcc="${confgcc} --enable-sjlj-exceptions" |
| 1313 | ;; |
| 1314 | esac |
| 1315 | |
| 1316 | GCC_LANG="c" |
| 1317 | is_cxx && GCC_LANG="${GCC_LANG},c++" |
| 1318 | is_d && GCC_LANG="${GCC_LANG},d" |
| 1319 | is_gcj && GCC_LANG="${GCC_LANG},java" |
| 1320 | if is_objc || is_objcxx ; then |
| 1321 | GCC_LANG="${GCC_LANG},objc" |
| 1322 | if tc_version_is_at_least "4.0" ; then |
| 1323 | use objc-gc && confgcc="${confgcc} --enable-objc-gc" |
| 1324 | fi |
| 1325 | is_objcxx && GCC_LANG="${GCC_LANG},obj-c++" |
| 1326 | fi |
| 1327 | is_treelang && GCC_LANG="${GCC_LANG},treelang" |
| 1328 | |
| 1329 | # fortran support just got sillier! the lang value can be f77 for |
| 1330 | # fortran77, f95 for fortran95, or just plain old fortran for the |
| 1331 | # currently supported standard depending on gcc version. |
| 1332 | is_fortran && GCC_LANG="${GCC_LANG},fortran" |
| 1333 | is_f77 && GCC_LANG="${GCC_LANG},f77" |
| 1334 | is_f95 && GCC_LANG="${GCC_LANG},f95" |
| 1335 | |
| 1336 | # We do NOT want 'ADA support' in here! |
| 1337 | # is_ada && GCC_LANG="${GCC_LANG},ada" |
| 1338 | |
| 1339 | einfo "configuring for GCC_LANG: ${GCC_LANG}" |
| 1340 | } |
| 1341 | |
| 1342 | # Other than the variables described for gcc_setup_variables, the following |
| 1343 | # will alter tha behavior of gcc_do_configure: |
| 1344 | # |
| 1345 | # CTARGET |
| 1346 | # CBUILD |
| 1347 | # Enable building for a target that differs from CHOST |
| 1348 | # |
| 1349 | # GCC_TARGET_NO_MULTILIB |
| 1350 | # Disable multilib. Useful when building single library targets. |
| 1351 | # |
| 1352 | # GCC_LANG |
| 1353 | # Enable support for ${GCC_LANG} languages. defaults to just "c" |
| 1354 | # |
| 1355 | # Travis Tilley <lv@gentoo.org> (04 Sep 2004) |
| 1356 | # |
| 1357 | gcc_do_configure() { |
| 1358 | local confgcc |
| 1359 | |
| 1360 | # Set configuration based on path variables |
| 1361 | confgcc="${confgcc} \ |
| 1362 | --prefix=${PREFIX} \ |
| 1363 | --bindir=${BINPATH} \ |
| 1364 | --includedir=${INCLUDEPATH} \ |
| 1365 | --datadir=${DATAPATH} \ |
| 1366 | --mandir=${DATAPATH}/man \ |
| 1367 | --infodir=${DATAPATH}/info \ |
| 1368 | --with-gxx-include-dir=${STDCXX_INCDIR}" |
| 1369 | # On Darwin we need libdir to be set in order to get correct install names |
| 1370 | # for things like libobjc-gnu, libgcj and libfortran. If we enable it on |
| 1371 | # non-Darwin we screw up the behaviour this eclass relies on. We in |
| 1372 | # particular need this over --libdir for bug #255315. |
| 1373 | [[ ${CHOST} == *-darwin* ]] && \ |
| 1374 | confgcc="${confgcc} --enable-version-specific-runtime-libs" |
| 1375 | |
| 1376 | # All our cross-compile logic goes here ! woo ! |
| 1377 | confgcc="${confgcc} --host=${CHOST}" |
| 1378 | if is_crosscompile || tc-is-cross-compiler ; then |
| 1379 | # Straight from the GCC install doc: |
| 1380 | # "GCC has code to correctly determine the correct value for target |
| 1381 | # for nearly all native systems. Therefore, we highly recommend you |
| 1382 | # not provide a configure target when configuring a native compiler." |
| 1383 | confgcc="${confgcc} --target=${CTARGET}" |
| 1384 | fi |
| 1385 | [[ -n ${CBUILD} ]] && confgcc="${confgcc} --build=${CBUILD}" |
| 1386 | |
| 1387 | # ppc altivec support |
| 1388 | confgcc="${confgcc} $(use_enable altivec)" |
| 1389 | |
| 1390 | # gcc has fixed-point arithmetic support in 4.3 for mips targets that can |
| 1391 | # significantly increase compile time by several hours. This will allow |
| 1392 | # users to control this feature in the event they need the support. |
| 1393 | tc_version_is_at_least "4.3" && confgcc="${confgcc} $(use_enable fixed-point)" |
| 1394 | |
| 1395 | # graphite support was added in 4.4, which depends upon external libraries |
| 1396 | # for optimizations. This option allows users to determine if they want |
| 1397 | # these optimizations and libraries pulled in |
| 1398 | tc_version_is_at_least "4.4" && \ |
| 1399 | confgcc="${confgcc} $(use_with graphite ppl) $(use_with graphite cloog)" |
| 1400 | |
| 1401 | # lto support was added in 4.5, which depends upon elfutils. This allows |
| 1402 | # users to enable that option, and pull in the additional library |
| 1403 | tc_version_is_at_least "4.5" && \ |
| 1404 | confgcc="${confgcc} $(use_enable lto)" |
| 1405 | |
| 1406 | |
| 1407 | [[ $(tc-is-softfloat) == "yes" ]] && confgcc="${confgcc} --with-float=soft" |
| 1408 | [[ $(tc-is-hardfloat) == "yes" ]] && confgcc="${confgcc} --with-float=hard" |
| 1409 | |
| 1410 | # Native Language Support |
| 1411 | if use nls ; then |
| 1412 | confgcc="${confgcc} --enable-nls --without-included-gettext" |
| 1413 | else |
| 1414 | confgcc="${confgcc} --disable-nls" |
| 1415 | fi |
| 1416 | |
| 1417 | # reasonably sane globals (hopefully) |
| 1418 | confgcc="${confgcc} \ |
| 1419 | --with-system-zlib \ |
| 1420 | --disable-checking \ |
| 1421 | --disable-werror \ |
| 1422 | --enable-secureplt" |
| 1423 | |
| 1424 | # etype specific configuration |
| 1425 | einfo "running ${ETYPE}-configure" |
| 1426 | ${ETYPE}-configure || die |
| 1427 | |
| 1428 | # if not specified, assume we are building for a target that only |
| 1429 | # requires C support |
| 1430 | GCC_LANG=${GCC_LANG:-c} |
| 1431 | confgcc="${confgcc} --enable-languages=${GCC_LANG}" |
| 1432 | |
| 1433 | if is_crosscompile ; then |
| 1434 | # When building a stage1 cross-compiler (just C compiler), we have to |
| 1435 | # disable a bunch of features or gcc goes boom |
| 1436 | local needed_libc="" |
| 1437 | case ${CTARGET} in |
| 1438 | *-linux) needed_libc=no-fucking-clue;; |
| 1439 | *-dietlibc) needed_libc=dietlibc;; |
| 1440 | *-elf) needed_libc=newlib;; |
| 1441 | *-freebsd*) needed_libc=freebsd-lib;; |
| 1442 | *-gnu*) needed_libc=glibc;; |
| 1443 | *-klibc) needed_libc=klibc;; |
| 1444 | *-uclibc*) needed_libc=uclibc;; |
| 1445 | *-cygwin) needed_libc=cygwin;; |
| 1446 | mingw*|*-mingw*) needed_libc=mingw-runtime;; |
| 1447 | avr) confgcc="${confgcc} --enable-shared --disable-threads";; |
| 1448 | esac |
| 1449 | if [[ -n ${needed_libc} ]] ; then |
| 1450 | if ! has_version ${CATEGORY}/${needed_libc} ; then |
| 1451 | confgcc="${confgcc} --disable-shared --disable-threads --without-headers" |
| 1452 | elif built_with_use --hidden --missing false ${CATEGORY}/${needed_libc} crosscompile_opts_headers-only ; then |
| 1453 | confgcc="${confgcc} --disable-shared --with-sysroot=${PREFIX}/${CTARGET}" |
| 1454 | else |
| 1455 | confgcc="${confgcc} --with-sysroot=${PREFIX}/${CTARGET}" |
| 1456 | fi |
| 1457 | fi |
| 1458 | |
| 1459 | if [[ ${GCCMAJOR}.${GCCMINOR} > 4.1 ]] ; then |
| 1460 | confgcc="${confgcc} --disable-bootstrap --disable-libgomp" |
| 1461 | fi |
| 1462 | elif [[ ${CHOST} == mingw* ]] || [[ ${CHOST} == *-mingw* ]] || [[ ${CHOST} == *-cygwin ]] ; then |
| 1463 | confgcc="${confgcc} --enable-shared --enable-threads=win32" |
| 1464 | else |
| 1465 | confgcc="${confgcc} --enable-shared --enable-threads=posix" |
| 1466 | fi |
| 1467 | [[ ${CTARGET} == *-elf ]] && confgcc="${confgcc} --with-newlib" |
| 1468 | # __cxa_atexit is "essential for fully standards-compliant handling of |
| 1469 | # destructors", but apparently requires glibc. |
| 1470 | if [[ ${CTARGET} == *-uclibc* ]] ; then |
| 1471 | confgcc="${confgcc} --disable-__cxa_atexit --enable-target-optspace $(use_enable nptl tls)" |
| 1472 | [[ ${GCCMAJOR}.${GCCMINOR} == 3.3 ]] && confgcc="${confgcc} --enable-sjlj-exceptions" |
| 1473 | if tc_version_is_at_least 3.4 && [[ ${GCCMAJOR}.${GCCMINOR} < 4.3 ]] ; then |
| 1474 | confgcc="${confgcc} --enable-clocale=uclibc" |
| 1475 | fi |
| 1476 | elif [[ ${CTARGET} == *-gnu* ]] ; then |
| 1477 | confgcc="${confgcc} --enable-__cxa_atexit" |
| 1478 | confgcc="${confgcc} --enable-clocale=gnu" |
| 1479 | elif [[ ${CTARGET} == *-freebsd* ]]; then |
| 1480 | confgcc="${confgcc} --enable-__cxa_atexit" |
| 1481 | elif [[ ${CTARGET} == *-solaris* ]]; then |
| 1482 | confgcc="${confgcc} --enable-__cxa_atexit" |
| 1483 | fi |
| 1484 | [[ ${GCCMAJOR}.${GCCMINOR} < 3.4 ]] && confgcc="${confgcc} --disable-libunwind-exceptions" |
| 1485 | |
| 1486 | # create a sparc*linux*-{gcc,g++} that can handle -m32 and -m64 (biarch) |
| 1487 | if [[ ${CTARGET} == sparc*linux* ]] \ |
| 1488 | && is_multilib \ |
| 1489 | && ! is_crosscompile \ |
| 1490 | && [[ ${GCCMAJOR}.${GCCMINOR} > 4.2 ]] |
| 1491 | then |
| 1492 | confgcc="${confgcc} --enable-targets=all" |
| 1493 | fi |
| 1494 | |
| 1495 | tc_version_is_at_least 4.3 && set -- "$@" \ |
| 1496 | --with-bugurl=http://bugs.gentoo.org/ \ |
| 1497 | --with-pkgversion="${BRANDING_GCC_PKGVERSION}" |
| 1498 | set -- ${confgcc} "$@" ${EXTRA_ECONF} |
| 1499 | |
| 1500 | # Nothing wrong with a good dose of verbosity |
| 1501 | echo |
| 1502 | einfo "PREFIX: ${PREFIX}" |
| 1503 | einfo "BINPATH: ${BINPATH}" |
| 1504 | einfo "LIBPATH: ${LIBPATH}" |
| 1505 | einfo "DATAPATH: ${DATAPATH}" |
| 1506 | einfo "STDCXX_INCDIR: ${STDCXX_INCDIR}" |
| 1507 | echo |
| 1508 | einfo "Configuring GCC with: ${@//--/\n\t--}" |
| 1509 | echo |
| 1510 | |
| 1511 | # Build in a separate build tree |
| 1512 | mkdir -p "${WORKDIR}"/build |
| 1513 | pushd "${WORKDIR}"/build > /dev/null |
| 1514 | |
| 1515 | # and now to do the actual configuration |
| 1516 | addwrite /dev/zero |
| 1517 | echo "${S}"/configure "$@" |
| 1518 | "${S}"/configure "$@" || die "failed to run configure" |
| 1519 | |
| 1520 | # return to whatever directory we were in before |
| 1521 | popd > /dev/null |
| 1522 | } |
| 1523 | |
| 1524 | # This function accepts one optional argument, the make target to be used. |
| 1525 | # If ommitted, gcc_do_make will try to guess whether it should use all, |
| 1526 | # profiledbootstrap, or bootstrap-lean depending on CTARGET and arch. An |
| 1527 | # example of how to use this function: |
| 1528 | # |
| 1529 | # gcc_do_make all-target-libstdc++-v3 |
| 1530 | # |
| 1531 | # In addition to the target to be used, the following variables alter the |
| 1532 | # behavior of this function: |
| 1533 | # |
| 1534 | # LDFLAGS |
| 1535 | # Flags to pass to ld |
| 1536 | # |
| 1537 | # STAGE1_CFLAGS |
| 1538 | # CFLAGS to use during stage1 of a gcc bootstrap |
| 1539 | # |
| 1540 | # BOOT_CFLAGS |
| 1541 | # CFLAGS to use during stages 2+3 of a gcc bootstrap. |
| 1542 | # |
| 1543 | # Travis Tilley <lv@gentoo.org> (04 Sep 2004) |
| 1544 | # |
| 1545 | gcc_do_make() { |
| 1546 | # Fix for libtool-portage.patch |
| 1547 | local OLDS=${S} |
| 1548 | S=${WORKDIR}/build |
| 1549 | |
| 1550 | # Set make target to $1 if passed |
| 1551 | [[ -n $1 ]] && GCC_MAKE_TARGET=$1 |
| 1552 | # default target |
| 1553 | if is_crosscompile || tc-is-cross-compiler ; then |
| 1554 | # 3 stage bootstrapping doesnt quite work when you cant run the |
| 1555 | # resulting binaries natively ^^; |
| 1556 | GCC_MAKE_TARGET=${GCC_MAKE_TARGET-all} |
| 1557 | else |
| 1558 | GCC_MAKE_TARGET=${GCC_MAKE_TARGET-bootstrap-lean} |
| 1559 | fi |
| 1560 | |
| 1561 | # the gcc docs state that parallel make isnt supported for the |
| 1562 | # profiledbootstrap target, as collisions in profile collecting may occur. |
| 1563 | [[ ${GCC_MAKE_TARGET} == "profiledbootstrap" ]] && export MAKEOPTS="${MAKEOPTS} -j1" |
| 1564 | |
| 1565 | # boundschecking seems to introduce parallel build issues |
| 1566 | want_boundschecking && export MAKEOPTS="${MAKEOPTS} -j1" |
| 1567 | |
| 1568 | if [[ ${GCC_MAKE_TARGET} == "all" ]] ; then |
| 1569 | STAGE1_CFLAGS=${STAGE1_CFLAGS-"${CFLAGS}"} |
| 1570 | elif [[ $(gcc-version) == "3.4" && ${GCC_BRANCH_VER} == "3.4" ]] && gcc-specs-ssp ; then |
| 1571 | # See bug #79852 |
| 1572 | STAGE1_CFLAGS=${STAGE1_CFLAGS-"-O2"} |
| 1573 | else |
| 1574 | STAGE1_CFLAGS=${STAGE1_CFLAGS-"-O"} |
| 1575 | fi |
| 1576 | |
| 1577 | if is_crosscompile; then |
| 1578 | # In 3.4, BOOT_CFLAGS is never used on a crosscompile... |
| 1579 | # but I'll leave this in anyways as someone might have had |
| 1580 | # some reason for putting it in here... --eradicator |
| 1581 | BOOT_CFLAGS=${BOOT_CFLAGS-"-O2"} |
| 1582 | else |
| 1583 | # we only want to use the system's CFLAGS if not building a |
| 1584 | # cross-compiler. |
| 1585 | BOOT_CFLAGS=${BOOT_CFLAGS-"$(get_abi_CFLAGS) ${CFLAGS}"} |
| 1586 | fi |
| 1587 | |
| 1588 | pushd "${WORKDIR}"/build |
| 1589 | |
| 1590 | emake \ |
| 1591 | LDFLAGS="${LDFLAGS}" \ |
| 1592 | STAGE1_CFLAGS="${STAGE1_CFLAGS}" \ |
| 1593 | LIBPATH="${LIBPATH}" \ |
| 1594 | BOOT_CFLAGS="${BOOT_CFLAGS}" \ |
| 1595 | ${GCC_MAKE_TARGET} \ |
| 1596 | || die "emake failed with ${GCC_MAKE_TARGET}" |
| 1597 | |
| 1598 | if ! is_crosscompile && ! use nocxx && use doc ; then |
| 1599 | if type -p doxygen > /dev/null ; then |
| 1600 | if tc_version_is_at_least 4.3 ; then |
| 1601 | cd "${CTARGET}"/libstdc++-v3/doc |
| 1602 | emake doc-man-doxygen || ewarn "failed to make docs" |
| 1603 | elif tc_version_is_at_least 3.0 ; then |
| 1604 | cd "${CTARGET}"/libstdc++-v3 |
| 1605 | emake doxygen-man || ewarn "failed to make docs" |
| 1606 | fi |
| 1607 | else |
| 1608 | ewarn "Skipping libstdc++ manpage generation since you don't have doxygen installed" |
| 1609 | fi |
| 1610 | fi |
| 1611 | |
| 1612 | popd |
| 1613 | } |
| 1614 | |
| 1615 | # This function will add ${GCC_CONFIG_VER} to the names of all shared libraries in the |
| 1616 | # directory specified to avoid filename collisions between multiple slotted |
| 1617 | # non-versioned gcc targets. If no directory is specified, it is assumed that |
| 1618 | # you want -all- shared objects to have ${GCC_CONFIG_VER} added. Example |
| 1619 | # |
| 1620 | # add_version_to_shared ${D}/usr/$(get_libdir) |
| 1621 | # |
| 1622 | # Travis Tilley <lv@gentoo.org> (05 Sep 2004) |
| 1623 | # |
| 1624 | add_version_to_shared() { |
| 1625 | local sharedlib sharedlibdir |
| 1626 | [[ -z $1 ]] \ |
| 1627 | && sharedlibdir=${D} \ |
| 1628 | || sharedlibdir=$1 |
| 1629 | |
| 1630 | for sharedlib in $(find ${sharedlibdir} -name *.so.*) ; do |
| 1631 | if [[ ! -L ${sharedlib} ]] ; then |
| 1632 | einfo "Renaming `basename "${sharedlib}"` to `basename "${sharedlib/.so*/}-${GCC_CONFIG_VER}.so.${sharedlib/*.so./}"`" |
| 1633 | mv "${sharedlib}" "${sharedlib/.so*/}-${GCC_CONFIG_VER}.so.${sharedlib/*.so./}" \ |
| 1634 | || die |
| 1635 | pushd `dirname "${sharedlib}"` > /dev/null || die |
| 1636 | ln -sf "`basename "${sharedlib/.so*/}-${GCC_CONFIG_VER}.so.${sharedlib/*.so./}"`" \ |
| 1637 | "`basename "${sharedlib}"`" || die |
| 1638 | popd > /dev/null || die |
| 1639 | fi |
| 1640 | done |
| 1641 | } |
| 1642 | |
| 1643 | # This is mostly a stub function to be overwritten in an ebuild |
| 1644 | gcc_do_filter_flags() { |
| 1645 | strip-flags |
| 1646 | |
| 1647 | # In general gcc does not like optimization, and add -O2 where |
| 1648 | # it is safe. This is especially true for gcc 3.3 + 3.4 |
| 1649 | replace-flags -O? -O2 |
| 1650 | |
| 1651 | # ... sure, why not? |
| 1652 | strip-unsupported-flags |
| 1653 | |
| 1654 | # dont want to funk ourselves |
| 1655 | filter-flags '-mabi*' -m31 -m32 -m64 |
| 1656 | |
| 1657 | case ${GCC_BRANCH_VER} in |
| 1658 | 3.2|3.3) |
| 1659 | replace-cpu-flags k8 athlon64 opteron i686 x86-64 |
| 1660 | replace-cpu-flags pentium-m pentium3m pentium3 |
| 1661 | case $(tc-arch) in |
| 1662 | amd64|x86) filter-flags '-mtune=*' ;; |
| 1663 | # in gcc 3.3 there is a bug on ppc64 where if -mcpu is used, |
| 1664 | # the compiler wrongly assumes a 32bit target |
| 1665 | ppc64) filter-flags "-mcpu=*";; |
| 1666 | esac |
| 1667 | case $(tc-arch) in |
| 1668 | amd64) replace-cpu-flags core2 nocona;; |
| 1669 | x86) replace-cpu-flags core2 prescott;; |
| 1670 | esac |
| 1671 | |
| 1672 | replace-cpu-flags G3 750 |
| 1673 | replace-cpu-flags G4 7400 |
| 1674 | replace-cpu-flags G5 7400 |
| 1675 | |
| 1676 | # XXX: should add a sed or something to query all supported flags |
| 1677 | # from the gcc source and trim everything else ... |
| 1678 | filter-flags -f{no-,}unit-at-a-time -f{no-,}web -mno-tls-direct-seg-refs |
| 1679 | filter-flags -f{no-,}stack-protector{,-all} |
| 1680 | filter-flags -fvisibility-inlines-hidden -fvisibility=hidden |
| 1681 | ;; |
| 1682 | 3.4|4.*) |
| 1683 | case $(tc-arch) in |
| 1684 | x86|amd64) filter-flags '-mcpu=*';; |
| 1685 | *-macos) |
| 1686 | # http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25127 |
| 1687 | [[ ${GCC_BRANCH_VER} == 4.0 || ${GCC_BRANCH_VER} == 4.1 ]] && \ |
| 1688 | filter-flags '-mcpu=*' '-march=*' '-mtune=*' |
| 1689 | ;; |
| 1690 | esac |
| 1691 | ;; |
| 1692 | esac |
| 1693 | |
| 1694 | # Compile problems with these (bug #6641 among others)... |
| 1695 | #filter-flags "-fno-exceptions -fomit-frame-pointer -fforce-addr" |
| 1696 | |
| 1697 | # CFLAGS logic (verified with 3.4.3): |
| 1698 | # CFLAGS: |
| 1699 | # This conflicts when creating a crosscompiler, so set to a sane |
| 1700 | # default in this case: |
| 1701 | # used in ./configure and elsewhere for the native compiler |
| 1702 | # used by gcc when creating libiberty.a |
| 1703 | # used by xgcc when creating libstdc++ (and probably others)! |
| 1704 | # this behavior should be removed... |
| 1705 | # |
| 1706 | # CXXFLAGS: |
| 1707 | # used by xgcc when creating libstdc++ |
| 1708 | # |
| 1709 | # STAGE1_CFLAGS (not used in creating a crosscompile gcc): |
| 1710 | # used by ${CHOST}-gcc for building stage1 compiler |
| 1711 | # |
| 1712 | # BOOT_CFLAGS (not used in creating a crosscompile gcc): |
| 1713 | # used by xgcc for building stage2/3 compiler |
| 1714 | |
| 1715 | if is_crosscompile ; then |
| 1716 | # Set this to something sane for both native and target |
| 1717 | CFLAGS="-O2 -pipe" |
| 1718 | |
| 1719 | local VAR="CFLAGS_"${CTARGET//-/_} |
| 1720 | CXXFLAGS=${!VAR} |
| 1721 | fi |
| 1722 | |
| 1723 | export GCJFLAGS=${GCJFLAGS:-${CFLAGS}} |
| 1724 | } |
| 1725 | |
| 1726 | gcc_src_compile() { |
| 1727 | gcc_do_filter_flags |
| 1728 | einfo "CFLAGS=\"${CFLAGS}\"" |
| 1729 | einfo "CXXFLAGS=\"${CXXFLAGS}\"" |
| 1730 | |
| 1731 | # For hardened gcc 4 for build the hardened specs file to use when building gcc |
| 1732 | setup_minispecs_gcc_build_specs |
| 1733 | |
| 1734 | # Build in a separate build tree |
| 1735 | mkdir -p "${WORKDIR}"/build |
| 1736 | pushd "${WORKDIR}"/build > /dev/null |
| 1737 | |
| 1738 | # Install our pre generated manpages if we do not have perl ... |
| 1739 | [[ ! -x /usr/bin/perl ]] && [[ -n ${MAN_VER} ]] && \ |
| 1740 | unpack gcc-${MAN_VER}-manpages.tar.bz2 |
| 1741 | |
| 1742 | einfo "Configuring ${PN} ..." |
| 1743 | gcc_do_configure |
| 1744 | |
| 1745 | touch "${S}"/gcc/c-gperf.h |
| 1746 | |
| 1747 | # Do not make manpages if we do not have perl ... |
| 1748 | [[ ! -x /usr/bin/perl ]] \ |
| 1749 | && find "${WORKDIR}"/build -name '*.[17]' | xargs touch |
| 1750 | |
| 1751 | einfo "Compiling ${PN} ..." |
| 1752 | gcc_do_make ${GCC_MAKE_TARGET} |
| 1753 | |
| 1754 | # Do not create multiple specs files for PIE+SSP if boundschecking is in |
| 1755 | # USE, as we disable PIE+SSP when it is. |
| 1756 | if [[ ${ETYPE} == "gcc-compiler" ]] && want_split_specs && ! want_minispecs; then |
| 1757 | split_out_specs_files || die "failed to split out specs" |
| 1758 | fi |
| 1759 | |
| 1760 | popd > /dev/null |
| 1761 | } |
| 1762 | |
| 1763 | gcc_src_test() { |
| 1764 | cd "${WORKDIR}"/build |
| 1765 | emake -j1 -k check || ewarn "check failed and that sucks :(" |
| 1766 | } |
| 1767 | |
| 1768 | gcc-library_src_install() { |
| 1769 | # Do the 'make install' from the build directory |
| 1770 | cd "${WORKDIR}"/build |
| 1771 | S=${WORKDIR}/build \ |
| 1772 | emake -j1 \ |
| 1773 | DESTDIR="${D}" \ |
| 1774 | prefix=${PREFIX} \ |
| 1775 | bindir=${BINPATH} \ |
| 1776 | includedir=${LIBPATH}/include \ |
| 1777 | datadir=${DATAPATH} \ |
| 1778 | mandir=${DATAPATH}/man \ |
| 1779 | infodir=${DATAPATH}/info \ |
| 1780 | LIBPATH="${LIBPATH}" \ |
| 1781 | ${GCC_INSTALL_TARGET} || die |
| 1782 | |
| 1783 | if [[ ${GCC_LIB_COMPAT_ONLY} == "true" ]] ; then |
| 1784 | rm -rf "${D}"${INCLUDEPATH} |
| 1785 | rm -rf "${D}"${DATAPATH} |
| 1786 | pushd "${D}"${LIBPATH}/ |
| 1787 | rm *.a *.la *.so |
| 1788 | popd |
| 1789 | fi |
| 1790 | |
| 1791 | if [[ -n ${GCC_LIB_USE_SUBDIR} ]] ; then |
| 1792 | mkdir -p "${WORKDIR}"/${GCC_LIB_USE_SUBDIR}/ |
| 1793 | mv "${D}"${LIBPATH}/* "${WORKDIR}"/${GCC_LIB_USE_SUBDIR}/ |
| 1794 | mv "${WORKDIR}"/${GCC_LIB_USE_SUBDIR}/ "${D}"${LIBPATH} |
| 1795 | |
| 1796 | dodir /etc/env.d |
| 1797 | echo "LDPATH=\"${LIBPATH}/${GCC_LIB_USE_SUBDIR}/\"" >> "${D}"/etc/env.d/99${PN} |
| 1798 | fi |
| 1799 | |
| 1800 | if [[ ${GCC_VAR_TYPE} == "non-versioned" ]] ; then |
| 1801 | # if we're not using versioned directories, we need to use versioned |
| 1802 | # filenames. |
| 1803 | add_version_to_shared |
| 1804 | fi |
| 1805 | } |
| 1806 | |
| 1807 | gcc-compiler_src_install() { |
| 1808 | local x= |
| 1809 | |
| 1810 | cd "${WORKDIR}"/build |
| 1811 | # Do allow symlinks in private gcc include dir as this can break the build |
| 1812 | find gcc/include*/ -type l -print0 | xargs -0 rm -f |
| 1813 | # Remove generated headers, as they can cause things to break |
| 1814 | # (ncurses, openssl, etc). |
| 1815 | for x in $(find gcc/include*/ -name '*.h') ; do |
| 1816 | grep -q 'It has been auto-edited by fixincludes from' "${x}" \ |
| 1817 | && rm -f "${x}" |
| 1818 | done |
| 1819 | # Do the 'make install' from the build directory |
| 1820 | S=${WORKDIR}/build \ |
| 1821 | emake -j1 DESTDIR="${D}" install || die |
| 1822 | # Punt some tools which are really only useful while building gcc |
| 1823 | find "${D}" -name install-tools -prune -type d -exec rm -rf "{}" \; |
| 1824 | # This one comes with binutils |
| 1825 | find "${D}" -name libiberty.a -exec rm -f "{}" \; |
| 1826 | |
| 1827 | # Move the libraries to the proper location |
| 1828 | gcc_movelibs |
| 1829 | |
| 1830 | # Basic sanity check |
| 1831 | if ! is_crosscompile ; then |
| 1832 | local EXEEXT |
| 1833 | eval $(grep ^EXEEXT= "${WORKDIR}"/build/gcc/config.log) |
| 1834 | [[ -r ${D}${BINPATH}/gcc${EXEEXT} ]] || die "gcc not found in ${D}" |
| 1835 | fi |
| 1836 | |
| 1837 | dodir /etc/env.d/gcc |
| 1838 | create_gcc_env_entry |
| 1839 | |
| 1840 | if want_split_specs ; then |
| 1841 | if use hardened ; then |
| 1842 | create_gcc_env_entry vanilla |
| 1843 | fi |
| 1844 | ! use hardened && hardened_gcc_works && create_gcc_env_entry hardened |
| 1845 | if hardened_gcc_works || hardened_gcc_works pie ; then |
| 1846 | create_gcc_env_entry hardenednossp |
| 1847 | fi |
| 1848 | if hardened_gcc_works || hardened_gcc_works ssp ; then |
| 1849 | create_gcc_env_entry hardenednopie |
| 1850 | fi |
| 1851 | create_gcc_env_entry hardenednopiessp |
| 1852 | |
| 1853 | insinto ${LIBPATH} |
| 1854 | doins "${WORKDIR}"/build/*.specs || die "failed to install specs" |
| 1855 | fi |
| 1856 | # Setup the gcc_env_entry for hardened gcc 4 with minispecs |
| 1857 | if want_minispecs ; then |
| 1858 | if hardened_gcc_works ; then |
| 1859 | create_gcc_env_entry hardenednopiessp |
| 1860 | fi |
| 1861 | if hardened_gcc_works pie ; then |
| 1862 | create_gcc_env_entry hardenednopie |
| 1863 | fi |
| 1864 | if hardened_gcc_works ssp ; then |
| 1865 | create_gcc_env_entry hardenednossp |
| 1866 | fi |
| 1867 | create_gcc_env_entry vanilla |
| 1868 | fi |
| 1869 | # Make sure we dont have stuff lying around that |
| 1870 | # can nuke multiple versions of gcc |
| 1871 | |
| 1872 | gcc_slot_java |
| 1873 | |
| 1874 | # Move <cxxabi.h> to compiler-specific directories |
| 1875 | [[ -f ${D}${STDCXX_INCDIR}/cxxabi.h ]] && \ |
| 1876 | mv -f "${D}"${STDCXX_INCDIR}/cxxabi.h "${D}"${LIBPATH}/include/ |
| 1877 | |
| 1878 | # These should be symlinks |
| 1879 | dodir /usr/bin |
| 1880 | cd "${D}"${BINPATH} |
| 1881 | for x in cpp gcc g++ c++ g77 gcj gcjh gfortran ; do |
| 1882 | # For some reason, g77 gets made instead of ${CTARGET}-g77... |
| 1883 | # this should take care of that |
| 1884 | [[ -f ${x} ]] && mv ${x} ${CTARGET}-${x} |
| 1885 | |
| 1886 | if [[ -f ${CTARGET}-${x} ]] && ! is_crosscompile ; then |
| 1887 | ln -sf ${CTARGET}-${x} ${x} |
| 1888 | |
| 1889 | # Create version-ed symlinks |
| 1890 | dosym ${BINPATH}/${CTARGET}-${x} \ |
| 1891 | /usr/bin/${CTARGET}-${x}-${GCC_CONFIG_VER} |
| 1892 | dosym ${BINPATH}/${CTARGET}-${x} \ |
| 1893 | /usr/bin/${x}-${GCC_CONFIG_VER} |
| 1894 | fi |
| 1895 | |
| 1896 | if [[ -f ${CTARGET}-${x}-${GCC_CONFIG_VER} ]] ; then |
| 1897 | rm -f ${CTARGET}-${x}-${GCC_CONFIG_VER} |
| 1898 | ln -sf ${CTARGET}-${x} ${CTARGET}-${x}-${GCC_CONFIG_VER} |
| 1899 | fi |
| 1900 | done |
| 1901 | |
| 1902 | # I do not know if this will break gcj stuff, so I'll only do it for |
| 1903 | # objc for now; basically "ffi.h" is the correct file to include, |
| 1904 | # but it gets installed in .../GCCVER/include and yet it does |
| 1905 | # "#include <ffitarget.h>" which (correctly, as it's an "extra" file) |
| 1906 | # is installed in .../GCCVER/include/libffi; the following fixes |
| 1907 | # ffi.'s include of ffitarget.h - Armando Di Cianno <fafhrd@gentoo.org> |
| 1908 | if [[ -d ${D}${LIBPATH}/include/libffi ]] ; then |
| 1909 | mv -i "${D}"${LIBPATH}/include/libffi/* "${D}"${LIBPATH}/include || die |
| 1910 | rm -r "${D}"${LIBPATH}/include/libffi || die |
| 1911 | fi |
| 1912 | |
| 1913 | # Now do the fun stripping stuff |
| 1914 | env RESTRICT="" CHOST=${CHOST} prepstrip "${D}${BINPATH}" |
| 1915 | env RESTRICT="" CHOST=${CTARGET} prepstrip "${D}${LIBPATH}" |
| 1916 | # gcc used to install helper binaries in lib/ but then moved to libexec/ |
| 1917 | [[ -d ${D}${PREFIX}/libexec/gcc ]] && \ |
| 1918 | env RESTRICT="" CHOST=${CHOST} prepstrip "${D}${PREFIX}/libexec/gcc/${CTARGET}/${GCC_CONFIG_VER}" |
| 1919 | |
| 1920 | cd "${S}" |
| 1921 | if is_crosscompile; then |
| 1922 | rm -rf "${D}"/usr/share/{man,info} |
| 1923 | rm -rf "${D}"${DATAPATH}/{man,info} |
| 1924 | else |
| 1925 | local cxx_mandir=${WORKDIR}/build/${CTARGET}/libstdc++-v3/docs/doxygen/man |
| 1926 | if [[ -d ${cxx_mandir} ]] ; then |
| 1927 | # clean bogus manpages #113902 |
| 1928 | find "${cxx_mandir}" -name '*_build_*' -exec rm {} \; |
| 1929 | cp -r "${cxx_mandir}"/man? "${D}/${DATAPATH}"/man/ |
| 1930 | fi |
| 1931 | has noinfo ${FEATURES} \ |
| 1932 | && rm -r "${D}/${DATAPATH}"/info \ |
| 1933 | || prepinfo "${DATAPATH}" |
| 1934 | has noman ${FEATURES} \ |
| 1935 | && rm -r "${D}/${DATAPATH}"/man \ |
| 1936 | || prepman "${DATAPATH}" |
| 1937 | fi |
| 1938 | # prune empty dirs left behind |
| 1939 | for x in 1 2 3 4 ; do |
| 1940 | find "${D}" -type d -exec rmdir "{}" \; >& /dev/null |
| 1941 | done |
| 1942 | |
| 1943 | # install testsuite results |
| 1944 | if use test; then |
| 1945 | docinto testsuite |
| 1946 | find "${WORKDIR}"/build -type f -name "*.sum" -print0 | xargs -0 dodoc |
| 1947 | find "${WORKDIR}"/build -type f -path "*/testsuite/*.log" -print0 \ |
| 1948 | | xargs -0 dodoc |
| 1949 | fi |
| 1950 | |
| 1951 | # Rather install the script, else portage with changing $FILESDIR |
| 1952 | # between binary and source package borks things .... |
| 1953 | if ! is_crosscompile ; then |
| 1954 | insinto "${DATAPATH}" |
| 1955 | if tc_version_is_at_least 4.0 ; then |
| 1956 | newins "${GCC_FILESDIR}"/awk/fixlafiles.awk-no_gcc_la fixlafiles.awk || die |
| 1957 | find "${D}/${LIBPATH}" -name libstdc++.la -type f -exec rm "{}" \; |
| 1958 | else |
| 1959 | doins "${GCC_FILESDIR}"/awk/fixlafiles.awk || die |
| 1960 | fi |
| 1961 | exeinto "${DATAPATH}" |
| 1962 | doexe "${GCC_FILESDIR}"/fix_libtool_files.sh || die |
| 1963 | doexe "${GCC_FILESDIR}"/c{89,99} || die |
| 1964 | fi |
| 1965 | |
| 1966 | # use gid of 0 because some stupid ports don't have |
| 1967 | # the group 'root' set to gid 0 |
| 1968 | chown -R root:0 "${D}"${LIBPATH} |
| 1969 | |
| 1970 | # Create config files for eselect-compiler |
| 1971 | create_eselect_conf |
| 1972 | |
| 1973 | # Copy the needed minispec for hardened gcc 4 |
| 1974 | copy_minispecs_gcc_specs |
| 1975 | |
| 1976 | # Move pretty-printers to gdb datadir to shut ldconfig up |
| 1977 | gdbdir=/usr/share/gdb/auto-load |
| 1978 | for module in $(find "${D}" -iname "*-gdb.py" -print); do |
| 1979 | insinto ${gdbdir}/$(dirname "${module/${D}/}" | \ |
| 1980 | sed -e "s:/lib/:/$(get_libdir)/:g") |
| 1981 | doins "${module}" |
| 1982 | rm "${module}" |
| 1983 | done |
| 1984 | } |
| 1985 | |
| 1986 | gcc_slot_java() { |
| 1987 | local x |
| 1988 | |
| 1989 | # Move Java headers to compiler-specific dir |
| 1990 | for x in "${D}"${PREFIX}/include/gc*.h "${D}"${PREFIX}/include/j*.h ; do |
| 1991 | [[ -f ${x} ]] && mv -f "${x}" "${D}"${LIBPATH}/include/ |
| 1992 | done |
| 1993 | for x in gcj gnu java javax org ; do |
| 1994 | if [[ -d ${D}${PREFIX}/include/${x} ]] ; then |
| 1995 | dodir /${LIBPATH}/include/${x} |
| 1996 | mv -f "${D}"${PREFIX}/include/${x}/* "${D}"${LIBPATH}/include/${x}/ |
| 1997 | rm -rf "${D}"${PREFIX}/include/${x} |
| 1998 | fi |
| 1999 | done |
| 2000 | |
| 2001 | if [[ -d ${D}${PREFIX}/lib/security ]] || [[ -d ${D}${PREFIX}/$(get_libdir)/security ]] ; then |
| 2002 | dodir /${LIBPATH}/security |
| 2003 | mv -f "${D}"${PREFIX}/lib*/security/* "${D}"${LIBPATH}/security |
| 2004 | rm -rf "${D}"${PREFIX}/lib*/security |
| 2005 | fi |
| 2006 | |
| 2007 | # Move libgcj.spec to compiler-specific directories |
| 2008 | [[ -f ${D}${PREFIX}/lib/libgcj.spec ]] && \ |
| 2009 | mv -f "${D}"${PREFIX}/lib/libgcj.spec "${D}"${LIBPATH}/libgcj.spec |
| 2010 | |
| 2011 | # SLOT up libgcj.pc (and let gcc-config worry about links) |
| 2012 | local libgcj=$(find "${D}"${PREFIX}/lib/pkgconfig/ -name 'libgcj*.pc') |
| 2013 | if [[ -n ${libgcj} ]] ; then |
| 2014 | sed -i "/^libdir=/s:=.*:=${LIBPATH}:" "${libgcj}" |
| 2015 | mv "${libgcj}" "${D}"/usr/lib/pkgconfig/libgcj-${GCC_PV}.pc || die |
| 2016 | fi |
| 2017 | |
| 2018 | # Rename jar because it could clash with Kaffe's jar if this gcc is |
| 2019 | # primary compiler (aka don't have the -<version> extension) |
| 2020 | cd "${D}"${BINPATH} |
| 2021 | [[ -f jar ]] && mv -f jar gcj-jar |
| 2022 | } |
| 2023 | |
| 2024 | # Move around the libs to the right location. For some reason, |
| 2025 | # when installing gcc, it dumps internal libraries into /usr/lib |
| 2026 | # instead of the private gcc lib path |
| 2027 | gcc_movelibs() { |
| 2028 | # older versions of gcc did not support --print-multi-os-directory |
| 2029 | tc_version_is_at_least 3.0 || return 0 |
| 2030 | |
| 2031 | local multiarg removedirs="" |
| 2032 | for multiarg in $($(XGCC) -print-multi-lib) ; do |
| 2033 | multiarg=${multiarg#*;} |
| 2034 | multiarg=${multiarg//@/ -} |
| 2035 | |
| 2036 | local OS_MULTIDIR=$($(XGCC) ${multiarg} --print-multi-os-directory) |
| 2037 | local MULTIDIR=$($(XGCC) ${multiarg} --print-multi-directory) |
| 2038 | local TODIR=${D}${LIBPATH}/${MULTIDIR} |
| 2039 | local FROMDIR= |
| 2040 | |
| 2041 | [[ -d ${TODIR} ]] || mkdir -p ${TODIR} |
| 2042 | |
| 2043 | for FROMDIR in \ |
| 2044 | ${LIBPATH}/${OS_MULTIDIR} \ |
| 2045 | ${LIBPATH}/../${MULTIDIR} \ |
| 2046 | ${PREFIX}/lib/${OS_MULTIDIR} \ |
| 2047 | ${PREFIX}/${CTARGET}/lib/${OS_MULTIDIR} \ |
| 2048 | ${PREFIX}/lib/${MULTIDIR} |
| 2049 | do |
| 2050 | removedirs="${removedirs} ${FROMDIR}" |
| 2051 | FROMDIR=${D}${FROMDIR} |
| 2052 | if [[ ${FROMDIR} != "${TODIR}" && -d ${FROMDIR} ]] ; then |
| 2053 | local files=$(find "${FROMDIR}" -maxdepth 1 ! -type d 2>/dev/null) |
| 2054 | if [[ -n ${files} ]] ; then |
| 2055 | mv ${files} "${TODIR}" |
| 2056 | fi |
| 2057 | fi |
| 2058 | done |
| 2059 | fix_libtool_libdir_paths "${LIBPATH}/${MULTIDIR}" |
| 2060 | done |
| 2061 | |
| 2062 | # We remove directories separately to avoid this case: |
| 2063 | # mv SRC/lib/../lib/*.o DEST |
| 2064 | # rmdir SRC/lib/../lib/ |
| 2065 | # mv SRC/lib/../lib32/*.o DEST # Bork |
| 2066 | for FROMDIR in ${removedirs} ; do |
| 2067 | rmdir "${D}"${FROMDIR} >& /dev/null |
| 2068 | done |
| 2069 | find "${D}" -type d | xargs rmdir >& /dev/null |
| 2070 | } |
| 2071 | |
| 2072 | #----<< src_* >>---- |
| 2073 | |
| 2074 | #---->> unorganized crap in need of refactoring follows |
| 2075 | |
| 2076 | # gcc_quick_unpack will unpack the gcc tarball and patches in a way that is |
| 2077 | # consistant with the behavior of get_gcc_src_uri. The only patch it applies |
| 2078 | # itself is the branch update if present. |
| 2079 | # |
| 2080 | # Travis Tilley <lv@gentoo.org> (03 Sep 2004) |
| 2081 | # |
| 2082 | gcc_quick_unpack() { |
| 2083 | pushd "${WORKDIR}" > /dev/null |
| 2084 | export PATCH_GCC_VER=${PATCH_GCC_VER:-${GCC_RELEASE_VER}} |
| 2085 | export UCLIBC_GCC_VER=${UCLIBC_GCC_VER:-${PATCH_GCC_VER}} |
| 2086 | export PIE_GCC_VER=${PIE_GCC_VER:-${GCC_RELEASE_VER}} |
| 2087 | export PP_GCC_VER=${PP_GCC_VER:-${GCC_RELEASE_VER}} |
| 2088 | export HTB_GCC_VER=${HTB_GCC_VER:-${GCC_RELEASE_VER}} |
| 2089 | export SPECS_GCC_VER=${SPECS_GCC_VER:-${GCC_RELEASE_VER}} |
| 2090 | |
| 2091 | if [[ -n ${GCC_A_FAKEIT} ]] ; then |
| 2092 | unpack ${GCC_A_FAKEIT} |
| 2093 | elif [[ -n ${PRERELEASE} ]] ; then |
| 2094 | unpack gcc-${PRERELEASE}.tar.bz2 |
| 2095 | elif [[ -n ${SNAPSHOT} ]] ; then |
| 2096 | unpack gcc-${SNAPSHOT}.tar.bz2 |
| 2097 | else |
| 2098 | unpack gcc-${GCC_RELEASE_VER}.tar.bz2 |
| 2099 | # We want branch updates to be against a release tarball |
| 2100 | if [[ -n ${BRANCH_UPDATE} ]] ; then |
| 2101 | pushd "${S}" > /dev/null |
| 2102 | epatch "${DISTDIR}"/gcc-${GCC_RELEASE_VER}-branch-update-${BRANCH_UPDATE}.patch.bz2 |
| 2103 | popd > /dev/null |
| 2104 | fi |
| 2105 | fi |
| 2106 | |
| 2107 | if [[ -n ${D_VER} ]] && use d ; then |
| 2108 | pushd "${S}"/gcc > /dev/null |
| 2109 | unpack gdc-${D_VER}-src.tar.bz2 |
| 2110 | cd .. |
| 2111 | ebegin "Adding support for the D language" |
| 2112 | ./gcc/d/setup-gcc.sh >& "${T}"/dgcc.log |
| 2113 | if ! eend $? ; then |
| 2114 | eerror "The D gcc package failed to apply" |
| 2115 | eerror "Please include this log file when posting a bug report:" |
| 2116 | eerror " ${T}/dgcc.log" |
| 2117 | die "failed to include the D language" |
| 2118 | fi |
| 2119 | popd > /dev/null |
| 2120 | fi |
| 2121 | |
| 2122 | [[ -n ${PATCH_VER} ]] && \ |
| 2123 | unpack gcc-${PATCH_GCC_VER}-patches-${PATCH_VER}.tar.bz2 |
| 2124 | |
| 2125 | [[ -n ${UCLIBC_VER} ]] && \ |
| 2126 | unpack gcc-${UCLIBC_GCC_VER}-uclibc-patches-${UCLIBC_VER}.tar.bz2 |
| 2127 | |
| 2128 | if want_ssp && [[ -z ${SPECS_VER} ]] ; then |
| 2129 | if [[ -n ${PP_FVER} ]] ; then |
| 2130 | # The gcc 3.4 propolice versions are meant to be unpacked to ${S} |
| 2131 | pushd "${S}" > /dev/null |
| 2132 | unpack protector-${PP_FVER}.tar.gz |
| 2133 | popd > /dev/null |
| 2134 | else |
| 2135 | unpack gcc-${PP_GCC_VER}-ssp-${PP_VER}.tar.bz2 |
| 2136 | fi |
| 2137 | fi |
| 2138 | |
| 2139 | if want_pie ; then |
| 2140 | if [[ -n ${PIE_CORE} ]] ; then |
| 2141 | unpack ${PIE_CORE} |
| 2142 | else |
| 2143 | unpack gcc-${PIE_GCC_VER}-piepatches-v${PIE_VER}.tar.bz2 |
| 2144 | fi |
| 2145 | [[ -n ${SPECS_VER} ]] && \ |
| 2146 | unpack gcc-${SPECS_GCC_VER}-specs-${SPECS_VER}.tar.bz2 |
| 2147 | fi |
| 2148 | |
| 2149 | want_boundschecking && \ |
| 2150 | unpack "bounds-checking-gcc-${HTB_GCC_VER}-${HTB_VER}.patch.bz2" |
| 2151 | |
| 2152 | popd > /dev/null |
| 2153 | } |
| 2154 | |
| 2155 | # Exclude any unwanted patches, as specified by the following variables: |
| 2156 | # |
| 2157 | # GENTOO_PATCH_EXCLUDE |
| 2158 | # List of filenames, relative to ${WORKDIR}/patch/ |
| 2159 | # |
| 2160 | # PIEPATCH_EXCLUDE |
| 2161 | # List of filenames, relative to ${WORKDIR}/piepatch/ |
| 2162 | # |
| 2163 | # Travis Tilley <lv@gentoo.org> (03 Sep 2004) |
| 2164 | # |
| 2165 | exclude_gcc_patches() { |
| 2166 | local i |
| 2167 | for i in ${GENTOO_PATCH_EXCLUDE} ; do |
| 2168 | if [[ -f ${WORKDIR}/patch/${i} ]] ; then |
| 2169 | einfo "Excluding patch ${i}" |
| 2170 | rm -f "${WORKDIR}"/patch/${i} || die "failed to delete ${i}" |
| 2171 | fi |
| 2172 | done |
| 2173 | for i in ${PIEPATCH_EXCLUDE} ; do |
| 2174 | if [[ -f ${WORKDIR}/piepatch/${i} ]] ; then |
| 2175 | einfo "Excluding piepatch ${i}" |
| 2176 | rm -f "${WORKDIR}"/piepatch/${i} || die "failed to delete ${i}" |
| 2177 | fi |
| 2178 | done |
| 2179 | } |
| 2180 | |
| 2181 | # Try to apply some stub patches so that gcc won't error out when |
| 2182 | # passed parameters like -fstack-protector but no ssp is found |
| 2183 | do_gcc_stub() { |
| 2184 | local v stub_patch="" |
| 2185 | for v in ${GCC_RELEASE_VER} ${GCC_BRANCH_VER} ; do |
| 2186 | stub_patch=${GCC_FILESDIR}/stubs/gcc-${v}-$1-stub.patch |
| 2187 | if [[ -e ${stub_patch} ]] && ! use vanilla ; then |
| 2188 | EPATCH_SINGLE_MSG="Applying stub patch for $1 ..." \ |
| 2189 | epatch "${stub_patch}" |
| 2190 | return 0 |
| 2191 | fi |
| 2192 | done |
| 2193 | } |
| 2194 | |
| 2195 | do_gcc_HTB_patches() { |
| 2196 | if ! want_boundschecking || \ |
| 2197 | (want_ssp && [[ ${HTB_EXCLUSIVE} == "true" ]]) |
| 2198 | then |
| 2199 | do_gcc_stub htb |
| 2200 | return 0 |
| 2201 | fi |
| 2202 | |
| 2203 | # modify the bounds checking patch with a regression patch |
| 2204 | epatch "${WORKDIR}/bounds-checking-gcc-${HTB_GCC_VER}-${HTB_VER}.patch" |
| 2205 | BRANDING_GCC_PKGVERSION="${BRANDING_GCC_PKGVERSION}, HTB-${HTB_GCC_VER}-${HTB_VER}" |
| 2206 | } |
| 2207 | |
| 2208 | # patch in ProPolice Stack Smashing protection |
| 2209 | do_gcc_SSP_patches() { |
| 2210 | # PARISC has no love ... it's our stack :( |
| 2211 | if [[ $(tc-arch) == "hppa" ]] || \ |
| 2212 | ! want_ssp || \ |
| 2213 | (want_boundschecking && [[ ${HTB_EXCLUSIVE} == "true" ]]) |
| 2214 | then |
| 2215 | do_gcc_stub ssp |
| 2216 | return 0 |
| 2217 | fi |
| 2218 | [[ -z ${SPECS_VER} ]] || return 0 |
| 2219 | |
| 2220 | local ssppatch |
| 2221 | local sspdocs |
| 2222 | |
| 2223 | if [[ -n ${PP_FVER} ]] ; then |
| 2224 | # Etoh keeps changing where files are and what the patch is named |
| 2225 | if tc_version_is_at_least 3.4.1 ; then |
| 2226 | # >3.4.1 uses version in patch name, and also includes docs |
| 2227 | ssppatch="${S}/gcc_${PP_VER}.dif" |
| 2228 | sspdocs="yes" |
| 2229 | elif tc_version_is_at_least 3.4.0 ; then |
| 2230 | # >3.4 put files where they belong and 3_4 uses old patch name |
| 2231 | ssppatch="${S}/protector.dif" |
| 2232 | sspdocs="no" |
| 2233 | elif tc_version_is_at_least 3.2.3 ; then |
| 2234 | # earlier versions have no directory structure or docs |
| 2235 | mv "${S}"/protector.{c,h} "${S}"/gcc |
| 2236 | ssppatch="${S}/protector.dif" |
| 2237 | sspdocs="no" |
| 2238 | fi |
| 2239 | else |
| 2240 | # Just start packaging the damn thing ourselves |
| 2241 | mv "${WORKDIR}"/ssp/protector.{c,h} "${S}"/gcc/ |
| 2242 | ssppatch=${WORKDIR}/ssp/gcc-${PP_GCC_VER}-ssp.patch |
| 2243 | # allow boundschecking and ssp to get along |
| 2244 | (want_boundschecking && [[ -e ${WORKDIR}/ssp/htb-ssp.patch ]]) \ |
| 2245 | && patch -s "${ssppatch}" "${WORKDIR}"/ssp/htb-ssp.patch |
| 2246 | fi |
| 2247 | |
| 2248 | [[ -z ${ssppatch} ]] && die "Sorry, SSP is not supported in this version" |
| 2249 | epatch ${ssppatch} |
| 2250 | |
| 2251 | if [[ ${PN} == "gcc" && ${sspdocs} == "no" ]] ; then |
| 2252 | epatch "${GCC_FILESDIR}"/pro-police-docs.patch |
| 2253 | fi |
| 2254 | |
| 2255 | # Don't build crtbegin/end with ssp |
| 2256 | sed -e 's|^CRTSTUFF_CFLAGS = |CRTSTUFF_CFLAGS = -fno-stack-protector |'\ |
| 2257 | -i gcc/Makefile.in || die "Failed to update crtstuff!" |
| 2258 | |
| 2259 | # if gcc in a stage3 defaults to ssp, is version 3.4.0 and a stage1 is built |
| 2260 | # the build fails building timevar.o w/: |
| 2261 | # cc1: stack smashing attack in function ix86_split_to_parts() |
| 2262 | if use build && tc_version_is_at_least 3.4.0 ; then |
| 2263 | if gcc -dumpspecs | grep -q "fno-stack-protector:" ; then |
| 2264 | epatch "${GCC_FILESDIR}"/3.4.0/gcc-3.4.0-cc1-no-stack-protector.patch |
| 2265 | fi |
| 2266 | fi |
| 2267 | |
| 2268 | BRANDING_GCC_PKGVERSION="${BRANDING_GCC_PKGVERSION}, ssp-${PP_FVER:-${PP_GCC_VER}-${PP_VER}}" |
| 2269 | if want_libssp ; then |
| 2270 | update_gcc_for_libssp |
| 2271 | else |
| 2272 | update_gcc_for_libc_ssp |
| 2273 | fi |
| 2274 | |
| 2275 | # Don't build libgcc with ssp |
| 2276 | sed -e 's|^\(LIBGCC2_CFLAGS.*\)$|\1 -fno-stack-protector|' \ |
| 2277 | -i gcc/Makefile.in || die "Failed to update gcc!" |
| 2278 | } |
| 2279 | |
| 2280 | # If glibc or uclibc has been patched to provide the necessary symbols itself, |
| 2281 | # then lets use those for SSP instead of libgcc. |
| 2282 | update_gcc_for_libc_ssp() { |
| 2283 | if libc_has_ssp ; then |
| 2284 | einfo "Updating gcc to use SSP from libc ..." |
| 2285 | sed -e 's|^\(LIBGCC2_CFLAGS.*\)$|\1 -D_LIBC_PROVIDES_SSP_|' \ |
| 2286 | -i "${S}"/gcc/Makefile.in || die "Failed to update gcc!" |
| 2287 | fi |
| 2288 | } |
| 2289 | |
| 2290 | # a split out non-libc non-libgcc ssp requires additional spec logic changes |
| 2291 | update_gcc_for_libssp() { |
| 2292 | einfo "Updating gcc to use SSP from libssp..." |
| 2293 | sed -e 's|^\(INTERNAL_CFLAGS.*\)$|\1 -D_LIBSSP_PROVIDES_SSP_|' \ |
| 2294 | -i "${S}"/gcc/Makefile.in || die "Failed to update gcc!" |
| 2295 | } |
| 2296 | |
| 2297 | # do various updates to PIE logic |
| 2298 | do_gcc_PIE_patches() { |
| 2299 | if ! want_pie || \ |
| 2300 | (want_boundschecking && [[ ${HTB_EXCLUSIVE} == "true" ]]) |
| 2301 | then |
| 2302 | return 0 |
| 2303 | fi |
| 2304 | |
| 2305 | want_boundschecking \ |
| 2306 | && rm -f "${WORKDIR}"/piepatch/*/*-boundschecking-no.patch* \ |
| 2307 | || rm -f "${WORKDIR}"/piepatch/*/*-boundschecking-yes.patch* |
| 2308 | |
| 2309 | use vanilla && return 0 |
| 2310 | |
| 2311 | if tc_version_is_at_least 4.3.2; then |
| 2312 | guess_patch_type_in_dir "${WORKDIR}"/piepatch/ |
| 2313 | EPATCH_MULTI_MSG="Applying pie patches ..." \ |
| 2314 | epatch "${WORKDIR}"/piepatch/ |
| 2315 | else |
| 2316 | guess_patch_type_in_dir "${WORKDIR}"/piepatch/upstream |
| 2317 | |
| 2318 | # corrects startfile/endfile selection and shared/static/pie flag usage |
| 2319 | EPATCH_MULTI_MSG="Applying upstream pie patches ..." \ |
| 2320 | epatch "${WORKDIR}"/piepatch/upstream |
| 2321 | # adds non-default pie support (rs6000) |
| 2322 | EPATCH_MULTI_MSG="Applying non-default pie patches ..." \ |
| 2323 | epatch "${WORKDIR}"/piepatch/nondef |
| 2324 | # adds default pie support (rs6000 too) if DEFAULT_PIE[_SSP] is defined |
| 2325 | EPATCH_MULTI_MSG="Applying default pie patches ..." \ |
| 2326 | epatch "${WORKDIR}"/piepatch/def |
| 2327 | |
| 2328 | # we want to be able to control the pie patch logic via something other |
| 2329 | # than ALL_CFLAGS... |
| 2330 | sed -e '/^ALL_CFLAGS/iHARD_CFLAGS = ' \ |
| 2331 | -e 's|^ALL_CFLAGS = |ALL_CFLAGS = $(HARD_CFLAGS) |' \ |
| 2332 | -i "${S}"/gcc/Makefile.in |
| 2333 | fi |
| 2334 | |
| 2335 | BRANDING_GCC_PKGVERSION="${BRANDING_GCC_PKGVERSION}, pie-${PIE_VER}" |
| 2336 | } |
| 2337 | |
| 2338 | should_we_gcc_config() { |
| 2339 | # we always want to run gcc-config if we're bootstrapping, otherwise |
| 2340 | # we might get stuck with the c-only stage1 compiler |
| 2341 | use bootstrap && return 0 |
| 2342 | use build && return 0 |
| 2343 | |
| 2344 | # if the current config is invalid, we definitely want a new one |
| 2345 | # Note: due to bash quirkiness, the following must not be 1 line |
| 2346 | local curr_config |
| 2347 | curr_config=$(env -i ROOT="${ROOT}" gcc-config -c ${CTARGET} 2>&1) || return 0 |
| 2348 | |
| 2349 | # if the previously selected config has the same major.minor (branch) as |
| 2350 | # the version we are installing, then it will probably be uninstalled |
| 2351 | # for being in the same SLOT, make sure we run gcc-config. |
| 2352 | local curr_config_ver=$(env -i ROOT="${ROOT}" gcc-config -S ${curr_config} | awk '{print $2}') |
| 2353 | |
| 2354 | local curr_branch_ver=$(get_version_component_range 1-2 ${curr_config_ver}) |
| 2355 | |
| 2356 | # If we're using multislot, just run gcc-config if we're installing |
| 2357 | # to the same profile as the current one. |
| 2358 | use multislot && return $([[ ${curr_config_ver} == ${GCC_CONFIG_VER} ]]) |
| 2359 | |
| 2360 | if [[ ${curr_branch_ver} == ${GCC_BRANCH_VER} ]] ; then |
| 2361 | return 0 |
| 2362 | else |
| 2363 | # if we're installing a genuinely different compiler version, |
| 2364 | # we should probably tell the user -how- to switch to the new |
| 2365 | # gcc version, since we're not going to do it for him/her. |
| 2366 | # We don't want to switch from say gcc-3.3 to gcc-3.4 right in |
| 2367 | # the middle of an emerge operation (like an 'emerge -e world' |
| 2368 | # which could install multiple gcc versions). |
| 2369 | einfo "The current gcc config appears valid, so it will not be" |
| 2370 | einfo "automatically switched for you. If you would like to" |
| 2371 | einfo "switch to the newly installed gcc version, do the" |
| 2372 | einfo "following:" |
| 2373 | echo |
| 2374 | einfo "gcc-config ${CTARGET}-${GCC_CONFIG_VER}" |
| 2375 | einfo "source /etc/profile" |
| 2376 | echo |
| 2377 | ebeep |
| 2378 | return 1 |
| 2379 | fi |
| 2380 | } |
| 2381 | |
| 2382 | do_gcc_config() { |
| 2383 | if ! should_we_gcc_config ; then |
| 2384 | env -i ROOT="${ROOT}" gcc-config --use-old --force |
| 2385 | return 0 |
| 2386 | fi |
| 2387 | |
| 2388 | local current_gcc_config="" current_specs="" use_specs="" |
| 2389 | |
| 2390 | current_gcc_config=$(env -i ROOT="${ROOT}" gcc-config -c ${CTARGET} 2>/dev/null) |
| 2391 | if [[ -n ${current_gcc_config} ]] ; then |
| 2392 | # figure out which specs-specific config is active |
| 2393 | current_specs=$(gcc-config -S ${current_gcc_config} | awk '{print $3}') |
| 2394 | [[ -n ${current_specs} ]] && use_specs=-${current_specs} |
| 2395 | fi |
| 2396 | if [[ -n ${use_specs} ]] && \ |
| 2397 | [[ ! -e ${ROOT}/etc/env.d/gcc/${CTARGET}-${GCC_CONFIG_VER}${use_specs} ]] |
| 2398 | then |
| 2399 | ewarn "The currently selected specs-specific gcc config," |
| 2400 | ewarn "${current_specs}, doesn't exist anymore. This is usually" |
| 2401 | ewarn "due to enabling/disabling hardened or switching to a version" |
| 2402 | ewarn "of gcc that doesnt create multiple specs files. The default" |
| 2403 | ewarn "config will be used, and the previous preference forgotten." |
| 2404 | ebeep |
| 2405 | epause |
| 2406 | use_specs="" |
| 2407 | fi |
| 2408 | |
| 2409 | gcc-config ${CTARGET}-${GCC_CONFIG_VER}${use_specs} |
| 2410 | } |
| 2411 | |
| 2412 | should_we_eselect_compiler() { |
| 2413 | # we always want to run gcc-config if we're bootstrapping, otherwise |
| 2414 | # we might get stuck with the c-only stage1 compiler |
| 2415 | use bootstrap && return 0 |
| 2416 | use build && return 0 |
| 2417 | |
| 2418 | # if the current config is invalid, we definitely want a new one |
| 2419 | # Note: due to bash quirkiness, the following must not be 1 line |
| 2420 | local curr_config |
| 2421 | curr_config=$(env -i eselect compiler show ${CTARGET} 2>&1) || return 0 |
| 2422 | [[ -z ${curr_config} || ${curr_config} == "(none)" ]] && return 0 |
| 2423 | |
| 2424 | # if the previously selected config has the same major.minor (branch) as |
| 2425 | # the version we are installing, then it will probably be uninstalled |
| 2426 | # for being in the same SLOT, make sure we run gcc-config. |
| 2427 | local curr_config_ver=$(echo ${curr_config} | cut -f1 -d/ | awk -F - '{ print $5 }') |
| 2428 | local curr_branch_ver=$(get_version_component_range 1-2 ${curr_config_ver}) |
| 2429 | |
| 2430 | # If we're using multislot, just run gcc-config if we're installing |
| 2431 | # to the same profile as the current one. |
| 2432 | use multislot && return $([[ ${curr_config_ver} == ${GCC_CONFIG_VER} ]]) |
| 2433 | |
| 2434 | if [[ ${curr_branch_ver} == ${GCC_BRANCH_VER} ]] ; then |
| 2435 | return 0 |
| 2436 | else |
| 2437 | # if we're installing a genuinely different compiler version, |
| 2438 | # we should probably tell the user -how- to switch to the new |
| 2439 | # gcc version, since we're not going to do it for him/her. |
| 2440 | # We don't want to switch from say gcc-3.3 to gcc-3.4 right in |
| 2441 | # the middle of an emerge operation (like an 'emerge -e world' |
| 2442 | # which could install multiple gcc versions). |
| 2443 | einfo "The current gcc config appears valid, so it will not be" |
| 2444 | einfo "automatically switched for you. If you would like to" |
| 2445 | einfo "switch to the newly installed gcc version, do the" |
| 2446 | einfo "following:" |
| 2447 | echo |
| 2448 | einfo "eselect compiler set <profile>" |
| 2449 | echo |
| 2450 | ebeep |
| 2451 | return 1 |
| 2452 | fi |
| 2453 | } |
| 2454 | |
| 2455 | do_eselect_compiler() { |
| 2456 | if ! should_we_eselect_compiler; then |
| 2457 | eselect compiler update |
| 2458 | return 0 |
| 2459 | fi |
| 2460 | |
| 2461 | for abi in $(get_all_abis) ; do |
| 2462 | local ctarget=$(get_abi_CHOST ${abi}) |
| 2463 | local current_specs=$(env -i eselect compiler show ${ctarget} | cut -f2 -d/) |
| 2464 | |
| 2465 | if [[ -n ${current_specs} && ${current_specs} != "(none)" ]] && eselect compiler set ${CTARGET}-${GCC_CONFIG_VER}/${current_specs} &> /dev/null; then |
| 2466 | einfo "The following compiler profile has been activated based on your previous profile:" |
| 2467 | einfo "${CTARGET}-${GCC_CONFIG_VER}/${current_specs}" |
| 2468 | else |
| 2469 | # We couldn't choose based on the old specs, so fall back on vanilla/hardened based on USE |
| 2470 | |
| 2471 | local spec |
| 2472 | if use hardened ; then |
| 2473 | spec="hardened" |
| 2474 | else |
| 2475 | spec="vanilla" |
| 2476 | fi |
| 2477 | |
| 2478 | local profile |
| 2479 | local isset=0 |
| 2480 | for profile in "${current_specs%-*}-${spec}" "${abi}-${spec}" "${spec}" ; do |
| 2481 | if eselect compiler set ${CTARGET}-${GCC_CONFIG_VER}/${profile} &> /dev/null ; then |
| 2482 | ewarn "The newly installed version of gcc does not have a profile that matches the name of your" |
| 2483 | ewarn "currently selected profile for ${ctarget}, so we have enabled the following instead:" |
| 2484 | ewarn "${CTARGET}-${GCC_CONFIG_VER}/${profile}" |
| 2485 | ewarn "If this is incorrect, please use 'eselect compiler set' to" |
| 2486 | ewarn "select another profile." |
| 2487 | |
| 2488 | isset=1 |
| 2489 | break |
| 2490 | fi |
| 2491 | done |
| 2492 | |
| 2493 | if [[ ${isset} == 0 ]] ; then |
| 2494 | eerror "We were not able to automatically set the current compiler for ${ctarget}" |
| 2495 | eerror "to your newly emerged gcc. Please use 'eselect compiler set'" |
| 2496 | eerror "to select your compiler." |
| 2497 | fi |
| 2498 | fi |
| 2499 | done |
| 2500 | } |
| 2501 | |
| 2502 | # This function allows us to gentoo-ize gcc's version number and bugzilla |
| 2503 | # URL without needing to use patches. |
| 2504 | gcc_version_patch() { |
| 2505 | # gcc-4.3+ has configure flags (whoo!) |
| 2506 | tc_version_is_at_least 4.3 && return 0 |
| 2507 | |
| 2508 | local version_string=${GCC_CONFIG_VER} |
| 2509 | [[ -n ${BRANCH_UPDATE} ]] && version_string="${version_string} ${BRANCH_UPDATE}" |
| 2510 | |
| 2511 | einfo "patching gcc version: ${version_string} (${BRANDING_GCC_PKGVERSION})" |
| 2512 | |
| 2513 | if grep -qs VERSUFFIX "${S}"/gcc/version.c ; then |
| 2514 | sed -i -e "s~VERSUFFIX \"\"~VERSUFFIX \" (${BRANDING_GCC_PKGVERSION})\"~" \ |
| 2515 | "${S}"/gcc/version.c || die "failed to update VERSUFFIX with Gentoo branding" |
| 2516 | else |
| 2517 | version_string="${version_string} (${BRANDING_GCC_PKGVERSION})" |
| 2518 | sed -i -e "s~\(const char version_string\[\] = \"\).*\(\".*\)~\1$version_string\2~" \ |
| 2519 | "${S}"/gcc/version.c || die "failed to update version.c with Gentoo branding." |
| 2520 | fi |
| 2521 | sed -i -e 's~gcc\.gnu\.org\/bugs\.html~bugs\.gentoo\.org\/~' \ |
| 2522 | "${S}"/gcc/version.c || die "Failed to change the bug URL" |
| 2523 | } |
| 2524 | |
| 2525 | # The purpose of this DISGUSTING gcc multilib hack is to allow 64bit libs |
| 2526 | # to live in lib instead of lib64 where they belong, with 32bit libraries |
| 2527 | # in lib32. This hack has been around since the beginning of the amd64 port, |
| 2528 | # and we're only now starting to fix everything that's broken. Eventually |
| 2529 | # this should go away. |
| 2530 | # |
| 2531 | # Travis Tilley <lv@gentoo.org> (03 Sep 2004) |
| 2532 | # |
| 2533 | disgusting_gcc_multilib_HACK() { |
| 2534 | local config |
| 2535 | local libdirs |
| 2536 | if has_multilib_profile ; then |
| 2537 | case $(tc-arch) in |
| 2538 | amd64) |
| 2539 | config="i386/t-linux64" |
| 2540 | libdirs="../$(get_abi_LIBDIR amd64) ../$(get_abi_LIBDIR x86)" \ |
| 2541 | ;; |
| 2542 | ppc64) |
| 2543 | config="rs6000/t-linux64" |
| 2544 | libdirs="../$(get_abi_LIBDIR ppc64) ../$(get_abi_LIBDIR ppc)" \ |
| 2545 | ;; |
| 2546 | esac |
| 2547 | else |
| 2548 | die "Your profile is no longer supported by portage." |
| 2549 | fi |
| 2550 | |
| 2551 | einfo "updating multilib directories to be: ${libdirs}" |
| 2552 | sed -i -e "s:^MULTILIB_OSDIRNAMES.*:MULTILIB_OSDIRNAMES = ${libdirs}:" "${S}"/gcc/config/${config} |
| 2553 | } |
| 2554 | |
| 2555 | disable_multilib_libjava() { |
| 2556 | if is_gcj ; then |
| 2557 | # We dont want a multilib libjava, so lets use this hack taken from fedora |
| 2558 | pushd "${S}" > /dev/null |
| 2559 | sed -i -e 's/^all: all-redirect/ifeq (\$(MULTISUBDIR),)\nall: all-redirect\nelse\nall:\n\techo Multilib libjava build disabled\nendif/' libjava/Makefile.in |
| 2560 | sed -i -e 's/^install: install-redirect/ifeq (\$(MULTISUBDIR),)\ninstall: install-redirect\nelse\ninstall:\n\techo Multilib libjava install disabled\nendif/' libjava/Makefile.in |
| 2561 | sed -i -e 's/^check: check-redirect/ifeq (\$(MULTISUBDIR),)\ncheck: check-redirect\nelse\ncheck:\n\techo Multilib libjava check disabled\nendif/' libjava/Makefile.in |
| 2562 | sed -i -e 's/^all: all-recursive/ifeq (\$(MULTISUBDIR),)\nall: all-recursive\nelse\nall:\n\techo Multilib libjava build disabled\nendif/' libjava/Makefile.in |
| 2563 | sed -i -e 's/^install: install-recursive/ifeq (\$(MULTISUBDIR),)\ninstall: install-recursive\nelse\ninstall:\n\techo Multilib libjava install disabled\nendif/' libjava/Makefile.in |
| 2564 | sed -i -e 's/^check: check-recursive/ifeq (\$(MULTISUBDIR),)\ncheck: check-recursive\nelse\ncheck:\n\techo Multilib libjava check disabled\nendif/' libjava/Makefile.in |
| 2565 | popd > /dev/null |
| 2566 | fi |
| 2567 | } |
| 2568 | |
| 2569 | # make sure the libtool archives have libdir set to where they actually |
| 2570 | # -are-, and not where they -used- to be. also, any dependencies we have |
| 2571 | # on our own .la files need to be updated. |
| 2572 | fix_libtool_libdir_paths() { |
| 2573 | pushd "${D}" >/dev/null |
| 2574 | |
| 2575 | pushd "./${1}" >/dev/null |
| 2576 | local dir="${PWD#${D%/}}" |
| 2577 | local allarchives=$(echo *.la) |
| 2578 | allarchives="\(${allarchives// /\\|}\)" |
| 2579 | popd >/dev/null |
| 2580 | |
| 2581 | sed -i \ |
| 2582 | -e "/^libdir=/s:=.*:='${dir}':" \ |
| 2583 | ./${dir}/*.la |
| 2584 | sed -i \ |
| 2585 | -e "/^dependency_libs=/s:/[^ ]*/${allarchives}:${LIBPATH}/\1:g" \ |
| 2586 | $(find ./${PREFIX}/lib* -maxdepth 3 -name '*.la') \ |
| 2587 | ./${dir}/*.la |
| 2588 | |
| 2589 | popd >/dev/null |
| 2590 | } |
| 2591 | |
| 2592 | is_multilib() { |
| 2593 | [[ ${GCCMAJOR} < 3 ]] && return 1 |
| 2594 | case ${CTARGET} in |
| 2595 | mips64*|powerpc64*|s390x*|sparc*|x86_64*) |
| 2596 | has_multilib_profile || use multilib ;; |
| 2597 | *-*-solaris*) use multilib ;; |
| 2598 | *-apple-darwin*) use multilib ;; |
| 2599 | *) false ;; |
| 2600 | esac |
| 2601 | } |
| 2602 | |
| 2603 | is_cxx() { |
| 2604 | gcc-lang-supported 'c++' || return 1 |
| 2605 | ! use nocxx |
| 2606 | } |
| 2607 | |
| 2608 | is_d() { |
| 2609 | gcc-lang-supported d || return 1 |
| 2610 | use d |
| 2611 | } |
| 2612 | |
| 2613 | is_f77() { |
| 2614 | gcc-lang-supported f77 || return 1 |
| 2615 | use fortran |
| 2616 | } |
| 2617 | |
| 2618 | is_f95() { |
| 2619 | gcc-lang-supported f95 || return 1 |
| 2620 | use fortran |
| 2621 | } |
| 2622 | |
| 2623 | is_fortran() { |
| 2624 | gcc-lang-supported fortran || return 1 |
| 2625 | use fortran |
| 2626 | } |
| 2627 | |
| 2628 | is_gcj() { |
| 2629 | gcc-lang-supported java || return 1 |
| 2630 | use gcj |
| 2631 | } |
| 2632 | |
| 2633 | is_libffi() { |
| 2634 | has libffi ${IUSE} || return 1 |
| 2635 | use libffi |
| 2636 | } |
| 2637 | |
| 2638 | is_objc() { |
| 2639 | gcc-lang-supported objc || return 1 |
| 2640 | use objc |
| 2641 | } |
| 2642 | |
| 2643 | is_objcxx() { |
| 2644 | gcc-lang-supported 'obj-c++' || return 1 |
| 2645 | use objc++ |
| 2646 | } |
| 2647 | |
| 2648 | is_ada() { |
| 2649 | gcc-lang-supported ada || return 1 |
| 2650 | use ada |
| 2651 | } |
| 2652 | |
| 2653 | is_treelang() { |
| 2654 | has boundschecking ${IUSE} && use boundschecking && return 1 #260532 |
| 2655 | is_crosscompile && return 1 #199924 |
| 2656 | gcc-lang-supported treelang || return 1 |
| 2657 | #use treelang |
| 2658 | return 0 |
| 2659 | } |