From ac59d13857d250b2d2c06f6ad65d69599ce768e1 Mon Sep 17 00:00:00 2001 From: Michael Olbrich Date: Sat, 12 Nov 2022 23:42:45 +0100 Subject: wrapper: try to avoid calling external programs The wrappers are called a lot so making them a bit faster makes a difference. Signed-off-by: Michael Olbrich --- scripts/wrapper/clang++-wrapper | 3 ++- scripts/wrapper/clang-wrapper | 3 ++- scripts/wrapper/cpp-wrapper | 3 ++- scripts/wrapper/g++-wrapper | 3 ++- scripts/wrapper/gcc-wrapper | 3 ++- scripts/wrapper/gdb-wrapper | 3 ++- scripts/wrapper/host-clang++-wrapper | 3 ++- scripts/wrapper/host-clang-wrapper | 3 ++- scripts/wrapper/host-cpp-wrapper | 3 ++- scripts/wrapper/host-g++-wrapper | 3 ++- scripts/wrapper/host-gcc-wrapper | 3 ++- scripts/wrapper/ld-wrapper | 3 ++- scripts/wrapper/libwrapper.sh | 18 ++++++++++++------ 13 files changed, 36 insertions(+), 18 deletions(-) diff --git a/scripts/wrapper/clang++-wrapper b/scripts/wrapper/clang++-wrapper index 0aeec2510..6e393f2a5 100755 --- a/scripts/wrapper/clang++-wrapper +++ b/scripts/wrapper/clang++-wrapper @@ -1,6 +1,7 @@ #!/bin/sh -. "$(dirname "$(readlink -f "$0")")/libwrapper.sh" || exit +WRAPPER_DIR="$(dirname "$(readlink -f "$0")")" +. "${WRAPPER_DIR}/libwrapper.sh" || exit cc_check_args "${@}" diff --git a/scripts/wrapper/clang-wrapper b/scripts/wrapper/clang-wrapper index 9a9ff6da6..8cee4456f 100755 --- a/scripts/wrapper/clang-wrapper +++ b/scripts/wrapper/clang-wrapper @@ -1,6 +1,7 @@ #!/bin/sh -. "$(dirname "$(readlink -f "$0")")/libwrapper.sh" || exit +WRAPPER_DIR="$(dirname "$(readlink -f "$0")")" +. "${WRAPPER_DIR}/libwrapper.sh" || exit cc_check_args "${@}" diff --git a/scripts/wrapper/cpp-wrapper b/scripts/wrapper/cpp-wrapper index b7380adfd..e67ba53df 100755 --- a/scripts/wrapper/cpp-wrapper +++ b/scripts/wrapper/cpp-wrapper @@ -1,6 +1,7 @@ #!/bin/sh -. "$(dirname "$(readlink -f "$0")")/libwrapper.sh" || exit +WRAPPER_DIR="$(dirname "$(readlink -f "$0")")" +. "${WRAPPER_DIR}/libwrapper.sh" || exit cc_check_args "${@}" diff --git a/scripts/wrapper/g++-wrapper b/scripts/wrapper/g++-wrapper index fb5b4b63b..9e4ceb0e0 100755 --- a/scripts/wrapper/g++-wrapper +++ b/scripts/wrapper/g++-wrapper @@ -1,6 +1,7 @@ #!/bin/sh -. "$(dirname "$(readlink -f "$0")")/libwrapper.sh" || exit +WRAPPER_DIR="$(dirname "$(readlink -f "$0")")" +. "${WRAPPER_DIR}/libwrapper.sh" || exit cc_check_args "${@}" diff --git a/scripts/wrapper/gcc-wrapper b/scripts/wrapper/gcc-wrapper index 624938f98..572b3b4a8 100755 --- a/scripts/wrapper/gcc-wrapper +++ b/scripts/wrapper/gcc-wrapper @@ -1,6 +1,7 @@ #!/bin/sh -. "$(dirname "$(readlink -f "$0")")/libwrapper.sh" || exit +WRAPPER_DIR="$(dirname "$(readlink -f "$0")")" +. "${WRAPPER_DIR}/libwrapper.sh" || exit cc_check_args "${@}" diff --git a/scripts/wrapper/gdb-wrapper b/scripts/wrapper/gdb-wrapper index 47c9fe5fe..770239907 100755 --- a/scripts/wrapper/gdb-wrapper +++ b/scripts/wrapper/gdb-wrapper @@ -1,6 +1,7 @@ #!/bin/sh -. "$(dirname "$(readlink -f "$0")")/libwrapper.sh" || exit +WRAPPER_DIR="$(dirname "$(readlink -f "$0")")" +. "${WRAPPER_DIR}/libwrapper.sh" || exit unset PTXDIST_ICECC unset PTXDIST_CCACHE diff --git a/scripts/wrapper/host-clang++-wrapper b/scripts/wrapper/host-clang++-wrapper index f8142462c..812ad7f84 100755 --- a/scripts/wrapper/host-clang++-wrapper +++ b/scripts/wrapper/host-clang++-wrapper @@ -1,6 +1,7 @@ #!/bin/sh -. "$(dirname "$(readlink -f "$0")")/libwrapper.sh" || exit +WRAPPER_DIR="$(dirname "$(readlink -f "$0")")" +. "${WRAPPER_DIR}/libwrapper.sh" || exit HOST=true diff --git a/scripts/wrapper/host-clang-wrapper b/scripts/wrapper/host-clang-wrapper index e1fa8f297..7cc1676cf 100755 --- a/scripts/wrapper/host-clang-wrapper +++ b/scripts/wrapper/host-clang-wrapper @@ -1,6 +1,7 @@ #!/bin/sh -. "$(dirname "$(readlink -f "$0")")/libwrapper.sh" || exit +WRAPPER_DIR="$(dirname "$(readlink -f "$0")")" +. "${WRAPPER_DIR}/libwrapper.sh" || exit HOST=true diff --git a/scripts/wrapper/host-cpp-wrapper b/scripts/wrapper/host-cpp-wrapper index b3a1afe4a..933ed4266 100755 --- a/scripts/wrapper/host-cpp-wrapper +++ b/scripts/wrapper/host-cpp-wrapper @@ -1,6 +1,7 @@ #!/bin/sh -. "$(dirname "$(readlink -f "$0")")/libwrapper.sh" || exit +WRAPPER_DIR="$(dirname "$(readlink -f "$0")")" +. "${WRAPPER_DIR}/libwrapper.sh" || exit HOST=true diff --git a/scripts/wrapper/host-g++-wrapper b/scripts/wrapper/host-g++-wrapper index de4444abe..a91520f5c 100755 --- a/scripts/wrapper/host-g++-wrapper +++ b/scripts/wrapper/host-g++-wrapper @@ -1,6 +1,7 @@ #!/bin/sh -. "$(dirname "$(readlink -f "$0")")/libwrapper.sh" || exit +WRAPPER_DIR="$(dirname "$(readlink -f "$0")")" +. "${WRAPPER_DIR}/libwrapper.sh" || exit HOST=true diff --git a/scripts/wrapper/host-gcc-wrapper b/scripts/wrapper/host-gcc-wrapper index 9887abe8c..b69f038d2 100755 --- a/scripts/wrapper/host-gcc-wrapper +++ b/scripts/wrapper/host-gcc-wrapper @@ -1,6 +1,7 @@ #!/bin/sh -. "$(dirname "$(readlink -f "$0")")/libwrapper.sh" || exit +WRAPPER_DIR="$(dirname "$(readlink -f "$0")")" +. "${WRAPPER_DIR}/libwrapper.sh" || exit HOST=true diff --git a/scripts/wrapper/ld-wrapper b/scripts/wrapper/ld-wrapper index f7ca2b604..5c8a28200 100755 --- a/scripts/wrapper/ld-wrapper +++ b/scripts/wrapper/ld-wrapper @@ -1,6 +1,7 @@ #!/bin/sh -. "$(dirname "$(readlink -f "$0")")/libwrapper.sh" || exit +WRAPPER_DIR="$(dirname "$(readlink -f "$0")")" +. "${WRAPPER_DIR}/libwrapper.sh" || exit unset PTXDIST_CCACHE diff --git a/scripts/wrapper/libwrapper.sh b/scripts/wrapper/libwrapper.sh index 07a7a24ad..75d73007d 100644 --- a/scripts/wrapper/libwrapper.sh +++ b/scripts/wrapper/libwrapper.sh @@ -17,7 +17,7 @@ ARG_LIST="" LATE_ARG_LIST="" if [ -z "${PTXDIST_PLATFORMCONFIG}" ]; then - . "$(dirname "$(readlink -f "${0}")")/env" || exit + . "${WRAPPER_DIR}/env" || exit fi . ${PTXDIST_PLATFORMCONFIG} @@ -31,7 +31,15 @@ if [ ! -e "/proc/self/fd/${PTXDIST_FD_LOGFILE}" ]; then fi wrapper_exec() { - PATH="$(echo "${PATH}" | sed "s;${PTXDIST_PATH_SYSROOT_HOST}/lib/wrapper:;;")" + IFS=: + tmp= + for P in ${PATH}; do + if [ "${P}" != "${PTXDIST_PATH_SYSROOT_HOST}/lib/wrapper" ]; then + tmp="${tmp}${tmp:+:}${P}" + fi + done + unset IFS + PATH="${tmp}" if [ -n "${FAKEROOTKEY}" -o -z "${ICECC_VERSION}" -o ! -e "${ICECC_VERSION}" ]; then PTXDIST_ICECC=${PTXDIST_ICERUN} fi @@ -313,7 +321,7 @@ cxx_add_target_extra() { cc_add_target_reproducible() { add_arg -fdebug-prefix-map="${PTXDIST_PLATFORMDIR%/*}/=" - add_arg -fdebug-prefix-map="$(readlink -f "${PTXDIST_PLATFORMDIR}")/=${PTXDIST_PLATFORMDIR##*/}/" + add_arg -fdebug-prefix-map="${WRAPPER_DIR%/sysroot-host/lib/wrapper}/=${PTXDIST_PLATFORMDIR##*/}/" } cpp_add_host_extra() { @@ -335,7 +343,6 @@ cxx_add_host_extra() { } cc_add_host_clang() { - FULL_CMD=$(readlink "${0%/*}/real/${CMD}") add_arg -gcc-toolchain /usr } @@ -389,11 +396,10 @@ cxx_add_host_icecc() { cc_add_target_clang() { triple="${CMD%-*}" - FULL_CMD=$(readlink "${0%/*}/real/${CMD}") if [ -n "${PTXDIST_SYSROOT_TOOLCHAIN}" ]; then add_arg --sysroot="${PTXDIST_SYSROOT_TOOLCHAIN}" fi - env="$(dirname "${FULL_CMD}")/.${triple}.flags" + env="${FULL_CMD%/*}/.${triple}.flags" if [ -e "${env}" ]; then . "${env}" add_arg ${flags} -- cgit v1.2.3