tests.cc-wrapper: add atomics test
`-std=c++17` is for clang 5
This commit is contained in:
parent
f80b2b510d
commit
dabfaef444
8
pkgs/test/cc-wrapper/atomics.cc
Normal file
8
pkgs/test/cc-wrapper/atomics.cc
Normal file
@ -0,0 +1,8 @@
|
||||
#include <atomic>
|
||||
#include <cstdint>
|
||||
|
||||
int main()
|
||||
{
|
||||
std::atomic_int x = {0};
|
||||
return !std::atomic_is_lock_free(&x);
|
||||
}
|
@ -9,7 +9,8 @@ let
|
||||
);
|
||||
staticLibc = lib.optionalString (stdenv.hostPlatform.libc == "glibc") "-L ${glibc.static}/lib";
|
||||
emulator = stdenv.hostPlatform.emulator buildPackages;
|
||||
libcxxStdenvSuffix = lib.optionalString (stdenv.cc.libcxx != null) "-libcxx";
|
||||
isCxx = stdenv.cc.libcxx != null;
|
||||
libcxxStdenvSuffix = lib.optionalString isCxx "-libcxx";
|
||||
in stdenv.mkDerivation {
|
||||
pname = "cc-wrapper-test-${stdenv.cc.cc.pname}${libcxxStdenvSuffix}";
|
||||
version = stdenv.cc.version;
|
||||
@ -37,6 +38,14 @@ in stdenv.mkDerivation {
|
||||
$CXX -o include-cxxabi ${./include-cxxabi.cc}
|
||||
${emulator} ./include-cxxabi
|
||||
|
||||
# cxx doesn't have libatomic.so
|
||||
${lib.optionalString (!isCxx) ''
|
||||
# https://github.com/NixOS/nixpkgs/issues/91285
|
||||
echo "checking whether libatomic.so can be linked... " >&2
|
||||
$CXX -shared -o atomics.so ${./atomics.cc} -latomic ${lib.optionalString (stdenv.cc.isClang && lib.versionOlder stdenv.cc.version "6.0.0" ) "-std=c++17"}
|
||||
$READELF -d ./atomics.so | grep libatomic.so && echo "ok" >&2 || echo "failed" >&2
|
||||
''}
|
||||
|
||||
${lib.optionalString (stdenv.isDarwin && stdenv.cc.isClang) ''
|
||||
echo "checking whether compiler can build with CoreFoundation.framework... " >&2
|
||||
mkdir -p foo/lib
|
||||
|
Loading…
Reference in New Issue
Block a user