commit:     e2ba90779e2c596d964777f706aca5c79e223e50
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Thu Dec  4 09:15:23 2014 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Thu Dec  4 10:44:03 2014 +0000
URL:        
http://sources.gentoo.org/gitweb/?p=dev/mgorny.git;a=commit;h=e2ba9077

sys-devel/gcc: Multilib gcc wrapper support.

Package-Manager: portage-2.2.14

---
 sys-devel/gcc/gcc-4.9.2-r100.ebuild | 73 ++++++++++++++++++++++++++++++-------
 1 file changed, 59 insertions(+), 14 deletions(-)

diff --git a/sys-devel/gcc/gcc-4.9.2-r100.ebuild 
b/sys-devel/gcc/gcc-4.9.2-r100.ebuild
index eb7b8b1..e559cac 100644
--- a/sys-devel/gcc/gcc-4.9.2-r100.ebuild
+++ b/sys-devel/gcc/gcc-4.9.2-r100.ebuild
@@ -425,18 +425,54 @@ create_gcc_symlinks() {
        # gcc-wrapper doesn't have an alias for it...
        ln -f -s g++ c++ || die
 
+       # Store for reuse in create_multilib_wrapper().
+       GCC_TOOLS=( * )
+
        local t
-       for t in *; do
+       for t in "${GCC_TOOLS[@]}"; do
                # Add CTARGET-ed symlinks to make gcc-wrapper happy.
                ln -s "${t}" "${CTARGET}-${t}" || die
 
-               # BROKEN: no gcc-ar, gcc-nm, gcc-ranlib
                # Install versioned symlinks in /usr/bin.
                dosym "${BINPATH}/${t}" /usr/bin/"${CTARGET}-${t}-${PV}"
                dosym "${CTARGET}-${t}-${PV}" /usr/bin/"${t}-${PV}"
        done
 }
 
+create_multilib_wrappers() {
+       local native_ctarget=${CTARGET}
+
+       create_multilib_wrapper() {
+               multilib_is_native_abi && continue
+
+               local abi_binpath=${PREFIX}/${CHOST}/gcc-bin/${PV}
+               exeinto "${abi_binpath}"
+               dodir "${abi_binpath}"
+
+               local t
+               for t in "${GCC_TOOLS[@]}"; do
+                       if [[ ${t} == gcov || ${t} == gcc-* ]]; then
+                               # those tools have no multilib powers, we 
symlink them as-is
+                               dosym "../../../${BINPATH#${PREFIX}/}/${t}" \
+                                       "${abi_binpath}/${t}" || die
+                       else
+                               # use canonical name to avoid playing with ${0}
+                               cat > "${T}"/wrapper <<-_EOF_
+                                       #!${EPREFIX}/bin/sh
+                                       exec "${native_ctarget}-${t}-${PV}" 
$(get_abi_CFLAGS) "\${@}"
+                               _EOF_
+
+                               newexe "${T}"/wrapper "${t}"
+                       fi
+
+                       # Now symlink fun.
+                       dosym "${t}" "${abi_binpath}/${CHOST}-${t}" || die
+                       dosym "${abi_binpath}/${t}" 
/usr/bin/"${CHOST}-${t}-${PV}"
+               done
+       }
+       multilib_foreach_abi create_multilib_wrapper
+}
+
 strip_gcc_executables() {
        # TODO: find out how to avoid prepstrip
        env RESTRICT="" CHOST="${CHOST}" prepstrip "${D}${BINPATH}"
@@ -455,7 +491,7 @@ 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_envd_base="/etc/env.d/gcc/${CHOST}-${PV}"
 
        local gcc_specs_file
        local gcc_envd_file="${D}${gcc_envd_base}"
@@ -485,15 +521,17 @@ create_gcc_env_entry() {
                mosdirs="${mosdir}${mosdirs:+:${mosdirs}}"
        done
 
+       local abi_binpath=${PREFIX}/${CHOST}/gcc-bin/${PV}
+
        cat <<-EOF > ${gcc_envd_file}
-       PATH="${BINPATH}"
-       ROOTPATH="${BINPATH}"
-       GCC_PATH="${BINPATH}"
+       PATH="${abi_binpath}"
+       ROOTPATH="${abi_binpath}"
+       GCC_PATH="${abi_binpath}"
        LDPATH="${ldpaths}"
        MANPATH="${DATAPATH}/man"
        INFOPATH="${DATAPATH}/info"
        STDCXX_INCDIR="${STDCXX_INCDIR##*/}"
-       CTARGET="${CTARGET}"
+       CTARGET="${CHOST}"
        GCC_SPECS="${gcc_specs_file}"
        MULTIOSDIRS="${mosdirs}"
        EOF
@@ -516,6 +554,7 @@ src_install() {
        rm "${D}${DATAPATH}"/info/dir || die
 
        create_gcc_symlinks
+       create_multilib_wrappers
        strip_gcc_executables
 
        # move *-gdb.py into /usr/share/gdb/auto-load tree
@@ -544,14 +583,20 @@ src_install() {
 
        prune_libtool_files
 
-       # entries and specs
-       create_gcc_env_entry
+       create_env_entries() {
+               # entries and specs
+               create_gcc_env_entry
+               if use hardened; then
+                       # setup the hardenedno* specs files and the vanilla 
specs file.
+                       create_gcc_env_entry hardenednopiessp
+                       create_gcc_env_entry hardenednopie
+                       create_gcc_env_entry hardenednossp
+                       create_gcc_env_entry vanilla
+               fi
+       }
+       multilib_foreach_abi create_gcc_env_entry
+
        if use hardened; then
-               # setup the hardenedno* specs files and the vanilla specs file.
-               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

Reply via email to