From cf1b7c4d5c027837e71d284a838fbeb05b3fcb7f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6ren=20Tempel?= Date: Sat, 24 Jun 2023 01:13:17 +0200 Subject: [PATCH] newlib: fix build of nano variant on non-ARM architectures librdimon.a is only available on ARM architectures, therefore building newlib-nano for other architectures (e.g. RISC-V) fails presently. This commit fixes this issue by only copying the library files that actually exist in the for loop body. Alternatively, it would be theoretically feasible to change the libraries iterated over based on the targeted architecture. --- pkgs/development/misc/newlib/default.nix | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pkgs/development/misc/newlib/default.nix b/pkgs/development/misc/newlib/default.nix index 4ec603f250d5..d162753608bd 100644 --- a/pkgs/development/misc/newlib/default.nix +++ b/pkgs/development/misc/newlib/default.nix @@ -73,10 +73,12 @@ stdenv.mkDerivation (finalAttrs: { cd $out${finalAttrs.passthru.libdir} for f in librdimon.a libc.a libg.a; do - cp "$f" "''${f%%\.a}_nano.a" + # Some libraries are only available for specific architectures. + # For example, librdimon.a is only available on ARM. + [ -f "$f" ] && cp "$f" "''${f%%\.a}_nano.a" done ) - ''; + '' + ''[ "$(find $out -type f | wc -l)" -gt 0 ] || (echo '$out is empty' 1>&2 && exit 1)''; passthru = { incdir = "/${stdenv.targetPlatform.config}/include";