summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichał Górny <mgorny@gentoo.org>2014-12-02 23:38:53 +0100
committerMichał Górny <mgorny@gentoo.org>2014-12-02 23:38:53 +0100
commit312bd3143a3842f072d096dbda4af9ee9a127ca7 (patch)
treef56df05d25f7fe09d645363adea18170ee9e2b15
parentsys-devel/gcc: add metadata.xml (diff)
downloadmgorny-312bd3143a3842f072d096dbda4af9ee9a127ca7.tar.gz
mgorny-312bd3143a3842f072d096dbda4af9ee9a127ca7.tar.bz2
mgorny-312bd3143a3842f072d096dbda4af9ee9a127ca7.zip
sys-devel/gcc: Complete install (hopefully).
Package-Manager: portage-2.2.14
-rw-r--r--sys-devel/gcc/files/gcc-4.6.4-fix-libgcc-s-path-with-vsrl.patch21
-rw-r--r--sys-devel/gcc/gcc-4.9.2-r100.ebuild250
2 files changed, 233 insertions, 38 deletions
diff --git a/sys-devel/gcc/files/gcc-4.6.4-fix-libgcc-s-path-with-vsrl.patch b/sys-devel/gcc/files/gcc-4.6.4-fix-libgcc-s-path-with-vsrl.patch
new file mode 100644
index 0000000..11c3731
--- /dev/null
+++ b/sys-devel/gcc/files/gcc-4.6.4-fix-libgcc-s-path-with-vsrl.patch
@@ -0,0 +1,21 @@
+diff -urN gcc-4.6.4/libgcc/Makefile.in gcc-4.6.4-fixed/libgcc/Makefile.in
+--- gcc-4.6.4/libgcc/Makefile.in 2013-04-24 00:12:29.213242770 +0000
++++ gcc-4.6.4-fixed/libgcc/Makefile.in 2013-04-24 01:19:14.909313041 +0000
+@@ -945,7 +945,7 @@
+
+ $(subst @multilib_dir@,$(MULTIDIR),$(subst \
+ @shlib_base_name@,libunwind,$(subst \
+- @shlib_slibdir_qual@,$(MULTIOSSUBDIR),$(SHLIBUNWIND_INSTALL))))
++ @shlib_slibdir_qual@,$(MULTISUBDIR),$(SHLIBUNWIND_INSTALL))))
+
+ install-shared:
+ $(mkinstalldirs) $(DESTDIR)$(inst_libdir)
+@@ -956,7 +956,7 @@
+
+ $(subst @multilib_dir@,$(MULTIDIR),$(subst \
+ @shlib_base_name@,libgcc_s,$(subst \
+- @shlib_slibdir_qual@,$(MULTIOSSUBDIR),$(SHLIB_INSTALL))))
++ @shlib_slibdir_qual@,$(MULTISUBDIR),$(SHLIB_INSTALL))))
+
+ install-leaf: $(install-shared) $(install-libunwind)
+ $(mkinstalldirs) $(DESTDIR)$(inst_libdir)
diff --git a/sys-devel/gcc/gcc-4.9.2-r100.ebuild b/sys-devel/gcc/gcc-4.9.2-r100.ebuild
index bbde906..6f6d359 100644
--- a/sys-devel/gcc/gcc-4.9.2-r100.ebuild
+++ b/sys-devel/gcc/gcc-4.9.2-r100.ebuild
@@ -63,6 +63,9 @@ REQUIRED_USE="
pie? ( !vanilla )
ssp? ( !vanilla )"
+# Custom magic.
+RESTRICT="strip"
+
pkg_setup() {
export CTARGET=${CTARGET:-${CHOST}}
@@ -102,13 +105,16 @@ setup_multilib_osdirnames() {
src_prepare() {
export BRANDING_GCC_PKGVERSION="Gentoo ${PVR}::mgorny"
- if has_version '<sys-libs/glibc-2.12' ; then
- ewarn "Your host glibc is too old; disabling automatic fortify."
- ewarn "Please rebuild gcc after upgrading to >=glibc-2.12 #362315"
- rm "${WORKDIR}"/patch/10_all_default-fortify-source.patch || die
- fi
+ # fix libgcc_s install path
+ epatch "${FILESDIR}"/gcc-4.6.4-fix-libgcc-s-path-with-vsrl.patch || die
if ! use vanilla; then
+ if has_version '<sys-libs/glibc-2.12' ; then
+ ewarn "Your host glibc is too old; disabling automatic fortify."
+ ewarn "Please rebuild gcc after upgrading to >=glibc-2.12 #362315"
+ rm "${WORKDIR}"/patch/10_all_default-fortify-source.patch || die
+ fi
+
BRANDING_GCC_PKGVERSION+=" p${PATCH_VER}"
einfo "Applying Gentoo patches ..."
@@ -184,12 +190,12 @@ src_configure() {
einfo "CXXFLAGS: ${CXXFLAGS}"
einfo "LDFLAGS: ${LDFLAGS}"
- local prefix=/usr
- local binpath=${prefix}/${CTARGET}/gcc-bin/${PV}
- local libpath=${prefix}/lib/gcc/${CTARGET}/${PV}
- local incpath=${libpath}/include
- local datapath=${prefix}/share/gcc-data/${CTARGET}/${PV}
- local stdcxx_incdir=${libpath}/include/g++-v${GCC_BRANCH_VER%%.*}
+ PREFIX=/usr
+ BINPATH=${PREFIX}/${CTARGET}/gcc-bin/${PV}
+ LIBPATH=${PREFIX}/lib/gcc/${CTARGET}/${PV}
+ INCPATH=${LIBPATH}/include
+ DATAPATH=${PREFIX}/share/gcc-data/${CTARGET}/${PV}
+ STDCXX_INCDIR=${LIBPATH}/include/g++-v${GCC_BRANCH_VER%%.*}
local langs=( c )
use cxx && langs+=( c++ )
@@ -203,18 +209,19 @@ src_configure() {
--host=${CHOST}
--build=${CBUILD:-${CHOST}}
- --prefix="${prefix}"
- --bindir="${binpath}"
- --includedir="${incpath}"
- --datadir="${datapath}"
- --mandir="${datapath}/man"
- --infodir="${datapath}/info"
- --with-gxx-include-dir="${stdcxx_incdir}"
- --with-python-dir=${datapath#${prefix}/}/python
+ --prefix="${PREFIX}"
+ --bindir="${BINPATH}"
+ --includedir="${INCPATH}"
+ --datadir="${DATAPATH}"
+ --mandir="${DATAPATH}/man"
+ --infodir="${DATAPATH}/info"
+ --with-gxx-include-dir="${STDCXX_INCDIR}"
+ --with-python-dir=${DATAPATH#${PREFIX}/}/python
--enable-languages="${langs// /,}"
--disable-libgcj
+ --disable-bootstrap
--enable-obsolete
--enable-secureplt
--disable-werror
@@ -235,6 +242,7 @@ src_configure() {
# going to link in -lrt to all C++ apps. #411681
$(use_enable cxx libstdcxx-time)
+ --enable-version-specific-runtime-libs
--enable-lto
--enable-shared
--enable-threads=posix
@@ -414,33 +422,15 @@ src_configure() {
# return to whatever directory we were in before
popd > /dev/null
-
- # TODO: crap
-
- cat <<-EOF > envd
- PATH="${binpath}"
- ROOTPATH="${binpath}"
- GCC_PATH="${binpath}"
- LDPATH="${ldpaths}"
- MANPATH="${datapath}/man"
- INFOPATH="${datapath}/info"
- STDCXX_INCDIR="${stdcxx_incdir##*/}"
- CTARGET="${CTARGET}"
- GCC_SPECS="${gcc_specs_file}"
- MULTIOSDIRS="${mosdirs}"
- EOF
}
src_compile() {
touch "${S}"/gcc/c-gperf.h
- local prefix=/usr
- local libpath=${prefix}/lib/gcc/${CTARGET}/${PV}
-
emake -C "${WORKDIR}"/build all \
LDFLAGS="${LDFLAGS}" \
STAGE1_CFLAGS="${CFLAGS}" \
- LIBPATH="${libpath}" \
+ LIBPATH="${LIBPATH}" \
BOOT_CFLAGS="$(get_abi_CFLAGS "${TARGET_DEFAULT_ABI}") ${CFLAGS}"
if use cxx && use doc; then
@@ -452,3 +442,187 @@ src_compile() {
src_test() {
emake -k -C "${WORKDIR}"/build check
}
+
+create_gcc_symlinks() {
+ dodir /usr/bin
+ cd "${D}${BINPATH}" || die
+
+ # First, remove all default hardlinks (we have all files
+ # unprefixed anyway).
+ rm "${CTARGET}"-* || die
+
+ # Replace c++ hardlink with symlink. We can't drop it since
+ # gcc-wrapper doesn't have an alias for it...
+ ln -f -s g++ c++ || die
+
+ local t
+ for t in *; do
+ # Add CTARGET-ed symlinks to make gcc-wrapper happy.
+ ln -s "${t}" "${CTARGET}-${t}" || die
+
+ # Install versioned symlinks in /usr/bin.
+ dosym "${BINPATH}/${t}" /usr/bin/"${CTARGET}-${t}-${PV}"
+ dosym "${CTARGET}-${t}-${PV}" /usr/bin/"${t}-${PV}"
+ done
+}
+
+strip_gcc_executables() {
+ # TODO: find out how to avoid prepstrip
+ env RESTRICT="" CHOST="${CHOST}" prepstrip "${D}${BINPATH}"
+ env RESTRICT="" CHOST="${CHOST}" prepstrip "${D}${PREFIX}/libexec/gcc/${CTARGET}/${GCC_CONFIG_VER}"
+ env RESTRICT="" CHOST="${CTARGET}" prepstrip "${D}${LIBPATH}"
+}
+
+# Grab a variable from the build system (taken from linux-info.eclass)
+get_make_var() {
+ local var=$1 makefile=${2:-${WORKDIR}/build/Makefile}
+ echo -e "e:\\n\\t@echo \$(${var})\\ninclude ${makefile}" | \
+ r=${makefile%/*} emake --no-print-directory -s -f - 2>/dev/null
+}
+
+XGCC() { get_make_var GCC_FOR_TARGET ; }
+
+create_gcc_env_entry() {
+ dodir /etc/env.d/gcc
+ local gcc_envd_base="/etc/env.d/gcc/${CTARGET}-${PV}"
+
+ local gcc_specs_file
+ local gcc_envd_file="${D}${gcc_envd_base}"
+ if [[ -z $1 ]] ; then
+ # I'm leaving the following commented out to remind me that it
+ # was an insanely -bad- idea. Stuff broke. GCC_SPECS isnt unset
+ # on chroot or in non-toolchain.eclass gcc ebuilds!
+ #gcc_specs_file="${LIBPATH}/specs"
+ gcc_specs_file=""
+ else
+ gcc_envd_file+="-${1}"
+ gcc_specs_file="${LIBPATH}/${1}.specs"
+ fi
+
+ # We want to list the default ABI's LIBPATH first so libtool
+ # searches that directory first. This is a temporary
+ # workaround for libtool being stupid and using .la's from
+ # conflicting ABIs by using the first one in the search path
+ local ldpaths mosdirs mdir mosdir abi ldpath
+ for abi in $(get_all_abis TARGET) ; do
+ mdir=$($(XGCC) $(get_abi_CFLAGS ${abi}) --print-multi-directory)
+ ldpath=${LIBPATH}
+ [[ ${mdir} != "." ]] && ldpath+="/${mdir}"
+ ldpaths="${ldpath}${ldpaths:+:${ldpaths}}"
+
+ mosdir=$($(XGCC) $(get_abi_CFLAGS ${abi}) -print-multi-os-directory)
+ mosdirs="${mosdir}${mosdirs:+:${mosdirs}}"
+ done
+
+ cat <<-EOF > ${gcc_envd_file}
+ PATH="${BINPATH}"
+ ROOTPATH="${BINPATH}"
+ GCC_PATH="${BINPATH}"
+ LDPATH="${ldpaths}"
+ MANPATH="${DATAPATH}/man"
+ INFOPATH="${DATAPATH}/info"
+ STDCXX_INCDIR="${STDCXX_INCDIR##*/}"
+ CTARGET="${CTARGET}"
+ GCC_SPECS="${gcc_specs_file}"
+ MULTIOSDIRS="${mosdirs}"
+ EOF
+}
+
+copy_minispecs_gcc_specs() {
+ # setup the hardenedno* specs files and the vanilla specs file.
+ if hardened_gcc_works ; then
+ create_gcc_env_entry hardenednopiessp
+ fi
+ if hardened_gcc_works pie ; then
+ create_gcc_env_entry hardenednopie
+ fi
+ if hardened_gcc_works ssp ; then
+ create_gcc_env_entry hardenednossp
+ fi
+ create_gcc_env_entry vanilla
+ insinto "${LIBPATH}"
+ doins "${WORKDIR}"/specs/*.specs
+}
+
+src_install() {
+ cd "${WORKDIR}"/build || die
+
+ # Fix out-of-source info-page install
+ local f
+ while read -r -d '' f; do
+ cp "${S}/${f}" "${f}" || die
+ done < <(cd "${S}" && find gcc -name '*.info')
+
+ # Clean up include-fixed
+ find gcc/include-fixed -type l -delete || die
+ while read -r -d '' f; do
+ if grep 'auto-edited by fixincludes' "${f}"; then
+ rm "${f}" || die
+ fi
+ done < <(find gcc/include-fixed -type f)
+ find gcc/include-fixed -type d -empty -delete || die
+
+ emake -j1 DESTDIR="${D}" install
+
+ # Punt some tools which are really only useful while building gcc
+ find "${D}" -name install-tools -prune -type d -exec rm -r {} + || die
+
+ create_gcc_symlinks
+ strip_gcc_executables
+
+ if use doc; then
+ cd "${WORKDIR}/build/${CTARGET}/libstdc++-v3/doc/doxygen/man" || die
+ doman man*/*
+ fi
+
+ # 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"
+
+ # Disable RANDMMAP so PCH works. #301299
+ pax-mark -r "${D}${PREFIX}/libexec/gcc/${CTARGET}/${GCC_CONFIG_VER}/cc1"
+ pax-mark -r "${D}${PREFIX}/libexec/gcc/${CTARGET}/${GCC_CONFIG_VER}/cc1plus"
+
+ prune_libtool_files
+
+ create_gcc_env_entry
+ use hardened && copy_minispecs_gcc_specs
+}
+
+switch_gcc() {
+ local curr_config curr_pv
+ # config name: ${CTARGET}-${PV}
+ curr_config=$(env -i ROOT="${ROOT}" gcc-config -c "${CTARGET}" 2>&1)
+
+ # no config? switch!
+ if [[ -z ${curr_config} ]]; then
+ gcc-config "${CTARGET}-${PV}"
+ return
+ fi
+
+ # some config? argh, we need to parse it.
+ split_config=( $(env -i ROOT="${ROOT}" gcc-config -S "${CTARGET}") )
+
+ # different branch? we aren't doing such leaps ourselves.
+ if [[ ${split_config[1]%.*} != ${PV%.*} ]]; then
+ env -i ROOT="${ROOT}" gcc-config --use-old --force
+ return
+ fi
+
+ if [[ -n ${split_config[2]} ]]; then
+ if [[ -f ${ROOT}/etc/env.d/gcc/${CTARGET}-${PV}-${split_config[2]} ]]
+ then
+ gcc-config "${CTARGET}-${PV}-${split_config[2]}"
+ return
+ else
+ ewarn "Spec '${split_config[2]}' used so far is no longer available."
+ ewarn "The default will be used instead."
+ fi
+
+ gcc-config "${CTARGET}-${PV}"
+ fi
+}
+
+pkg_postinst() {
+ switch_gcc
+}