summary refs log tree commit diff
path: root/pkgs/test
diff options
context:
space:
mode:
authorJörg Thalheim <joerg@thalheim.io>2020-12-25 21:52:42 +0100
committerJörg Thalheim <joerg@thalheim.io>2020-12-27 16:42:11 +0100
commit61bbbcd1af1c3b5a365423f2ecc722a627ff353f (patch)
treed5bd5d7b10f26bad5c5ee4507361a911f94c8be7 /pkgs/test
parent7659201d58cd85b215e561068a2c96bf760c002b (diff)
downloadnixpkgs-61bbbcd1af1c3b5a365423f2ecc722a627ff353f.tar
nixpkgs-61bbbcd1af1c3b5a365423f2ecc722a627ff353f.tar.gz
nixpkgs-61bbbcd1af1c3b5a365423f2ecc722a627ff353f.tar.bz2
nixpkgs-61bbbcd1af1c3b5a365423f2ecc722a627ff353f.tar.lz
nixpkgs-61bbbcd1af1c3b5a365423f2ecc722a627ff353f.tar.xz
nixpkgs-61bbbcd1af1c3b5a365423f2ecc722a627ff353f.tar.zst
nixpkgs-61bbbcd1af1c3b5a365423f2ecc722a627ff353f.zip
bintools-wrapper: skip dynamic linker for static binaries
Diffstat (limited to 'pkgs/test')
-rw-r--r--pkgs/test/cc-wrapper/default.nix23
1 files changed, 19 insertions, 4 deletions
diff --git a/pkgs/test/cc-wrapper/default.nix b/pkgs/test/cc-wrapper/default.nix
index c0c89d63fff..fae3448c44c 100644
--- a/pkgs/test/cc-wrapper/default.nix
+++ b/pkgs/test/cc-wrapper/default.nix
@@ -1,11 +1,13 @@
-{ stdenv }:
+{ stdenv, glibc }:
 with stdenv.lib;
 let
   # Sanitizers are not supported on Darwin.
   # Sanitizer headers aren't available in older libc++ stdenvs due to a bug
-  sanitizersWorking =
-       (stdenv.cc.isClang && versionAtLeast (getVersion stdenv.cc.name) "5.0.0")
-    || (stdenv.cc.isGNU && stdenv.isLinux);
+  sanitizersWorking = !stdenv.hostPlatform.isMusl && (
+    (stdenv.cc.isClang && versionAtLeast (getVersion stdenv.cc.name) "5.0.0")
+    || (stdenv.cc.isGNU && stdenv.isLinux)
+  );
+  staticLibc = optionalString (stdenv.hostPlatform.libc == "glibc") "-L ${glibc.static}/lib";
 in stdenv.mkDerivation {
   name = "cc-wrapper-test";
 
@@ -28,6 +30,19 @@ in stdenv.mkDerivation {
       ./core-foundation-check
     ''}
 
+
+    ${optionalString (!stdenv.isDarwin) ''
+      printf "checking whether compiler builds valid static C binaries... " >&2
+      $CC ${staticLibc} -static -o cc-static ${./cc-main.c}
+      ./cc-static
+      # our glibc does not have pie enabled yet.
+      ${optionalString (stdenv.hostPlatform.isMusl && stdenv.cc.isGNU) ''
+        printf "checking whether compiler builds valid static pie C binaries... " >&2
+        $CC ${staticLibc} -static-pie -o cc-static-pie ${./cc-main.c}
+        ./cc-static-pie
+      ''}
+    ''}
+
     printf "checking whether compiler uses NIX_CFLAGS_COMPILE... " >&2
     mkdir -p foo/include
     cp ${./foo.c} foo/include/foo.h