Skip to content
Browse files

FL-719, FL-692: gcc-4.8.1.ebuild, masked. Backported improvements/fix…

…es to gcc-4.6.4-r1
  • Loading branch information...
1 parent 69c96f5 commit 254c7d4c1c22f8ebf373ba74561fe87a7ad82090 @danielrobbins danielrobbins committed Sep 12, 2013
View
2 sys-devel/gcc/Manifest
@@ -37,6 +37,8 @@ DIST gcc-4.8.0-patches-1.1.tar.bz2 14191 SHA256 900989c5db0f657a332d3b788ff08f48
DIST gcc-4.8.0-piepatches-v0.5.5.tar.bz2 14278 SHA256 644727a87c372c9e371b823a43432e39257716dcb9e49fb61b69692beb456639 SHA512 780d12fc33b491b964cc20029e9cb7648ce789e13d731bfe5305a130ce4d69da9f53f3acccf8d28cf0e8eafa41e90bd73fcffbc52f0d6d20b4ba89868267f777 WHIRLPOOL 8f82402850059124a049aa21a19cb7d83c4da27695a4c1eaa58bf0e45d638344737d66cbdb07ecd29215a48ec67cad79ae3685069d7574571d04f36ef972a853
DIST gcc-4.8.0-uclibc-patches-1.0.tar.bz2 3010 SHA256 0300927d938d5d0baccf7cc63d6be71dbb73a5c9d1efaf9f06bace87d7267dcd SHA512 25b82b0860c14b876920a18257b6348161b768e9583eabb5179ed3a3d924bb74fef615ad458beff6c89bc4d0cf723bbd9702cd8bca9e73b60adc82c196def382 WHIRLPOOL 5ae9e33dc382c7d1816d92d0a6b55191f922dec9f023bab0bcb51cbb0ce267c27874670ddc484144c122a204319b55a7dbe0f10c6a13e6390c4015f134d8b712
DIST gcc-4.8.0.tar.bz2 86663646 SHA256 b037fe5132b71ecad2ea7141ec92292b5d32427bf90fd90cde432b1d5abacc2c SHA512 8a59f1a67e557eb719961a217bdb6a05b4b3abfc792f4bddee536c46fc3cc8472126e0f7531fa473acfce525a59bbd581ade97d068caf7308dfb2296f8861826 WHIRLPOOL ad966de5e75c817ea4aec9076a16198e91108e1e67c413bda839235692cbd1626e85a5e76206b8889884790d4d282650662a3e0b024893a3422bf0bfc04b46a2
+DIST gcc-4.8.1-piepatches-v0.5.7.tar.bz2 14260 SHA256 3edd9c0592716a5cd544af470c61448a0c5cb81d15ce0bfcf77e660a15546e60 SHA512 e471c852340cac7acef4540d0e2c266039e284952ec14cdb39cc732fd3572fed47f4912389f658916d9cb300ecd29d52734f2b7c003ef7acb33567af0211688c WHIRLPOOL fb95580a4969f3b447a4097d0ff86d243c71546e145ed7c290110a55339c2367fee2cb3f36b6a8c64e0f07d04c7a512f191eb2d7ab9e93aa759a8fd01d514317
+DIST gcc-4.8.1.tar.bz2 86753166 SHA256 545b44be3ad9f2c4e90e6880f5c9d4f0a8f0e5f67e1ffb0d45da9fa01bb05813 SHA512 1becc874aad77a469069b6d9da4158aae9e013e24afa9364fe4feff9a5094d0673ee7694b3840e892c860f73a56b3ece6174338a8214438c42b9f86dd6c35ea7 WHIRLPOOL c706fa4445bbf4b9503c78b7e03da6adeadc3c736d208edb65059ddf23a08875dfa1ac92ccaafb3dd72ecbceb15a0de5814c62104fb94f99032232fbc50ab82c
DIST gdc-0.24-src.tar.bz2 1012099 SHA256 cc6a97c76c9e6db31e76ff97014d24b3d43e21f018a3c6218e3fb2a4500fc79a
DIST gmp-5.1.1.tar.xz 1812988 SHA256 4bd64d782fdeb61aeed45b434fca5246d66baa9de76f87cba30c38460d8834c2 SHA512 4cc3307411eb2144e87b791ee2f52e0020711638f911dfa3cc5929a57eda5ac7d9ca10c1c0bb75c96afc7ff7a9c6ad165bc87409b036c562867b4e5da15ba571 WHIRLPOOL 8a7afe06d530a15edb75a0c37c8497d1ab209dfeffebd44aecfcfe6b75586c182384cfdf8ea9b696ce968aed04944ec7c1c271730b65c34b2e3504d26565240e
DIST mpc-1.0.1.tar.gz 624125 SHA256 ed5a815cfea525dc778df0cb37468b9c1b554aaf30d9328b1431ca705b7400ff SHA512 fa381e75999bba626ba08d73225285b03c6d2f6cca87881b28829925d1624eaed1c9b544f75e7281cf5d8dcdd7831025a4eafc05f88f13375f9e08239a8a9303 WHIRLPOOL ddc857d361b10c7702e2a6bfec3ecb8538f80ae22a41097caaad6f767f035e2a4af2317fe9685a93c6f3d9bcdb0982db042eeb073f7b0e71a72500a5ef07630c
View
87 sys-devel/gcc/files/gcc-spec-env-r1.patch
@@ -0,0 +1,87 @@
+2013-08-22 Magnus Granberg <zorry@gentoo.org>
+
+ * gcc/gcc.c (main): Add support for external spec file via the GCC_SPECS env var
+ and move the process of the user specifed specs.
+
+ This allows us to easily control pie/ssp defaults with gcc-config profiles.
+ Original patch by Rob Holland
+ Extended to support multiple entries separated by ':' by Kevin F. Quinn
+ Modified to use getenv instead of poisoned GET_ENVIRONMENT by Ryan Hill
+ Modified to process the GCC_SPECS env var befor DRIVER_SELF_SPECS by Magnus Granberg
+
+--- gcc-4.8-20130210/gcc/gcc.c 2013-02-05 16:55:31.000000000 +0100
++++ gcc-4.8-20130210-work/gcc/gcc.c 2013-07-26 02:32:14.625089864 +0200
+@@ -6427,6 +6428,48 @@ main (int argc, char **argv)
+ do_option_spec (option_default_specs[i].name,
+ option_default_specs[i].spec);
+
++#if !(defined (__MSDOS__) || defined (OS2) || defined (VMS) || defined (WIN32))
++ /* Add specs listed in GCC_SPECS. Note; in the process of separating
++ * each spec listed, the string is overwritten at token boundaries
++ * (':') with '\0', an effect of strtok_r().
++ */
++ specs_file = getenv ("GCC_SPECS");
++ if (specs_file && (strlen(specs_file) > 0))
++ {
++ char *spec, *saveptr;
++ for (spec=strtok_r(specs_file,":",&saveptr);
++ spec!=NULL;
++ spec=strtok_r(NULL,":",&saveptr))
++ {
++ struct user_specs *user = (struct user_specs *)
++ xmalloc (sizeof (struct user_specs));
++ user->next = (struct user_specs *) 0;
++ user->filename = spec;
++ if (user_specs_tail)
++ user_specs_tail->next = user;
++ else
++ user_specs_head = user;
++ user_specs_tail = user;
++ }
++ }
++#endif
++ /* Process any user specified specs in the order given on the command
++ * line. */
++ for (uptr = user_specs_head; uptr; uptr = uptr->next)
++ {
++ char *filename = find_a_file (&startfile_prefixes, uptr->filename,
++ R_OK, true);
++ read_specs (filename ? filename : uptr->filename, false, true);
++ }
++ /* Process any user self specs. */
++ {
++ struct spec_list *sl;
++ for (sl = specs; sl; sl = sl->next)
++ if (sl->name_len == sizeof "self_spec" - 1
++ && !strcmp (sl->name, "self_spec"))
++ do_self_spec (*sl->ptr_spec);
++ }
++
+ /* Process DRIVER_SELF_SPECS, adding any new options to the end
+ of the command line. */
+
+@@ -6535,24 +6578,6 @@ main (int argc, char **argv)
+ PREFIX_PRIORITY_LAST, 0, 1);
+ }
+
+- /* Process any user specified specs in the order given on the command
+- line. */
+- for (uptr = user_specs_head; uptr; uptr = uptr->next)
+- {
+- char *filename = find_a_file (&startfile_prefixes, uptr->filename,
+- R_OK, true);
+- read_specs (filename ? filename : uptr->filename, false, true);
+- }
+-
+- /* Process any user self specs. */
+- {
+- struct spec_list *sl;
+- for (sl = specs; sl; sl = sl->next)
+- if (sl->name_len == sizeof "self_spec" - 1
+- && !strcmp (sl->name, "self_spec"))
+- do_self_spec (*sl->ptr_spec);
+- }
+-
+ if (compare_debug)
+ {
+ enum save_temps save;
View
394 sys-devel/gcc/gcc-4.6.4-r1.ebuild
@@ -0,0 +1,394 @@
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=5
+
+inherit multilib eutils
+
+# Ebuild notes:
+#
+# This is a simplified Funtoo gcc ebuild. It has been designed to have a reduced dependency
+# footprint, so that libgmp, mpfr and mpc are built as part of the gcc build process and
+# are not external dependencies. This makes upgrading these dependencies easier and
+# improves upgradability of Funtoo Linux systems, and solves various thorny build issues.
+#
+# Also, this gcc ebuild no longer uses toolchain.eclass which improves the maintainability
+# of the ebuild itself as it is less complex.
+#
+# -- Daniel Robbins, Apr 19, 2013.
+#
+# Other important notes on this ebuild:
+#
+# x86/amd64 architecture support only (for now).
+# mudflap is enabled by default.
+# lto is disabled by default.
+# test is not currently supported.
+# objc-gc is enabled by default when objc is enabled.
+# gcj is not currently supported by this ebuild.
+# graphite is not currently supported by this ebuild.
+# multislot is a good USE flag to set when testing this ebuild;
+# (It allows this gcc to co-exist along identical x.y versions.)
+# hardened is now supported, but we have deprecated the nopie and
+# nossp USE flags from gentoo.
+
+# Note: multi-stage bootstrapping is currently not being performed.
+
+RESTRICT="strip"
+FEATURES=${FEATURES/multilib-strict/}
+
+IUSE="ada cxx fortran f77 f95 objc objc++ openmp" # languages
+IUSE="$IUSE multislot nls nptl vanilla doc multilib altivec libssp hardened" # other stuff
+
+if use multislot; then
+ SLOT="${PV}"
+else
+ SLOT="${PV%.*}"
+fi
+
+#Not used:
+#PATCH_VER="1.6"
+
+#Hardened Support:
+#
+# PIE_VER specifies the version of the PIE patches that will be downloaded and applied.
+#
+# SPECS_VER and SPECS_GCC_VER specifies the version of the "minispecs" files that will
+# be used. Minispecs are compiler definitions that are installed that can be used to
+# select various permutations of the hardened compiler, as well as a non-hardened
+# compiler, and are typically selected via Gentoo's gcc-config tool.
+
+PIE_VER="0.5.2"
+SPECS_VER="0.2.0"
+SPECS_GCC_VER="4.4.3"
+SPECS_A="gcc-${SPECS_GCC_VER}-specs-${SPECS_VER}.tar.bz2"
+PIE_A="gcc-${PV}-piepatches-v${PIE_VER}.tar.bz2"
+
+GMP_VER="5.1.1"
+MPFR_VER="3.1.2"
+MPC_VER="1.0.1"
+
+GCC_A="gcc-${PV}.tar.bz2"
+SRC_URI="mirror://gnu/gcc/gcc-${PV}/${GCC_A}"
+SRC_URI="$SRC_URI http://www.multiprecision.org/mpc/download/mpc-${MPC_VER}.tar.gz"
+SRC_URI="$SRC_URI http://www.mpfr.org/mpfr-${MPFR_VER}/mpfr-${MPFR_VER}.tar.xz"
+SRC_URI="$SRC_URI mirror://gnu/gmp/gmp-${GMP_VER}.tar.xz"
+
+#Hardened Support:
+SRC_URI="$SRC_URI hardened? ( mirror://gentoo/${SPECS_A} mirror://gentoo/${PIE_A} )"
+
+DESCRIPTION="The GNU Compiler Collection"
+
+LICENSE="GPL-3+ LGPL-3+ || ( GPL-3+ libgcc libstdc++ gcc-runtime-library-exception-3.1 ) FDL-1.3+"
+KEYWORDS="*"
+
+RDEPEND="sys-libs/zlib nls? ( sys-devel/gettext ) virtual/libiconv"
+DEPEND="${RDEPEND} >=sys-devel/bison-1.875 >=sys-devel/flex-2.5.4 elibc_glibc? ( >=sys-libs/glibc-2.8 ) >=sys-devel/binutils-2.18"
+PDEPEND=">=sys-devel/gcc-config-1.5 elibc_glibc? ( >=sys-libs/glibc-2.8 )"
+
+pkg_setup() {
+ unset GCC_SPECS # we don't want to use the installed compiler's specs to build gcc!
+ unset LANGUAGES #265283
+ PREFIX=/usr
+ CTARGET=$CHOST
+ GCC_BRANCH_VER=${SLOT}
+ GCC_CONFIG_VER=${PV}
+ DATAPATH=${PREFIX}/share/gcc-data/${CTARGET}/${GCC_CONFIG_VER}
+ BINPATH=${PREFIX}/${CTARGET}/gcc-bin/${GCC_CONFIG_VER}
+ LIBPATH=${PREFIX}/lib/gcc/${CTARGET}/${GCC_CONFIG_VER}
+ STDCXX_INCDIR=${LIBPATH}/include/g++-v${GCC_BRANCH_VER}
+}
+
+src_unpack() {
+ unpack $GCC_A
+ ( unpack mpc-${MPC_VER}.tar.gz && mv ${WORKDIR}/mpc-${MPC_VER} ${S}/mpc ) || die "mpc setup fail"
+ ( unpack mpfr-${MPFR_VER}.tar.xz && mv ${WORKDIR}/mpfr-${MPFR_VER} ${S}/mpfr ) || die "mpfr setup fail"
+ ( unpack gmp-${GMP_VER}.tar.xz && mv ${WORKDIR}/gmp-${GMP_VER} ${S}/gmp ) || die "gmp setup fail"
+ if use hardened; then
+ unpack $PIE_A || die "pie unpack fail"
+ unpack $SPECS_A || die "specs unpack fail"
+ fi
+ cd $S
+ mkdir ${WORKDIR}/objdir
+}
+
+src_prepare() {
+
+ # TODO - APPLY PIE PATCHES
+ # TODO - ALL_CFLAGS vs HARD_CFLAGS (see do_gcc_PIE_patches() in toolchain.eclass)
+
+ # For some reason, when upgrading gcc, the gcc Makefile will install stuff
+ # like crtbegin.o into a subdirectory based on the name of the currently-installed
+ # gcc version, rather than *our* gcc version. Manually fix this:
+
+ sed -i -e "s/^version :=.*/version := ${GCC_CONFIG_VER}/" ${S}/libgcc/Makefile.in || die
+
+ # The following patch allows pie/ssp specs to be changed via environment
+ # variable, which is needed for gcc-config to allow switching of compilers:
+
+ [[ ${CHOST} == ${CTARGET} ]] && cat "${FILESDIR}"/gcc-spec-env.patch | patch -p1 || die "patch fail"
+
+ # We use --enable-version-specific-libs with ./configure. This
+ # option is designed to place all our libraries into a sub-directory
+ # rather than /usr/lib*. However, this option, even through 4.8.0,
+ # does not work 100% correctly without a small fix for
+ # libgcc_s.so. See: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32415.
+ # So, we apply a small patch to get this working:
+
+ cat "${FILESDIR}"/gcc-4.6.4-fix-libgcc-s-path-with-vsrl.patch | patch -p1 || die "patch fail"
+
+ # gcc-4.6.4 seems to have trouble building libgfortran - it can't find the gfortran compiler it built.
+ # Here is hack #1 to make that happen - hard-code the configure script with the full path to gfortran:
+
+ sed -i -e "s:^FC=.*:FC=${WORKDIR}/objdir/gcc/gfortran:" ${WORKDIR}/gcc-${PV}/libgfortran/configure || die libgfortran prep
+
+ if use hardened; then
+ local gcc_hard_flags="-DEFAULT_RELRO -DEFAULT_BIND_NOW -DEFAULT_PIE_SSP"
+ sed -i -e "/^HARD_CFLAGS = /s|=|= ${gcc_hard_flags} |" "${S}"/gcc/Makefile.in || die
+ EPATCH_MULTI_MSG="Applying PIE patches..." \
+ epatch "${WORKDIR}"/piepatch/*.patch
+ fi
+}
+
+src_configure() {
+
+ # Determine language support:
+ local confgcc
+ local GCC_LANG="c"
+ use cxx && GCC_LANG+=",c++" && confgcc+=" --enable-libstdcxx-time"
+ if use objc; then
+ GCC_LANG+=",objc"
+ confgcc+=" --enable-objc-gc"
+ use objc++ && GCC_LANG+=",obj-c++"
+ fi
+ use fortran && GCC_LANG+=",fortran" || confgcc+=" --disable-libquadmath"
+ use f77 && GCC_LANG+=",f77"
+ use f95 && GCC_LANG+=",f95"
+ use ada && GCC_LANG+=",ada"
+ confgcc+=" $(use_enable openmp libgomp)"
+ confgcc+=" --enable-languages=${GCC_LANG} --disable-libgcj"
+ confgcc+=" $(use_enable hardened esp)"
+
+ use libssp || export gcc_cv_libc_provides_ssp=yes
+
+ local branding="Funtoo"
+ if use hardened; then
+ branding="$branding Hardened ${PVR}, pie-${PIE_VER}"
+ else
+ branding="$branding ${PVR}"
+ fi
+
+ cd ${WORKDIR}/objdir && ../gcc-${PV}/configure \
+ $(use_enable libssp) \
+ $(use_enable multilib) \
+ --enable-version-specific-runtime-libs \
+ --enable-libmudflap \
+ --prefix=${PREFIX} \
+ --bindir=${BINPATH} \
+ --includedir=${LIBPATH}/include \
+ --datadir=${DATAPATH} \
+ --mandir=${DATAPATH}/man \
+ --infodir=${DATAPATH}/info \
+ --with-gxx-include-dir=${STDCXX_INCDIR} \
+ --enable-__cxa_atexit \
+ --enable-clocale=gnu \
+ --host=$CHOST \
+ --build=$CHOST \
+ --disable-ppl \
+ --disable-cloog \
+ --with-system-zlib \
+ --enable-obsolete \
+ --disable-werror \
+ --enable-secureplt \
+ --disable-lto \
+ --with-bugurl=http://bugs.funtoo.org \
+ --with-pkgversion="$branding" \
+ --with-mpfr-include=${S}/mpfr/src \
+ --with-mpfr-lib=${WORKDIR}/objdir/mpfr/src/.libs \
+ $confgcc \
+ || die "configure fail"
+
+ # The --with-mpfr* lines above are used so that gcc-4.6.4 can find mpfr-3.1.2.
+ # It can find 2.4.2 with no problem automatically but needs help with newer versions
+ # due to mpfr dir structure changes. We look for includes in the source directory,
+ # and libraries in the build (objdir) directory.
+}
+
+src_compile() {
+ cd $WORKDIR/objdir
+ unset ABI
+
+ # gcc-4.6.4 seems to have trouble building libgfortran - it can't find the gfortran compiler it built.
+ # Here is hack #2 to make that happen: expand PATH so that gfortran can find other tools it needs:
+
+ export PATH="$WORKDIR/objdir/gcc:$PATH"
+ emake LIBPATH="${LIBPATH}" bootstrap-lean || die "compile fail"
+}
+
+create_gcc_env_entry() {
+ dodir /etc/env.d/gcc
+ local gcc_envd_base="/etc/env.d/gcc/${CTARGET}-${GCC_CONFIG_VER}"
+ local gcc_envd_file="${D}${gcc_envd_base}"
+ if [ -z $1 ]; then
+ gcc_specs_file=""
+ else
+ gcc_envd_file="$gcc_envd_file-$1"
+ gcc_specs_file="${LIBPATH}/$1.specs"
+ fi
+ cat <<-EOF > ${gcc_envd_file}
+ GCC_PATH="${BINPATH}"
+ LDPATH="${LIBPATH}:${LIBPATH}/32"
+ MANPATH="${DATAPATH}/man"
+ INFOPATH="${DATAPATH}/info"
+ STDCXX_INCDIR="${STDCXX_INCDIR##*/}"
+ GCC_SPECS="${gcc_specs_file}"
+ EOF
+}
+
+linkify_compiler_binaries() {
+ dodir /usr/bin
+ cd "${D}"${BINPATH}
+ # Ugh: we really need to auto-detect this list.
+ # It's constantly out of date.
+ for x in cpp gcc g++ c++ gcov g77 gcj gcjh gfortran gccgo ; do
+ # For some reason, g77 gets made instead of ${CTARGET}-g77...
+ # this should take care of that
+ [[ -f ${x} ]] && mv ${x} ${CTARGET}-${x}
+
+ if [[ -f ${CTARGET}-${x} ]] ; then
+ ln -sf ${CTARGET}-${x} ${x}
+ dosym ${BINPATH}/${CTARGET}-${x} /usr/bin/${x}-${GCC_CONFIG_VER}
+ # Create version-ed symlinks
+ dosym ${BINPATH}/${CTARGET}-${x} /usr/bin/${CTARGET}-${x}-${GCC_CONFIG_VER}
+ fi
+
+ if [[ -f ${CTARGET}-${x}-${GCC_CONFIG_VER} ]] ; then
+ rm -f ${CTARGET}-${x}-${GCC_CONFIG_VER}
+ ln -sf ${CTARGET}-${x} ${CTARGET}-${x}-${GCC_CONFIG_VER}
+ fi
+ done
+}
+
+tasteful_stripping() {
+ # Now do the fun stripping stuff
+ env RESTRICT="" CHOST=${CHOST} prepstrip "${D}${BINPATH}"
+ env RESTRICT="" CHOST=${CTARGET} prepstrip "${D}${LIBPATH}"
+ # gcc used to install helper binaries in lib/ but then moved to libexec/
+ [[ -d ${D}${PREFIX}/libexec/gcc ]] && \
+ env RESTRICT="" CHOST=${CHOST} prepstrip "${D}${PREFIX}/libexec/gcc/${CTARGET}/${GCC_CONFIG_VER}"
+}
+
+doc_cleanups() {
+ local cxx_mandir=$(find "${WORKDIR}/objdir/${CTARGET}/libstdc++-v3" -name man)
+ if [[ -d ${cxx_mandir} ]] ; then
+ # clean bogus manpages #113902
+ find "${cxx_mandir}" -name '*_build_*' -exec rm {} \;
+ cp -r "${cxx_mandir}"/man? "${D}/${DATAPATH}"/man/
+ fi
+ has noinfo ${FEATURES} \
+ && rm -r "${D}/${DATAPATH}"/info \
+ || prepinfo "${DATAPATH}"
+ has noman ${FEATURES} \
+ && rm -r "${D}/${DATAPATH}"/man \
+ || prepman "${DATAPATH}"
+}
+
+src_install() {
+ S=$WORKDIR/objdir; cd $S
+
+# PRE-MAKE INSTALL SECTION:
+
+ # from toolchain eclass:
+ # Do allow symlinks in private gcc include dir as this can break the build
+ find gcc/include*/ -type l -delete
+
+ # Remove generated headers, as they can cause things to break
+ # (ncurses, openssl, etc).
+ while read x; do
+ grep -q 'It has been auto-edited by fixincludes from' "${x}" \
+ && echo "Removing auto-generated header: $x" \
+ && rm -f "${x}"
+ done < <(find gcc/include*/ -name '*.h')
+
+# MAKE INSTALL SECTION:
+
+ make -j1 DESTDIR="${D}" install || die
+
+# POST MAKE INSTALL SECTION:
+
+ # Basic sanity check
+ local EXEEXT
+ eval $(grep ^EXEEXT= "${WORKDIR}"/objdir/gcc/config.log)
+ [[ -r ${D}${BINPATH}/gcc${EXEEXT} ]] || die "gcc not found in ${D}"
+
+# GENTOO ENV SETUP
+
+ dodir /etc/env.d/gcc
+ create_gcc_env_entry
+
+ if use hardened; then
+ create_gcc_env_entry hardenednopiessp
+ create_gcc_env_entry hardenednopie
+ create_gcc_env_entry hardenednossp
+ create_gcc_env_entry vanilla
+ insinto ${LIBPATH}
+ doins "${WORKDIR}"/specs/*.specs
+ fi
+
+# CLEANUPS:
+
+ # Punt some tools which are really only useful while building gcc
+ find "${D}" -name install-tools -prune -type d -exec rm -rf "{}" \;
+ # This one comes with binutils
+ find "${D}" -name libiberty.a -delete
+ # prune empty dirs left behind
+ find "${D}" -depth -type d -delete 2>/dev/null
+ # ownership fix:
+ chown -R root:0 "${D}"${LIBPATH} 2>/dev/null
+ find "${D}/${LIBPATH}" -name libstdc++.la -type f -exec rm "{}" \;
+ find "${D}/${LIBPATH}" -name "*.py" -type f -exec rm "{}" \;
+
+ linkify_compiler_binaries
+ tasteful_stripping
+ doc_cleanups
+ exeinto "${DATAPATH}"
+ doexe "${FILESDIR}"/c{89,99} || die
+
+ # Don't scan .gox files for executable stacks - false positives
+ export QA_EXECSTACK="usr/lib*/go/*/*.gox"
+ export QA_WX_LOAD="usr/lib*/go/*/*.gox"
+}
+
+pkg_postinst() {
+
+ # Here, we will auto-enable the new compiler if none is currently enabled, or
+ # if this is an _._.x upgrade to an already-installed compiler.
+
+ # One exception is if multislot is enabled in USE, which allows ie. 4.6.9
+ # and 4.6.10 to exist alongside one another. In this case, the user must
+ # enable this compiler manually.
+
+ local do_config="yes"
+ curr_gcc_config=$(env -i ROOT="${ROOT}" gcc-config -c ${CTARGET} 2>/dev/null)
+ if [ -n "$curr_gcc_config" ]; then
+ CURR_GCC_CONFIG_VER=$(gcc-config -S ${curr_gcc_config} | awk '{print $2}')
+ if [ "${CURR_GCC_CONFIG_VER%%.*}" != "${GCC_CONFIG_VER%%.*}" ]; then
+ # major versions don't match, don't run gcc-config
+ do_config="no"
+ fi
+ use multislot && do_config="no"
+ fi
+ if [ "$do_config" == "yes" ]; then
+ gcc-config ${CTARGET}-${GCC_CONFIG_VER}
+ else
+ einfo "This does not appear to be a regular upgrade of gcc, so"
+ einfo "gcc ${GCC_CONFIG_VER} will not be automatically enabled as the"
+ einfo "default system compiler."
+ echo
+ einfo "If you would like to make ${GCC_CONFIG_VER} the default system"
+ einfo "compiler, then perform the following steps as root:"
+ echo
+ einfo "gcc-config ${CTARGET}-${GCC_CONFIG_VER}"
+ einfo "source /etc/profile"
+ echo
+ ebeep
+ fi
+}
View
394 sys-devel/gcc/gcc-4.8.1.ebuild
@@ -0,0 +1,394 @@
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=5
+
+inherit multilib eutils
+
+# Ebuild notes:
+#
+# This is a simplified Funtoo gcc ebuild. It has been designed to have a reduced dependency
+# footprint, so that libgmp, mpfr and mpc are built as part of the gcc build process and
+# are not external dependencies. This makes upgrading these dependencies easier and
+# improves upgradability of Funtoo Linux systems, and solves various thorny build issues.
+#
+# Also, this gcc ebuild no longer uses toolchain.eclass which improves the maintainability
+# of the ebuild itself as it is less complex.
+#
+# -- Daniel Robbins, Apr 19, 2013.
+#
+# Other important notes on this ebuild:
+#
+# x86/amd64 architecture support only (for now).
+# mudflap is enabled by default.
+# lto is disabled by default.
+# test is not currently supported.
+# objc-gc is enabled by default when objc is enabled.
+# gcj is not currently supported by this ebuild.
+# graphite is not currently supported by this ebuild.
+# multislot is a good USE flag to set when testing this ebuild;
+# (It allows this gcc to co-exist along identical x.y versions.)
+# hardened is now supported, but we have deprecated the nopie and
+# nossp USE flags from gentoo.
+
+# Note: multi-stage bootstrapping is currently not being performed.
+
+RESTRICT="strip"
+FEATURES=${FEATURES/multilib-strict/}
+
+IUSE="ada cxx fortran f77 f95 objc objc++ openmp" # languages
+IUSE="$IUSE multislot nls nptl vanilla doc multilib altivec libssp hardened" # other stuff
+
+if use multislot; then
+ SLOT="${PV}"
+else
+ SLOT="${PV%.*}"
+fi
+
+#Not used:
+#PATCH_VER="1.6"
+
+#Hardened Support:
+#
+# PIE_VER specifies the version of the PIE patches that will be downloaded and applied.
+#
+# SPECS_VER and SPECS_GCC_VER specifies the version of the "minispecs" files that will
+# be used. Minispecs are compiler definitions that are installed that can be used to
+# select various permutations of the hardened compiler, as well as a non-hardened
+# compiler, and are typically selected via Gentoo's gcc-config tool.
+
+PIE_VER="0.5.7"
+SPECS_VER="0.2.0"
+SPECS_GCC_VER="4.4.3"
+SPECS_A="gcc-${SPECS_GCC_VER}-specs-${SPECS_VER}.tar.bz2"
+PIE_A="gcc-${PV}-piepatches-v${PIE_VER}.tar.bz2"
+
+GMP_VER="5.1.1"
+MPFR_VER="3.1.2"
+MPC_VER="1.0.1"
+
+GCC_A="gcc-${PV}.tar.bz2"
+SRC_URI="mirror://gnu/gcc/gcc-${PV}/${GCC_A}"
+SRC_URI="$SRC_URI http://www.multiprecision.org/mpc/download/mpc-${MPC_VER}.tar.gz"
+SRC_URI="$SRC_URI http://www.mpfr.org/mpfr-${MPFR_VER}/mpfr-${MPFR_VER}.tar.xz"
+SRC_URI="$SRC_URI mirror://gnu/gmp/gmp-${GMP_VER}.tar.xz"
+
+#Hardened Support:
+SRC_URI="$SRC_URI hardened? ( mirror://gentoo/${SPECS_A} mirror://gentoo/${PIE_A} )"
+
+DESCRIPTION="The GNU Compiler Collection"
+
+LICENSE="GPL-3+ LGPL-3+ || ( GPL-3+ libgcc libstdc++ gcc-runtime-library-exception-3.1 ) FDL-1.3+"
+KEYWORDS="*"
+
+RDEPEND="sys-libs/zlib nls? ( sys-devel/gettext ) virtual/libiconv"
+DEPEND="${RDEPEND} >=sys-devel/bison-1.875 >=sys-devel/flex-2.5.4 elibc_glibc? ( >=sys-libs/glibc-2.8 ) >=sys-devel/binutils-2.18"
+PDEPEND=">=sys-devel/gcc-config-1.5 elibc_glibc? ( >=sys-libs/glibc-2.8 )"
+
+pkg_setup() {
+ unset GCC_SPECS # we don't want to use the installed compiler's specs to build gcc!
+ unset LANGUAGES #265283
+ PREFIX=/usr
+ CTARGET=$CHOST
+ GCC_BRANCH_VER=${SLOT}
+ GCC_CONFIG_VER=${PV}
+ DATAPATH=${PREFIX}/share/gcc-data/${CTARGET}/${GCC_CONFIG_VER}
+ BINPATH=${PREFIX}/${CTARGET}/gcc-bin/${GCC_CONFIG_VER}
+ LIBPATH=${PREFIX}/lib/gcc/${CTARGET}/${GCC_CONFIG_VER}
+ STDCXX_INCDIR=${LIBPATH}/include/g++-v${GCC_BRANCH_VER}
+}
+
+src_unpack() {
+ unpack $GCC_A
+ ( unpack mpc-${MPC_VER}.tar.gz && mv ${WORKDIR}/mpc-${MPC_VER} ${S}/mpc ) || die "mpc setup fail"
+ ( unpack mpfr-${MPFR_VER}.tar.xz && mv ${WORKDIR}/mpfr-${MPFR_VER} ${S}/mpfr ) || die "mpfr setup fail"
+ ( unpack gmp-${GMP_VER}.tar.xz && mv ${WORKDIR}/gmp-${GMP_VER} ${S}/gmp ) || die "gmp setup fail"
+ if use hardened; then
+ unpack $PIE_A || die "pie unpack fail"
+ unpack $SPECS_A || die "specs unpack fail"
+ fi
+ cd $S
+ mkdir ${WORKDIR}/objdir
+}
+
+src_prepare() {
+
+ # TODO - APPLY PIE PATCHES
+ # TODO - ALL_CFLAGS vs HARD_CFLAGS (see do_gcc_PIE_patches() in toolchain.eclass)
+
+ # For some reason, when upgrading gcc, the gcc Makefile will install stuff
+ # like crtbegin.o into a subdirectory based on the name of the currently-installed
+ # gcc version, rather than *our* gcc version. Manually fix this:
+
+ sed -i -e "s/^version :=.*/version := ${GCC_CONFIG_VER}/" ${S}/libgcc/Makefile.in || die
+
+ # The following patch allows pie/ssp specs to be changed via environment
+ # variable, which is needed for gcc-config to allow switching of compilers:
+
+ [[ ${CHOST} == ${CTARGET} ]] && cat "${FILESDIR}"/gcc-spec-env.patch | patch -p1 || die "patch fail"
+
+ # We use --enable-version-specific-libs with ./configure. This
+ # option is designed to place all our libraries into a sub-directory
+ # rather than /usr/lib*. However, this option, even through 4.8.0,
+ # does not work 100% correctly without a small fix for
+ # libgcc_s.so. See: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32415.
+ # So, we apply a small patch to get this working:
+
+ cat "${FILESDIR}"/gcc-4.6.4-fix-libgcc-s-path-with-vsrl.patch | patch -p1 || die "patch fail"
+
+ # gcc-4.6.4 seems to have trouble building libgfortran - it can't find the gfortran compiler it built.
+ # Here is hack #1 to make that happen - hard-code the configure script with the full path to gfortran:
+
+ sed -i -e "s:^FC=.*:FC=${WORKDIR}/objdir/gcc/gfortran:" ${WORKDIR}/gcc-${PV}/libgfortran/configure || die libgfortran prep
+
+ if use hardened; then
+ local gcc_hard_flags="-DEFAULT_RELRO -DEFAULT_BIND_NOW -DEFAULT_PIE_SSP"
+ sed -i -e "/^HARD_CFLAGS = /s|=|= ${gcc_hard_flags} |" "${S}"/gcc/Makefile.in || die
+ EPATCH_MULTI_MSG="Applying PIE patches..." \
+ epatch "${WORKDIR}"/piepatch/*.patch
+ fi
+}
+
+src_configure() {
+
+ # Determine language support:
+ local confgcc
+ local GCC_LANG="c"
+ use cxx && GCC_LANG+=",c++" && confgcc+=" --enable-libstdcxx-time"
+ if use objc; then
+ GCC_LANG+=",objc"
+ confgcc+=" --enable-objc-gc"
+ use objc++ && GCC_LANG+=",obj-c++"
+ fi
+ use fortran && GCC_LANG+=",fortran" || confgcc+=" --disable-libquadmath"
+ use f77 && GCC_LANG+=",f77"
+ use f95 && GCC_LANG+=",f95"
+ use ada && GCC_LANG+=",ada"
+ confgcc+=" $(use_enable openmp libgomp)"
+ confgcc+=" --enable-languages=${GCC_LANG} --disable-libgcj"
+ confgcc+=" $(use_enable hardened esp)"
+
+ use libssp || export gcc_cv_libc_provides_ssp=yes
+
+ local branding="Funtoo"
+ if use hardened; then
+ branding="$branding Hardened ${PVR}, pie-${PIE_VER}"
+ else
+ branding="$branding ${PVR}"
+ fi
+
+ cd ${WORKDIR}/objdir && ../gcc-${PV}/configure \
+ $(use_enable libssp) \
+ $(use_enable multilib) \
+ --enable-version-specific-runtime-libs \
+ --enable-libmudflap \
+ --prefix=${PREFIX} \
+ --bindir=${BINPATH} \
+ --includedir=${LIBPATH}/include \
+ --datadir=${DATAPATH} \
+ --mandir=${DATAPATH}/man \
+ --infodir=${DATAPATH}/info \
+ --with-gxx-include-dir=${STDCXX_INCDIR} \
+ --enable-__cxa_atexit \
+ --enable-clocale=gnu \
+ --host=$CHOST \
+ --build=$CHOST \
+ --disable-ppl \
+ --disable-cloog \
+ --with-system-zlib \
+ --enable-obsolete \
+ --disable-werror \
+ --enable-secureplt \
+ --disable-lto \
+ --with-bugurl=http://bugs.funtoo.org \
+ --with-pkgversion="$branding" \
+ --with-mpfr-include=${S}/mpfr/src \
+ --with-mpfr-lib=${WORKDIR}/objdir/mpfr/src/.libs \
+ $confgcc \
+ || die "configure fail"
+
+ # The --with-mpfr* lines above are used so that gcc-4.6.4 can find mpfr-3.1.2.
+ # It can find 2.4.2 with no problem automatically but needs help with newer versions
+ # due to mpfr dir structure changes. We look for includes in the source directory,
+ # and libraries in the build (objdir) directory.
+}
+
+src_compile() {
+ cd $WORKDIR/objdir
+ unset ABI
+
+ # gcc-4.6.4 seems to have trouble building libgfortran - it can't find the gfortran compiler it built.
+ # Here is hack #2 to make that happen: expand PATH so that gfortran can find other tools it needs:
+
+ export PATH="$WORKDIR/objdir/gcc:$PATH"
+ emake LIBPATH="${LIBPATH}" bootstrap-lean || die "compile fail"
+}
+
+create_gcc_env_entry() {
+ dodir /etc/env.d/gcc
+ local gcc_envd_base="/etc/env.d/gcc/${CTARGET}-${GCC_CONFIG_VER}"
+ local gcc_envd_file="${D}${gcc_envd_base}"
+ if [ -z $1 ]; then
+ gcc_specs_file=""
+ else
+ gcc_envd_file="$gcc_envd_file-$1"
+ gcc_specs_file="${LIBPATH}/$1.specs"
+ fi
+ cat <<-EOF > ${gcc_envd_file}
+ GCC_PATH="${BINPATH}"
+ LDPATH="${LIBPATH}:${LIBPATH}/32"
+ MANPATH="${DATAPATH}/man"
+ INFOPATH="${DATAPATH}/info"
+ STDCXX_INCDIR="${STDCXX_INCDIR##*/}"
+ GCC_SPECS="${gcc_specs_file}"
+ EOF
+}
+
+linkify_compiler_binaries() {
+ dodir /usr/bin
+ cd "${D}"${BINPATH}
+ # Ugh: we really need to auto-detect this list.
+ # It's constantly out of date.
+ for x in cpp gcc g++ c++ gcov g77 gcj gcjh gfortran gccgo ; do
+ # For some reason, g77 gets made instead of ${CTARGET}-g77...
+ # this should take care of that
+ [[ -f ${x} ]] && mv ${x} ${CTARGET}-${x}
+
+ if [[ -f ${CTARGET}-${x} ]] ; then
+ ln -sf ${CTARGET}-${x} ${x}
+ dosym ${BINPATH}/${CTARGET}-${x} /usr/bin/${x}-${GCC_CONFIG_VER}
+ # Create version-ed symlinks
+ dosym ${BINPATH}/${CTARGET}-${x} /usr/bin/${CTARGET}-${x}-${GCC_CONFIG_VER}
+ fi
+
+ if [[ -f ${CTARGET}-${x}-${GCC_CONFIG_VER} ]] ; then
+ rm -f ${CTARGET}-${x}-${GCC_CONFIG_VER}
+ ln -sf ${CTARGET}-${x} ${CTARGET}-${x}-${GCC_CONFIG_VER}
+ fi
+ done
+}
+
+tasteful_stripping() {
+ # Now do the fun stripping stuff
+ env RESTRICT="" CHOST=${CHOST} prepstrip "${D}${BINPATH}"
+ env RESTRICT="" CHOST=${CTARGET} prepstrip "${D}${LIBPATH}"
+ # gcc used to install helper binaries in lib/ but then moved to libexec/
+ [[ -d ${D}${PREFIX}/libexec/gcc ]] && \
+ env RESTRICT="" CHOST=${CHOST} prepstrip "${D}${PREFIX}/libexec/gcc/${CTARGET}/${GCC_CONFIG_VER}"
+}
+
+doc_cleanups() {
+ local cxx_mandir=$(find "${WORKDIR}/objdir/${CTARGET}/libstdc++-v3" -name man)
+ if [[ -d ${cxx_mandir} ]] ; then
+ # clean bogus manpages #113902
+ find "${cxx_mandir}" -name '*_build_*' -exec rm {} \;
+ cp -r "${cxx_mandir}"/man? "${D}/${DATAPATH}"/man/
+ fi
+ has noinfo ${FEATURES} \
+ && rm -r "${D}/${DATAPATH}"/info \
+ || prepinfo "${DATAPATH}"
+ has noman ${FEATURES} \
+ && rm -r "${D}/${DATAPATH}"/man \
+ || prepman "${DATAPATH}"
+}
+
+src_install() {
+ S=$WORKDIR/objdir; cd $S
+
+# PRE-MAKE INSTALL SECTION:
+
+ # from toolchain eclass:
+ # Do allow symlinks in private gcc include dir as this can break the build
+ find gcc/include*/ -type l -delete
+
+ # Remove generated headers, as they can cause things to break
+ # (ncurses, openssl, etc).
+ while read x; do
+ grep -q 'It has been auto-edited by fixincludes from' "${x}" \
+ && echo "Removing auto-generated header: $x" \
+ && rm -f "${x}"
+ done < <(find gcc/include*/ -name '*.h')
+
+# MAKE INSTALL SECTION:
+
+ make -j1 DESTDIR="${D}" install || die
+
+# POST MAKE INSTALL SECTION:
+
+ # Basic sanity check
+ local EXEEXT
+ eval $(grep ^EXEEXT= "${WORKDIR}"/objdir/gcc/config.log)
+ [[ -r ${D}${BINPATH}/gcc${EXEEXT} ]] || die "gcc not found in ${D}"
+
+# GENTOO ENV SETUP
+
+ dodir /etc/env.d/gcc
+ create_gcc_env_entry
+
+ if use hardened; then
+ create_gcc_env_entry hardenednopiessp
+ create_gcc_env_entry hardenednopie
+ create_gcc_env_entry hardenednossp
+ create_gcc_env_entry vanilla
+ insinto ${LIBPATH}
+ doins "${WORKDIR}"/specs/*.specs
+ fi
+
+# CLEANUPS:
+
+ # Punt some tools which are really only useful while building gcc
+ find "${D}" -name install-tools -prune -type d -exec rm -rf "{}" \;
+ # This one comes with binutils
+ find "${D}" -name libiberty.a -delete
+ # prune empty dirs left behind
+ find "${D}" -depth -type d -delete 2>/dev/null
+ # ownership fix:
+ chown -R root:0 "${D}"${LIBPATH} 2>/dev/null
+ find "${D}/${LIBPATH}" -name libstdc++.la -type f -exec rm "{}" \;
+ find "${D}/${LIBPATH}" -name "*.py" -type f -exec rm "{}" \;
+
+ linkify_compiler_binaries
+ tasteful_stripping
+ doc_cleanups
+ exeinto "${DATAPATH}"
+ doexe "${FILESDIR}"/c{89,99} || die
+
+ # Don't scan .gox files for executable stacks - false positives
+ export QA_EXECSTACK="usr/lib*/go/*/*.gox"
+ export QA_WX_LOAD="usr/lib*/go/*/*.gox"
+}
+
+pkg_postinst() {
+
+ # Here, we will auto-enable the new compiler if none is currently enabled, or
+ # if this is an _._.x upgrade to an already-installed compiler.
+
+ # One exception is if multislot is enabled in USE, which allows ie. 4.6.9
+ # and 4.6.10 to exist alongside one another. In this case, the user must
+ # enable this compiler manually.
+
+ local do_config="yes"
+ curr_gcc_config=$(env -i ROOT="${ROOT}" gcc-config -c ${CTARGET} 2>/dev/null)
+ if [ -n "$curr_gcc_config" ]; then
+ CURR_GCC_CONFIG_VER=$(gcc-config -S ${curr_gcc_config} | awk '{print $2}')
+ if [ "${CURR_GCC_CONFIG_VER%%.*}" != "${GCC_CONFIG_VER%%.*}" ]; then
+ # major versions don't match, don't run gcc-config
+ do_config="no"
+ fi
+ use multislot && do_config="no"
+ fi
+ if [ "$do_config" == "yes" ]; then
+ gcc-config ${CTARGET}-${GCC_CONFIG_VER}
+ else
+ einfo "This does not appear to be a regular upgrade of gcc, so"
+ einfo "gcc ${GCC_CONFIG_VER} will not be automatically enabled as the"
+ einfo "default system compiler."
+ echo
+ einfo "If you would like to make ${GCC_CONFIG_VER} the default system"
+ einfo "compiler, then perform the following steps as root:"
+ echo
+ einfo "gcc-config ${CTARGET}-${GCC_CONFIG_VER}"
+ einfo "source /etc/profile"
+ echo
+ ebeep
+ fi
+}

0 comments on commit 254c7d4

Please sign in to comment.
Something went wrong with that request. Please try again.