about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMoritz Angermann <moritz.angermann@gmail.com>2023-02-18 13:19:47 +0000
committerMoritz Angermann <moritz.angermann@gmail.com>2023-02-18 13:19:47 +0000
commitbd4cdf346c0e43f56b1055fc649b9e9987acd601 (patch)
tree2054a8f1a91350ce4276db9d92e9ebf1a2eae411
parentf47ea8fbf7e638167dc045d34e820b8516c1683e (diff)
android-ndk: allow -no-pie
We add -pie if we don't find -shared in the arguments. However this does not
work in the presense of @response files.  We also do not respect -no-pie, and
add -pie regardless. This improves the argument parsing, and allows to prevent
the forced -pie flag.
-rw-r--r--pkgs/development/androidndk-pkgs/androidndk-pkgs.nix3
1 files changed, 2 insertions, 1 deletions
diff --git a/pkgs/development/androidndk-pkgs/androidndk-pkgs.nix b/pkgs/development/androidndk-pkgs/androidndk-pkgs.nix
index 5c04ca4a50ffa..475fe4564eee9 100644
--- a/pkgs/development/androidndk-pkgs/androidndk-pkgs.nix
+++ b/pkgs/development/androidndk-pkgs/androidndk-pkgs.nix
@@ -133,7 +133,8 @@ rec {
       # Use -fPIC for compilation, and link with -pie if no -shared flag used in ldflags
       echo "-target ${targetInfo.triple} -fPIC" >> $out/nix-support/cc-cflags
       echo "-z,noexecstack -z,relro -z,now -z,muldefs" >> $out/nix-support/cc-ldflags
-      echo 'if [[ ! " $@ " =~ " -shared " ]]; then NIX_LDFLAGS_${suffixSalt}+=" -pie"; fi' >> $out/nix-support/add-flags.sh
+      echo 'expandResponseParams "$@"' >> $out/nix-support/add-flags.sh
+      echo 'if [[ ! (" ''${params[@]} " =~ " -shared ") && ! (" ''${params[@]} " =~ " -no-pie ") ]]; then NIX_LDFLAGS_${suffixSalt}+=" -pie"; fi' >> $out/nix-support/add-flags.sh
       echo "-Xclang -mnoexecstack" >> $out/nix-support/cc-cxxflags
       if [ ${targetInfo.triple} == arm-linux-androideabi ]; then
         # https://android.googlesource.com/platform/external/android-cmake/+/refs/heads/cmake-master-dev/android.toolchain.cmake