From 166948d4794be5c56c6279bf580ac416b1bcf022 Mon Sep 17 00:00:00 2001 From: Jörg Thalheim Date: Sat, 22 May 2021 13:55:47 +0200 Subject: cc-wrapper: don't set rpath on static-pie executables --- pkgs/build-support/wrapper-common/utils.bash | 35 ++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'pkgs/build-support/wrapper-common') diff --git a/pkgs/build-support/wrapper-common/utils.bash b/pkgs/build-support/wrapper-common/utils.bash index 66b7c3f3e83c5..a0e3225202002 100644 --- a/pkgs/build-support/wrapper-common/utils.bash +++ b/pkgs/build-support/wrapper-common/utils.bash @@ -123,3 +123,38 @@ expandResponseParams() { fi done } + +checkLinkType() { + local arg mode + type="dynamic" + for arg in "$@"; do + if [[ "$arg" = -static ]]; then + type="static" + elif [[ "$arg" = -static-pie ]]; then + type="static-pie" + fi + done + echo "$type" +} + +# When building static-pie executables we cannot have rpath +# set. At least glibc requires rpath to be empty +filterRpathFlags() { + local linkType=$1 ret="" i + shift + + if [[ "$linkType" == "static-pie" ]]; then + while [[ "$#" -gt 0 ]]; do + i="$1"; shift 1 + if [[ "$i" == -rpath ]]; then + # also skip its argument + shift + else + ret+="$i " + fi + done + else + ret=$@ + fi + echo $ret +} -- cgit 1.4.1