uclibc-ng: fix cross-compile to mips (for ben-nanonote)

Must specify the the TARGET_ARCH (which confusingly is actually
for the host platform, in Nix/autotools terminology) at build and
`make install` time.

Also, auto-disable UCLIBC_HAS_FPU when hostPlatform.gcc.float == "soft".

Clarify platforms = linux and broken = arm to better reflect
the current support situation.

Fixes pkgsCross.ben-nanonote.stdenv
This commit is contained in:
Ryan Burns 2021-12-09 17:12:42 -08:00
parent 581d2d6c9c
commit 2d8304ddc5

View File

@ -39,6 +39,8 @@ let
UCLIBC_SUSV4_LEGACY y
UCLIBC_HAS_THREADS_NATIVE y
KERNEL_HEADERS "${linuxHeaders}/include"
'' + lib.optionalString (stdenv.hostPlatform.gcc.float or "" == "soft") ''
UCLIBC_HAS_FPU n
'' + lib.optionalString (stdenv.isAarch32 && stdenv.buildPlatform != stdenv.hostPlatform) ''
CONFIG_ARM_EABI y
ARCH_WANTS_BIG_ENDIAN n
@ -81,7 +83,8 @@ stdenv.mkDerivation {
depsBuildBuild = [ buildPackages.stdenv.cc ];
makeFlags = [
"ARCH=${stdenv.hostPlatform.parsed.cpu.name}"
"ARCH=${stdenv.hostPlatform.linuxArch}"
"TARGET_ARCH=${stdenv.hostPlatform.linuxArch}"
"VERBOSE=1"
] ++ lib.optionals (stdenv.buildPlatform != stdenv.hostPlatform) [
"CROSS=${stdenv.cc.targetPrefix}"
@ -93,7 +96,7 @@ stdenv.mkDerivation {
installPhase = ''
mkdir -p $out
make PREFIX=$out VERBOSE=1 install
make $makeFlags PREFIX=$out VERBOSE=1 install
(cd $out/include && ln -s $(ls -d ${linuxHeaders}/include/* | grep -v "scsi$") .)
# libpthread.so may not exist, so I do || true
sed -i s@/lib/@$out/lib/@g $out/lib/libc.so $out/lib/libpthread.so || true
@ -109,6 +112,7 @@ stdenv.mkDerivation {
description = "A small implementation of the C library";
maintainers = with maintainers; [ rasendubi ];
license = licenses.lgpl2;
platforms = intersectLists platforms.linux platforms.x86; # fails to build on ARM
platforms = platforms.linux;
broken = stdenv.hostPlatform.isAarch32 || stdenv.hostPlatform.isAarch64;
};
}