about summary refs log tree commit diff
path: root/pkgs/build-support/wrapper-common
diff options
context:
space:
mode:
authorJörg Thalheim <Mic92@users.noreply.github.com>2021-05-25 06:32:25 +0100
committerGitHub <noreply@github.com>2021-05-25 06:32:25 +0100
commit5551a785784e839d68c65b3e2daf81916d165c29 (patch)
treed9d702511de64680a184f9275949fd5bddc6811d /pkgs/build-support/wrapper-common
parent18d250069d6a23479ffea1682476dfb3888b40d4 (diff)
parent602b5f8747e63ff737d48e6f18c8fd35168a707c (diff)
Merge pull request #123989 from Mic92/static-pie
glibc: allow to build position-independent static executable
Diffstat (limited to 'pkgs/build-support/wrapper-common')
-rw-r--r--pkgs/build-support/wrapper-common/utils.bash35
1 files changed, 35 insertions, 0 deletions
diff --git a/pkgs/build-support/wrapper-common/utils.bash b/pkgs/build-support/wrapper-common/utils.bash
index f773270f7de94..cb3552ebc54b7 100644
--- a/pkgs/build-support/wrapper-common/utils.bash
+++ b/pkgs/build-support/wrapper-common/utils.bash
@@ -129,3 +129,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
+}