• [gentoo-dev] [PATCH 1/4] toolchain-funcs.eclass: stop using which(1)

    From Sam James@21:1/5 to All on Mon Dec 5 12:00:02 2022
    It's non-portable and we're looking to remove it from @system.

    Bug: https://bugs.gentoo.org/487696
    Bug: https://bugs.gentoo.org/646588
    Signed-off-by: Sam James <sam@gentoo.org>
    ---
    eclass/toolchain-funcs.eclass | 4 ++--
    1 file changed, 2 insertions(+), 2 deletions(-)

    diff --git a/eclass/toolchain-funcs.eclass b/eclass/toolchain-funcs.eclass index fea2a6885c46..6fa103fc110e 100644
    --- a/eclass/toolchain-funcs.eclass
    +++ b/eclass/toolchain-funcs.eclass
    @@ -609,7 +609,7 @@ tc-ld-force-bfd() {
    # to its value (like multilib). #545218
    local ld=$(tc-getLD "$@")
    local bfd_ld="${ld%% *}.bfd"
    - local path_ld=$(which "${bfd_ld}" 2>/dev/null)
    + local path_ld=$(type -P "${bfd_ld}" 2>/dev/null)
    [[ -e ${path_ld} ]] && export LD=${bfd_ld}

    # Set up LDFLAGS to select bfd based on the gcc / clang version.
    @@ -1154,7 +1154,7 @@ gen_usr_ldscript() {
    # If they're using gold, manually invoke the old bfd. #487696
    local d="${T}/bfd-linker"
    mkdir -p "${d}"
    - ln -sf $(which ${CHOST}-ld.bfd) "${d}"/ld
    + ln -sf $(type -P ${CHOST}-ld.bfd) "${d}"/ld
    flags+=( -B"${d}" )
    fi
    output_format=$($(tc-getCC) "${flags[@]}" 2>&1 | sed -n 's/^OUTPUT_FORMAT("\([^"]*\)"