diff options
Diffstat (limited to 'eclass/toolchain.eclass')
-rw-r--r-- | eclass/toolchain.eclass | 76 |
1 files changed, 52 insertions, 24 deletions
diff --git a/eclass/toolchain.eclass b/eclass/toolchain.eclass index d80889d1ba64..0fb518a0c2ea 100644 --- a/eclass/toolchain.eclass +++ b/eclass/toolchain.eclass @@ -309,6 +309,14 @@ gentoo_urls() { # ten Brugge's bounds-checking patches. If you want to use a patch # for an older gcc version with a new gcc, make sure you set # HTB_GCC_VER to that version of gcc. +# +# CYGWINPORTS_GITREV +# If set, this variable signals that we should apply additional patches +# maintained by upstream Cygwin developers at github/cygwinports/gcc, +# using the specified git commit id there. The list of patches to +# apply is extracted from gcc.cygport, maintained there as well. +# This is done for compilers running on Cygwin, not for cross compilers +# with a Cygwin target. get_gcc_src_uri() { export PATCH_GCC_VER=${PATCH_GCC_VER:-${GCC_RELEASE_VER}} export UCLIBC_GCC_VER=${UCLIBC_GCC_VER:-${PATCH_GCC_VER}} @@ -375,6 +383,11 @@ get_gcc_src_uri() { fi fi + # Cygwin patches from https://github.com/cygwinports/gcc + [[ -n ${CYGWINPORTS_GITREV} ]] && \ + GCC_SRC_URI+=" elibc_Cygwin? ( https://github.com/cygwinports/gcc/archive/${CYGWINPORTS_GITREV}.tar.gz + -> gcc-cygwinports-${CYGWINPORTS_GITREV}.tar.gz )" + echo "${GCC_SRC_URI}" } @@ -481,6 +494,8 @@ gcc_quick_unpack() { use_if_iuse boundschecking && unpack "bounds-checking-gcc-${HTB_GCC_VER}-${HTB_VER}.patch.bz2" + [[ -n ${CYGWINPORTS_GITREV} ]] && use elibc_Cygwin && unpack "gcc-cygwinports-${CYGWINPORTS_GITREV}.tar.gz" + popd > /dev/null } @@ -505,6 +520,7 @@ toolchain_src_prepare() { fi do_gcc_HTB_patches do_gcc_PIE_patches + do_gcc_CYGWINPORTS_patches epatch_user if ( tc_version_is_at_least 4.8.2 || use_if_iuse hardened ) && ! use vanilla ; then @@ -645,6 +661,18 @@ do_gcc_PIE_patches() { BRANDING_GCC_PKGVERSION="${BRANDING_GCC_PKGVERSION}, pie-${PIE_VER}" } +do_gcc_CYGWINPORTS_patches() { + [[ -n ${CYGWINPORTS_GITREV} ]] || return 0 + use elibc_Cygwin || return 0 + + local -a patches + local p d="${WORKDIR}/gcc-${CYGWINPORTS_GITREV}" + readarray -t patches < <(sed -e '1,/PATCH_URI="/d;/"/,$d' < "${d}"/gcc.cygport) + for p in ${patches[*]}; do + epatch "${d}/${p}" + done +} + # configure to build with the hardened GCC specs as the default make_gcc_hard() { @@ -1034,7 +1062,7 @@ toolchain_src_configure() { confgcc+=( --enable-shared ) fi case ${CHOST} in - mingw*|*-mingw*|*-cygwin) + mingw*|*-mingw*) confgcc+=( --enable-threads=win32 ) ;; *) confgcc+=( --enable-threads=posix ) ;; @@ -1722,9 +1750,9 @@ toolchain_src_install() { S="${WORKDIR}"/build emake -j1 DESTDIR="${D}" install || die # Punt some tools which are really only useful while building gcc - find "${D}" -name install-tools -prune -type d -exec rm -rf "{}" \; + find "${ED}" -name install-tools -prune -type d -exec rm -rf "{}" \; # This one comes with binutils - find "${D}" -name libiberty.a -delete + find "${ED}" -name libiberty.a -delete # Move the libraries to the proper location gcc_movelibs @@ -1733,7 +1761,7 @@ toolchain_src_install() { if ! is_crosscompile ; then local EXEEXT eval $(grep ^EXEEXT= "${WORKDIR}"/build/gcc/config.log) - [[ -r ${D}${BINPATH}/gcc${EXEEXT} ]] || die "gcc not found in ${D}" + [[ -r ${D}${BINPATH}/gcc${EXEEXT} ]] || die "gcc not found in ${ED}" fi dodir /etc/env.d/gcc @@ -1795,13 +1823,13 @@ toolchain_src_install() { cd "${S}" if is_crosscompile; then - rm -rf "${ED}"usr/share/{man,info} + rm -rf "${ED}"/usr/share/{man,info} rm -rf "${D}"${DATAPATH}/{man,info} else if tc_version_is_at_least 3.0 ; then local cxx_mandir=$(find "${WORKDIR}/build/${CTARGET}/libstdc++-v3" -name man) if [[ -d ${cxx_mandir} ]] ; then - cp -r "${cxx_mandir}"/man? "${D}/${DATAPATH}"/man/ + cp -r "${cxx_mandir}"/man? "${D}${DATAPATH}"/man/ fi fi has noinfo ${FEATURES} \ @@ -1812,7 +1840,7 @@ toolchain_src_install() { || prepman "${DATAPATH#${EPREFIX}}" fi # prune empty dirs left behind - find "${D}" -depth -type d -delete 2>/dev/null + find "${ED}" -depth -type d -delete 2>/dev/null # install testsuite results if use regression-test; then @@ -1852,7 +1880,7 @@ toolchain_src_install() { # libvtv.la: gcc itself handles linkage correctly. # lib*san.la: Sanitizer linkage is handled internally by gcc, and they # do not support static linking. #487550 #546700 - find "${D}/${LIBPATH}" \ + find "${D}${LIBPATH}" \ '(' \ -name libstdc++.la -o \ -name libstdc++fs.la -o \ @@ -1918,7 +1946,7 @@ gcc_movelibs() { # code to run on the target. if tc_version_is_at_least 5 && is_crosscompile ; then dodir "${HOSTLIBPATH#${EPREFIX}}" - mv "${ED}"usr/$(get_libdir)/libcc1* "${D}${HOSTLIBPATH}" || die + mv "${ED}"/usr/$(get_libdir)/libcc1* "${D}${HOSTLIBPATH}" || die fi # For all the libs that are built for CTARGET, move them into the @@ -1968,7 +1996,7 @@ gcc_movelibs() { for FROMDIR in ${removedirs} ; do rmdir "${D}"${FROMDIR} >& /dev/null done - find -depth "${D}" -type d -exec rmdir {} + >& /dev/null + find -depth "${ED}" -type d -exec rmdir {} + >& /dev/null } # make sure the libtool archives have libdir set to where they actually @@ -2115,7 +2143,7 @@ gcc_slot_java() { toolchain_pkg_postinst() { do_gcc_config - if [[ ${ROOT} == / && -f ${EPREFIX}/usr/share/eselect/modules/compiler-shadow.eselect ]] ; then + if [[ ! ${ROOT%/} && -f ${EPREFIX}/usr/share/eselect/modules/compiler-shadow.eselect ]] ; then eselect compiler-shadow update all fi @@ -2130,17 +2158,17 @@ toolchain_pkg_postinst() { echo # Clean up old paths - rm -f "${EROOT}"*/rcscripts/awk/fixlafiles.awk "${EROOT}"sbin/fix_libtool_files.sh - rmdir "${EROOT}"*/rcscripts{/awk,} 2>/dev/null + rm -f "${EROOT%/}"/*/rcscripts/awk/fixlafiles.awk "${EROOT%/}"/sbin/fix_libtool_files.sh + rmdir "${EROOT%/}"/*/rcscripts{/awk,} 2>/dev/null - mkdir -p "${EROOT}"usr/{share/gcc-data,sbin,bin} + mkdir -p "${EROOT%/}"/usr/{share/gcc-data,sbin,bin} # DATAPATH has EPREFIX already, use ROOT with it - cp "${ROOT}${DATAPATH}"/fixlafiles.awk "${EROOT}"usr/share/gcc-data/ || die - cp "${ROOT}${DATAPATH}"/fix_libtool_files.sh "${EROOT}"usr/sbin/ || die + cp "${ROOT%/}${DATAPATH}"/fixlafiles.awk "${EROOT%/}"/usr/share/gcc-data/ || die + cp "${ROOT%/}${DATAPATH}"/fix_libtool_files.sh "${EROOT%/}"/usr/sbin/ || die # Since these aren't critical files and portage sucks with # handling of binpkgs, don't require these to be found - cp "${ROOT}${DATAPATH}"/c{89,99} "${EROOT}"usr/bin/ 2>/dev/null + cp "${ROOT%/}${DATAPATH}"/c{89,99} "${EROOT%/}"/usr/bin/ 2>/dev/null fi if use regression-test ; then @@ -2156,7 +2184,7 @@ toolchain_pkg_postinst() { } toolchain_pkg_postrm() { - if [[ ${ROOT} == / && -f ${EPREFIX}/usr/share/eselect/modules/compiler-shadow.eselect ]] ; then + if [[ ! ${ROOT%/} && -f ${EPREFIX}/usr/share/eselect/modules/compiler-shadow.eselect ]] ; then eselect compiler-shadow clean all fi @@ -2167,16 +2195,16 @@ toolchain_pkg_postrm() { # clean up the cruft left behind by cross-compilers if is_crosscompile ; then - if [[ -z $(ls "${EROOT}"etc/env.d/gcc/${CTARGET}* 2>/dev/null) ]] ; then - rm -f "${EROOT}"etc/env.d/gcc/config-${CTARGET} - rm -f "${EROOT}"etc/env.d/??gcc-${CTARGET} - rm -f "${EROOT}"usr/bin/${CTARGET}-{gcc,{g,c}++}{,32,64} + if [[ -z $(ls "${EROOT%/}"/etc/env.d/gcc/${CTARGET}* 2>/dev/null) ]] ; then + rm -f "${EROOT%/}"/etc/env.d/gcc/config-${CTARGET} + rm -f "${EROOT%/}"/etc/env.d/??gcc-${CTARGET} + rm -f "${EROOT%/}"/usr/bin/${CTARGET}-{gcc,{g,c}++}{,32,64} fi return 0 fi # ROOT isnt handled by the script - [[ ${ROOT} != "/" ]] && return 0 + [[ ${ROOT%/} ]] && return 0 if [[ ! -e ${LIBPATH}/libstdc++.so ]] ; then # make sure the profile is sane during same-slot upgrade #289403 @@ -2209,7 +2237,7 @@ do_gcc_config() { [[ -n ${current_specs} ]] && use_specs=-${current_specs} if [[ -n ${use_specs} ]] && \ - [[ ! -e ${ROOT}/etc/env.d/gcc/${CTARGET}-${GCC_CONFIG_VER}${use_specs} ]] + [[ ! -e ${EROOT%/}/etc/env.d/gcc/${CTARGET}-${GCC_CONFIG_VER}${use_specs} ]] then ewarn "The currently selected specs-specific gcc config," ewarn "${current_specs}, doesn't exist anymore. This is usually" |