3
0
Fork 0
forked from mirrors/nixpkgs

Add clang multilib variants (x64_64-only, 64/32bit), basic multilib tests

This commit is contained in:
Will Dietz 2017-11-30 13:10:41 -06:00
parent 115bf9d2cf
commit 9d8f9b2e53
4 changed files with 99 additions and 0 deletions

View file

@ -0,0 +1,44 @@
{ runCommand,
clang,
gcc64,
gcc32,
glibc_multi
}:
let
combine = basegcc: runCommand "combine-gcc-libc" {} ''
mkdir -p $out
cp -r ${basegcc.cc}/lib $out/lib
chmod u+rw -R $out/lib
cp -r ${basegcc.libc}/lib/* $(ls -d $out/lib/gcc/*/*)
'';
gcc_multi_sysroot = runCommand "gcc-multi-sysroot" {} ''
mkdir -p $out/lib/gcc
ln -s ${combine gcc64}/lib/gcc/* $out/lib/gcc/
ln -s ${combine gcc32}/lib/gcc/* $out/lib/gcc/
# XXX: This shouldn't be needed, clang just doesn't look for "i686-unknown"
ln -s $out/lib/gcc/i686-unknown-linux-gnu $out/lib/gcc/i686-pc-linux-gnu
# includes
ln -s ${glibc_multi.dev}/include $out/
# dynamic linkers
mkdir -p $out/lib/32
ln -s ${glibc_multi.out}/lib/ld-linux* $out/lib
ln -s ${glibc_multi.out}/lib/32/ld-linux* $out/lib/32/
'';
clangMulti = clang.override {
# Only used for providing expected structure re:dynamic linkers, AFAIK
# Most of the magic is done by setting the --gcc-toolchain option below
libc = gcc_multi_sysroot;
extraBuildCommands = ''
sed -e '$a --gcc-toolchain=${gcc_multi_sysroot}' -i $out/nix-support/libc-cflags
'';
};
in clangMulti

View file

@ -0,0 +1,37 @@
{ stdenv }:
stdenv.mkDerivation {
name = "cc-multilib-test";
# XXX: "depend" on cc-wrapper test?
# TODO: Have tests report pointer size or something; ensure they are what we asked for
buildCommand = ''
NIX_DEBUG=1 $CC -v
NIX_DEBUG=1 $CXX -v
printf "checking whether compiler builds valid C binaries... " >&2
$CC -o cc-check ${./cc-main.c}
./cc-check
printf "checking whether compiler builds valid 32bit C binaries... " >&2
$CC -m32 -o c32-check ${./cc-main.c}
./c32-check
printf "checking whether compiler builds valid 64bit C binaries... " >&2
$CC -m64 -o c64-check ${./cc-main.c}
./c64-check
printf "checking whether compiler builds valid 32bit C++ binaries... " >&2
$CXX -m32 -o cxx32-check ${./cxx-main.cc}
./cxx32-check
printf "checking whether compiler builds valid 64bit C++ binaries... " >&2
$CXX -m64 -o cxx64-check ${./cxx-main.cc}
./cxx64-check
touch $out
'';
meta.platforms = stdenv.lib.platforms.x86_64;
}

View file

@ -5579,7 +5579,20 @@ with pkgs;
'';
}) else throw "Multilib ${cc.name} not supported on ${system}";
wrapClangMulti = clang:
if system == "x86_64-linux" then
callPackages ../development/compilers/llvm/multi.nix {
inherit clang;
gcc32 = pkgsi686Linux.gcc;
gcc64 = pkgs.gcc;
}
else throw "Multilib ${clang.cc.name} not supported on '${system}'";
gcc_multi = wrapCCMulti gcc;
clang_multi = wrapClangMulti clang;
gccMultiStdenv = overrideCC stdenv gcc_multi;
clangMultiStdenv = overrideCC stdenv clang_multi;
gcc_debug = lowPrio (wrapCC (gcc.cc.override {
stripped = false;
@ -20040,6 +20053,9 @@ with pkgs;
cc-wrapper-libcxx-5 = callPackage ../test/cc-wrapper { stdenv = llvmPackages_5.libcxxStdenv; };
stdenv-inputs = callPackage ../test/stdenv-inputs { };
cc-multilib-gcc = callPackage ../test/cc-wrapper/multilib.nix { stdenv = gccMultiStdenv; };
cc-multilib-clang = callPackage ../test/cc-wrapper/multilib.nix { stdenv = clangMultiStdenv; };
macOSSierraShared = callPackage ../test/macos-sierra-shared {};
};

View file

@ -112,6 +112,8 @@ let
jobs.tests.cc-wrapper-clang-39.x86_64-darwin
jobs.tests.cc-wrapper-libcxx-39.x86_64-linux
jobs.tests.cc-wrapper-libcxx-39.x86_64-darwin
jobs.tests.cc-multilib-gcc.x86_64-linux
jobs.tests.cc-multilib-clang.x86_64-linux
jobs.tests.stdenv-inputs.x86_64-linux
jobs.tests.stdenv-inputs.x86_64-darwin
jobs.tests.macOSSierraShared.x86_64-darwin