Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)

Merge pull request #267717 from Artturin/atomicstest

authored by Artturi and committed by GitHub 6bccf90e 2fc368a8

+37 -18
+8
pkgs/test/cc-wrapper/atomics.cc
··· 1 + #include <atomic> 2 + #include <cstdint> 3 + 4 + int main() 5 + { 6 + std::atomic_int x = {0}; 7 + return !std::atomic_is_lock_free(&x); 8 + }
+10 -1
pkgs/test/cc-wrapper/default.nix
··· 9 9 ); 10 10 staticLibc = lib.optionalString (stdenv.hostPlatform.libc == "glibc") "-L ${glibc.static}/lib"; 11 11 emulator = stdenv.hostPlatform.emulator buildPackages; 12 - libcxxStdenvSuffix = lib.optionalString (stdenv.cc.libcxx != null) "-libcxx"; 12 + isCxx = stdenv.cc.libcxx != null; 13 + libcxxStdenvSuffix = lib.optionalString isCxx "-libcxx"; 13 14 in stdenv.mkDerivation { 14 15 pname = "cc-wrapper-test-${stdenv.cc.cc.pname}${libcxxStdenvSuffix}"; 15 16 version = stdenv.cc.version; ··· 36 37 echo "checking whether cxxabi.h can be included... " >&2 37 38 $CXX -o include-cxxabi ${./include-cxxabi.cc} 38 39 ${emulator} ./include-cxxabi 40 + 41 + # cxx doesn't have libatomic.so 42 + ${lib.optionalString (!isCxx) '' 43 + # https://github.com/NixOS/nixpkgs/issues/91285 44 + echo "checking whether libatomic.so can be linked... " >&2 45 + $CXX -shared -o atomics.so ${./atomics.cc} -latomic ${lib.optionalString (stdenv.cc.isClang && lib.versionOlder stdenv.cc.version "6.0.0" ) "-std=c++17"} 46 + $READELF -d ./atomics.so | grep libatomic.so && echo "ok" >&2 || echo "failed" >&2 47 + ''} 39 48 40 49 ${lib.optionalString (stdenv.isDarwin && stdenv.cc.isClang) '' 41 50 echo "checking whether compiler can build with CoreFoundation.framework... " >&2
+19 -17
pkgs/test/default.nix
··· 39 39 name = "cc-wrapper-supported"; 40 40 builtGCC = 41 41 let 42 - names = lib.pipe (attrNames gccTests) ([ 43 - (filter (n: lib.meta.availableOn stdenv.hostPlatform pkgs.${n}.cc)) 42 + inherit (lib) filterAttrs; 43 + sets = lib.pipe gccTests ([ 44 + (filterAttrs (_: v: lib.meta.availableOn stdenv.hostPlatform v.stdenv.cc)) 44 45 # Broken 45 - (filter (n: n != "gcc49Stdenv")) 46 - (filter (n: n != "gccMultiStdenv")) 46 + (filterAttrs (n: _: n != "gcc49Stdenv")) 47 + (filterAttrs (n: _: n != "gccMultiStdenv")) 47 48 ] ++ lib.optionals (stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isAarch64) [ 48 49 # fails with things like 49 50 # ld: warning: ld: warning: object file (trunctfsf2_s.o) was built for newer macOS version (11.0) than being linked (10.5) 50 51 # ld: warning: ld: warning: could not create compact unwind for ___fixunstfdi: register 20 saved somewhere other than in frame 51 - (filter (n: n != "gcc11Stdenv")) 52 + (filterAttrs (n: _: n != "gcc11Stdenv")) 52 53 ]); 53 54 in 54 - toJSON (lib.genAttrs names (name: { name = pkgs.${name}; })); 55 + toJSON sets; 55 56 56 57 builtLLVM = 57 58 let 58 - names = lib.pipe (attrNames llvmTests) ([ 59 - (filter (n: lib.meta.availableOn stdenv.hostPlatform pkgs.${n}.stdenv.cc)) 60 - (filter (n: lib.meta.availableOn stdenv.hostPlatform pkgs.${n}.libcxxStdenv.cc)) 59 + inherit (lib) filterAttrs; 60 + sets = lib.pipe llvmTests ([ 61 + (filterAttrs (_: v: lib.meta.availableOn stdenv.hostPlatform v.clang.stdenv.cc)) 62 + (filterAttrs (_: v: lib.meta.availableOn stdenv.hostPlatform v.libcxx.stdenv.cc)) 61 63 62 64 # libcxxStdenv broken 63 65 # fix in https://github.com/NixOS/nixpkgs/pull/216273 64 66 ] ++ lib.optionals (stdenv.hostPlatform.isLinux && stdenv.hostPlatform.isAarch64) [ 65 67 # libcxx does not build for some reason on aarch64-linux 66 - (filter (n: n != "llvmPackages_7")) 68 + (filterAttrs (n: _: n != "llvmPackages_7")) 67 69 ] ++ lib.optionals (stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isAarch64) [ 68 - (filter (n: n != "llvmPackages_5")) 69 - (filter (n: n != "llvmPackages_6")) 70 - (filter (n: n != "llvmPackages_7")) 71 - (filter (n: n != "llvmPackages_8")) 72 - (filter (n: n != "llvmPackages_9")) 73 - (filter (n: n != "llvmPackages_10")) 70 + (filterAttrs (n: _: n != "llvmPackages_5")) 71 + (filterAttrs (n: _: n != "llvmPackages_6")) 72 + (filterAttrs (n: _: n != "llvmPackages_7")) 73 + (filterAttrs (n: _: n != "llvmPackages_8")) 74 + (filterAttrs (n: _: n != "llvmPackages_9")) 75 + (filterAttrs (n: _: n != "llvmPackages_10")) 74 76 ]); 75 77 in 76 - toJSON (lib.genAttrs names (name: { stdenv = pkgs.${name}.stdenv; libcxx = pkgs.${name}.libcxxStdenv; })); 78 + toJSON sets; 77 79 buildCommand = '' 78 80 touch $out 79 81 '';