From c6e871f634db9f868eb95662fc33ef9a94ce2c65 Mon Sep 17 00:00:00 2001 From: Artturin Date: Tue, 21 Mar 2023 19:53:58 +0200 Subject: newlib: improve the nano version apply patch from gentoo because there's no libstdc++.a libsupc++.a or their nano versions this matches upstream arm more https://developer.arm.com/downloads/-/arm-gnu-toolchain-downloads -lc_nano is used in nano.specs but 'libc_nano.a' is not installed without these changes --- pkgs/development/misc/newlib/default.nix | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) (limited to 'pkgs/development/misc') diff --git a/pkgs/development/misc/newlib/default.nix b/pkgs/development/misc/newlib/default.nix index 60ad50a8e4f7a..9983d2f9ab91c 100644 --- a/pkgs/development/misc/newlib/default.nix +++ b/pkgs/development/misc/newlib/default.nix @@ -1,19 +1,28 @@ -{ stdenv, fetchurl, buildPackages +{ stdenv, fetchurl, buildPackages, lib, fetchpatch , # "newlib-nano" is what the official ARM embedded toolchain calls this build # configuration that prioritizes low space usage. We include it as a preset # for embedded projects striving for a similar configuration. nanoizeNewlib ? false }: -stdenv.mkDerivation rec { +stdenv.mkDerivation (finalAttrs: { pname = "newlib"; version = "4.1.0"; src = fetchurl { - url = "ftp://sourceware.org/pub/newlib/newlib-${version}.tar.gz"; + url = "ftp://sourceware.org/pub/newlib/newlib-${finalAttrs.version}.tar.gz"; sha256 = "0m01sjjyj0ib7bwlcrvmk1qkkgd66zf1dhbw716j490kymrf75pj"; }; + patches = lib.optionals nanoizeNewlib [ + # https://bugs.gentoo.org/723756 + (fetchpatch { + name = "newlib-3.3.0-no-nano-cxx.patch"; + url = "https://gitweb.gentoo.org/repo/gentoo.git/plain/sys-libs/newlib/files/newlib-3.3.0-no-nano-cxx.patch?id=9ee5a1cd6f8da6d084b93b3dbd2e8022a147cfbf"; + sha256 = "sha256-S3mf7vwrzSMWZIGE+d61UDH+/SK/ao1hTPee1sElgco="; + }) + ]; + depsBuildBuild = [ buildPackages.stdenv.cc ]; # newlib expects CC to build for build platform, not host platform @@ -45,8 +54,22 @@ stdenv.mkDerivation rec { dontDisableStatic = true; + # apply necessary nano changes from https://developer.arm.com/-/media/Files/downloads/gnu/12.2.rel1/manifest/copy_nano_libraries.sh?rev=4c50be6ccb9c4205a5262a3925317073&hash=1375A7B0A1CD0DB9B9EB0D2B574ADF66 + postInstall = lib.optionalString nanoizeNewlib '' + mkdir -p $out${finalAttrs.passthru.incdir}/newlib-nano + cp $out${finalAttrs.passthru.incdir}/newlib.h $out${finalAttrs.passthru.incdir}/newlib-nano/ + + ( + cd $out${finalAttrs.passthru.libdir} + + for f in librdimon.a libc.a libg.a; do + cp "$f" "''${f%%\.a}_nano.a" + done + ) + ''; + passthru = { incdir = "/${stdenv.targetPlatform.config}/include"; libdir = "/${stdenv.targetPlatform.config}/lib"; }; -} +}) -- cgit 1.4.1 From 13e3b51c998383df221e8c489a3c8192dff50297 Mon Sep 17 00:00:00 2001 From: Artturin Date: Wed, 22 Mar 2023 21:32:04 +0200 Subject: newlib: sync configure flags with upstream removed the common flags to improve the future diffs --- pkgs/development/misc/newlib/default.nix | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) (limited to 'pkgs/development/misc') diff --git a/pkgs/development/misc/newlib/default.nix b/pkgs/development/misc/newlib/default.nix index 9983d2f9ab91c..e44f087d7f8e1 100644 --- a/pkgs/development/misc/newlib/default.nix +++ b/pkgs/development/misc/newlib/default.nix @@ -31,25 +31,32 @@ stdenv.mkDerivation (finalAttrs: { ''; configurePlatforms = [ "build" "target" ]; + # flags copied from https://community.arm.com/support-forums/f/compilers-and-libraries-forum/53310/gcc-arm-none-eabi-what-were-the-newlib-compilation-options + # sort alphabetically configureFlags = [ "--host=${stdenv.buildPlatform.config}" - + ] ++ (if !nanoizeNewlib then [ "--disable-newlib-supplied-syscalls" "--disable-nls" - "--enable-newlib-retargetable-locking" - ] ++ (if !nanoizeNewlib then [ + "--enable-newlib-io-c99-formats" "--enable-newlib-io-long-long" + "--enable-newlib-reent-check-verify" "--enable-newlib-register-fini" + "--enable-newlib-retargetable-locking" ] else [ - "--enable-newlib-reent-small" - "--disable-newlib-fvwrite-in-streamio" "--disable-newlib-fseek-optimization" - "--disable-newlib-wide-orient" - "--enable-newlib-nano-malloc" + "--disable-newlib-fvwrite-in-streamio" + "--disable-newlib-supplied-syscalls" "--disable-newlib-unbuf-stream-opt" + "--disable-newlib-wide-orient" + "--disable-nls" "--enable-lite-exit" "--enable-newlib-global-atexit" "--enable-newlib-nano-formatted-io" + "--enable-newlib-nano-malloc" + "--enable-newlib-reent-check-verify" + "--enable-newlib-reent-small" + "--enable-newlib-retargetable-locking" ]); dontDisableStatic = true; -- cgit 1.4.1 From 116dd693ca46b6bff0f44c714a94175d0e5b6b88 Mon Sep 17 00:00:00 2001 From: Artturin Date: Wed, 22 Mar 2023 22:15:02 +0200 Subject: newlib: 4.1.0 -> 4.3.0.20230120 --- pkgs/development/misc/newlib/default.nix | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'pkgs/development/misc') diff --git a/pkgs/development/misc/newlib/default.nix b/pkgs/development/misc/newlib/default.nix index e44f087d7f8e1..e515ef540aab0 100644 --- a/pkgs/development/misc/newlib/default.nix +++ b/pkgs/development/misc/newlib/default.nix @@ -1,4 +1,4 @@ -{ stdenv, fetchurl, buildPackages, lib, fetchpatch +{ stdenv, fetchurl, buildPackages, lib, fetchpatch, texinfo , # "newlib-nano" is what the official ARM embedded toolchain calls this build # configuration that prioritizes low space usage. We include it as a preset # for embedded projects striving for a similar configuration. @@ -7,11 +7,11 @@ stdenv.mkDerivation (finalAttrs: { pname = "newlib"; - version = "4.1.0"; + version = "4.3.0.20230120"; src = fetchurl { url = "ftp://sourceware.org/pub/newlib/newlib-${finalAttrs.version}.tar.gz"; - sha256 = "0m01sjjyj0ib7bwlcrvmk1qkkgd66zf1dhbw716j490kymrf75pj"; + sha256 = "sha256-g6Yqma9Z4465sMWO0JLuJNcA//Q6IsA+QzlVET7zUVA="; }; patches = lib.optionals nanoizeNewlib [ @@ -23,7 +23,10 @@ stdenv.mkDerivation (finalAttrs: { }) ]; - depsBuildBuild = [ buildPackages.stdenv.cc ]; + depsBuildBuild = [ + buildPackages.stdenv.cc + texinfo # for makeinfo + ]; # newlib expects CC to build for build platform, not host platform preConfigure = '' -- cgit 1.4.1 From eca3d38d188dd9d9ebb60a502ba42a6ca92d550d Mon Sep 17 00:00:00 2001 From: Artturin Date: Wed, 22 Mar 2023 22:27:31 +0200 Subject: newlib: add meta --- pkgs/development/misc/newlib/default.nix | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'pkgs/development/misc') diff --git a/pkgs/development/misc/newlib/default.nix b/pkgs/development/misc/newlib/default.nix index e515ef540aab0..4ec603f250d52 100644 --- a/pkgs/development/misc/newlib/default.nix +++ b/pkgs/development/misc/newlib/default.nix @@ -82,4 +82,17 @@ stdenv.mkDerivation (finalAttrs: { incdir = "/${stdenv.targetPlatform.config}/include"; libdir = "/${stdenv.targetPlatform.config}/lib"; }; + + meta = with lib; { + description = "a C library intended for use on embedded systems"; + homepage = "https://sourceware.org/newlib/"; + # arch has "bsd" while gentoo has "NEWLIB LIBGLOSS GPL-2" while COPYING has "gpl2" + # there are 5 copying files in total + # COPYING + # COPYING.LIB + # COPYING.LIBGLOSS + # COPYING.NEWLIB + # COPYING3 + license = licenses.gpl2Plus; + }; }) -- cgit 1.4.1