Merge pull request #222401 from Artturin/newlibincr
This commit is contained in:
commit
4d383f2c4f
1 changed files with 60 additions and 14 deletions
|
@ -1,20 +1,32 @@
|
||||||
{ stdenv, fetchurl, buildPackages
|
{ stdenv, fetchurl, buildPackages, lib, fetchpatch, texinfo
|
||||||
, # "newlib-nano" is what the official ARM embedded toolchain calls this build
|
, # "newlib-nano" is what the official ARM embedded toolchain calls this build
|
||||||
# configuration that prioritizes low space usage. We include it as a preset
|
# configuration that prioritizes low space usage. We include it as a preset
|
||||||
# for embedded projects striving for a similar configuration.
|
# for embedded projects striving for a similar configuration.
|
||||||
nanoizeNewlib ? false
|
nanoizeNewlib ? false
|
||||||
}:
|
}:
|
||||||
|
|
||||||
stdenv.mkDerivation rec {
|
stdenv.mkDerivation (finalAttrs: {
|
||||||
pname = "newlib";
|
pname = "newlib";
|
||||||
version = "4.1.0";
|
version = "4.3.0.20230120";
|
||||||
|
|
||||||
src = fetchurl {
|
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";
|
sha256 = "sha256-g6Yqma9Z4465sMWO0JLuJNcA//Q6IsA+QzlVET7zUVA=";
|
||||||
};
|
};
|
||||||
|
|
||||||
depsBuildBuild = [ buildPackages.stdenv.cc ];
|
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
|
||||||
|
texinfo # for makeinfo
|
||||||
|
];
|
||||||
|
|
||||||
# newlib expects CC to build for build platform, not host platform
|
# newlib expects CC to build for build platform, not host platform
|
||||||
preConfigure = ''
|
preConfigure = ''
|
||||||
|
@ -22,31 +34,65 @@ stdenv.mkDerivation rec {
|
||||||
'';
|
'';
|
||||||
|
|
||||||
configurePlatforms = [ "build" "target" ];
|
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 = [
|
configureFlags = [
|
||||||
"--host=${stdenv.buildPlatform.config}"
|
"--host=${stdenv.buildPlatform.config}"
|
||||||
|
] ++ (if !nanoizeNewlib then [
|
||||||
"--disable-newlib-supplied-syscalls"
|
"--disable-newlib-supplied-syscalls"
|
||||||
"--disable-nls"
|
"--disable-nls"
|
||||||
"--enable-newlib-retargetable-locking"
|
"--enable-newlib-io-c99-formats"
|
||||||
] ++ (if !nanoizeNewlib then [
|
|
||||||
"--enable-newlib-io-long-long"
|
"--enable-newlib-io-long-long"
|
||||||
|
"--enable-newlib-reent-check-verify"
|
||||||
"--enable-newlib-register-fini"
|
"--enable-newlib-register-fini"
|
||||||
|
"--enable-newlib-retargetable-locking"
|
||||||
] else [
|
] else [
|
||||||
"--enable-newlib-reent-small"
|
|
||||||
"--disable-newlib-fvwrite-in-streamio"
|
|
||||||
"--disable-newlib-fseek-optimization"
|
"--disable-newlib-fseek-optimization"
|
||||||
"--disable-newlib-wide-orient"
|
"--disable-newlib-fvwrite-in-streamio"
|
||||||
"--enable-newlib-nano-malloc"
|
"--disable-newlib-supplied-syscalls"
|
||||||
"--disable-newlib-unbuf-stream-opt"
|
"--disable-newlib-unbuf-stream-opt"
|
||||||
|
"--disable-newlib-wide-orient"
|
||||||
|
"--disable-nls"
|
||||||
"--enable-lite-exit"
|
"--enable-lite-exit"
|
||||||
"--enable-newlib-global-atexit"
|
"--enable-newlib-global-atexit"
|
||||||
"--enable-newlib-nano-formatted-io"
|
"--enable-newlib-nano-formatted-io"
|
||||||
|
"--enable-newlib-nano-malloc"
|
||||||
|
"--enable-newlib-reent-check-verify"
|
||||||
|
"--enable-newlib-reent-small"
|
||||||
|
"--enable-newlib-retargetable-locking"
|
||||||
]);
|
]);
|
||||||
|
|
||||||
dontDisableStatic = true;
|
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 = {
|
passthru = {
|
||||||
incdir = "/${stdenv.targetPlatform.config}/include";
|
incdir = "/${stdenv.targetPlatform.config}/include";
|
||||||
libdir = "/${stdenv.targetPlatform.config}/lib";
|
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;
|
||||||
|
};
|
||||||
|
})
|
||||||
|
|
Loading…
Reference in a new issue