lol
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

at 23.05-pre 80 lines 2.9 kB view raw
1{ lib, stdenv, glibc }: 2 3let 4 # Sanitizers are not supported on Darwin. 5 # Sanitizer headers aren't available in older libc++ stdenvs due to a bug 6 sanitizersWorking = !stdenv.hostPlatform.isMusl && ( 7 (stdenv.cc.isClang && lib.versionAtLeast (lib.getVersion stdenv.cc.name) "5.0.0") 8 || (stdenv.cc.isGNU && stdenv.isLinux) 9 ); 10 staticLibc = lib.optionalString (stdenv.hostPlatform.libc == "glibc") "-L ${glibc.static}/lib"; 11in stdenv.mkDerivation { 12 name = "cc-wrapper-test"; 13 14 buildCommand = '' 15 NIX_DEBUG=1 $CC -v 16 NIX_DEBUG=1 $CXX -v 17 18 printf "checking whether compiler builds valid C binaries... " >&2 19 $CC -o cc-check ${./cc-main.c} 20 ./cc-check 21 22 printf "checking whether compiler builds valid C++ binaries... " >&2 23 $CXX -o cxx-check ${./cxx-main.cc} 24 ./cxx-check 25 26 ${lib.optionalString (stdenv.isDarwin && stdenv.cc.isClang) '' 27 printf "checking whether compiler can build with CoreFoundation.framework... " >&2 28 mkdir -p foo/lib 29 $CC -framework CoreFoundation -o core-foundation-check ${./core-foundation-main.c} 30 ./core-foundation-check 31 ''} 32 33 34 ${lib.optionalString (!stdenv.isDarwin) '' 35 printf "checking whether compiler builds valid static C binaries... " >&2 36 $CC ${staticLibc} -static -o cc-static ${./cc-main.c} 37 ./cc-static 38 ${lib.optionalString (stdenv.cc.isGNU && lib.versionAtLeast (lib.getVersion stdenv.cc.name) "8.0.0") '' 39 printf "checking whether compiler builds valid static pie C binaries... " >&2 40 $CC ${staticLibc} -static-pie -o cc-static-pie ${./cc-main.c} 41 ./cc-static-pie 42 ''} 43 ''} 44 45 printf "checking whether compiler uses NIX_CFLAGS_COMPILE... " >&2 46 mkdir -p foo/include 47 cp ${./foo.c} foo/include/foo.h 48 NIX_CFLAGS_COMPILE="-Ifoo/include -DVALUE=42" $CC -o cflags-check ${./cflags-main.c} 49 ./cflags-check 50 51 printf "checking whether compiler uses NIX_LDFLAGS... " >&2 52 mkdir -p foo/lib 53 $CC -shared \ 54 ${lib.optionalString stdenv.isDarwin "-Wl,-install_name,@rpath/libfoo.dylib"} \ 55 -DVALUE=42 \ 56 -o foo/lib/libfoo${stdenv.hostPlatform.extensions.sharedLibrary} \ 57 ${./foo.c} 58 59 NIX_LDFLAGS="-L$NIX_BUILD_TOP/foo/lib -rpath $NIX_BUILD_TOP/foo/lib" $CC -lfoo -o ldflags-check ${./ldflags-main.c} 60 ./ldflags-check 61 62 printf "Check whether -nostdinc and -nostdinc++ is handled correctly" >&2 63 mkdir -p std-include 64 cp ${./stdio.h} std-include/stdio.h 65 NIX_DEBUG=1 $CC -I std-include -nostdinc -o nostdinc-main ${./nostdinc-main.c} 66 ./nostdinc-main 67 $CXX -I std-include -nostdinc++ -o nostdinc-main++ ${./nostdinc-main.c} 68 ./nostdinc-main++ 69 70 ${lib.optionalString sanitizersWorking '' 71 printf "checking whether sanitizers are fully functional... ">&2 72 $CC -o sanitizers -fsanitize=address,undefined ${./sanitizers.c} 73 ./sanitizers 74 ''} 75 76 touch $out 77 ''; 78 79 meta.platforms = lib.platforms.all; 80}