Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at 17.09 46 lines 1.5 kB view raw
1{ stdenv }: 2 3stdenv.mkDerivation { 4 name = "cc-wrapper-test"; 5 6 buildCommand = '' 7 NIX_DEBUG=1 $CC -v 8 NIX_DEBUG=1 $CXX -v 9 10 printf "checking whether compiler builds valid C binaries... " >&2 11 $CC -o cc-check ${./cc-main.c} 12 ./cc-check 13 14 printf "checking whether compiler builds valid C++ binaries... " >&2 15 $CXX -o cxx-check ${./cxx-main.cc} 16 ./cxx-check 17 18 ${stdenv.lib.optionalString (stdenv.isDarwin && stdenv.cc.isClang) '' 19 printf "checking whether compiler can build with CoreFoundation.framework... " >&2 20 mkdir -p foo/lib 21 $CC -framework CoreFoundation -o core-foundation-check ${./core-foundation-main.c} 22 ./core-foundation-check 23 ''} 24 25 printf "checking whether compiler uses NIX_CFLAGS_COMPILE... " >&2 26 mkdir -p foo/include 27 cp ${./foo.c} foo/include/foo.h 28 NIX_CFLAGS_COMPILE="-Ifoo/include -DVALUE=42" $CC -o cflags-check ${./cflags-main.c} 29 ./cflags-check 30 31 printf "checking whether compiler uses NIX_LDFLAGS... " >&2 32 mkdir -p foo/lib 33 $CC -shared \ 34 ${stdenv.lib.optionalString stdenv.isDarwin "-Wl,-install_name,@rpath/libfoo.dylib"} \ 35 -DVALUE=42 \ 36 -o foo/lib/libfoo${stdenv.hostPlatform.extensions.sharedLibrary} \ 37 ${./foo.c} 38 39 NIX_LDFLAGS="-L$NIX_BUILD_TOP/foo/lib -rpath $NIX_BUILD_TOP/foo/lib" $CC -lfoo -o ldflags-check ${./ldflags-main.c} 40 ./ldflags-check 41 42 touch $out 43 ''; 44 45 meta.platforms = stdenv.lib.platforms.all; 46}