netbsd.libcMinimal: Cut down on deps, don't build tags

We have a similar patch for OpenBSD too. FreeBSD didn't need it because
they removed a tags special case for libc.
This commit is contained in:
John Ericson 2024-06-20 16:08:04 -04:00
parent 4c6b3609df
commit f9dbc8f83e
3 changed files with 74 additions and 10 deletions

View File

@ -98,7 +98,7 @@ makeScopeWithSplicing' {
inherit (buildNetbsd) makeMinimal;
};
libcMinimal = self.callPackage ./pkgs/libcMinimal.nix {
libcMinimal = self.callPackage ./pkgs/libcMinimal/package.nix {
inherit (self) headers csu;
inherit (buildNetbsd)
netbsdSetupHook

View File

@ -0,0 +1,53 @@
From 62acd447e36d5009d3008e025df72c08690905d5 Mon Sep 17 00:00:00 2001
From: John Ericson <John.Ericson@Obsidian.Systems>
Date: Thu, 20 Jun 2024 15:48:54 -0400
Subject: [PATCH] Allow building libc without generating tags
When bootstrapping from scratch, it is nice to avoid dependencies (like
`ctags`/`genassym`/etc.) that are not strictly needed.
This makefile change introduces a new `MK_LIBC_TAGS` variable, defaulted
to `yes`, to control whether `make all` / `make install` should
build/install (respectively) the tags.
The underlying rules for tags can still be run regardless of the choice
of variable.
---
lib/libc/Makefile | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/lib/libc/Makefile b/lib/libc/Makefile
index f2dab2a090e7..c6aa5e45f959 100644
--- a/lib/libc/Makefile
+++ b/lib/libc/Makefile
@@ -132,7 +132,12 @@ MKREPRO_SED= -e 's;${NETBSDSRCDIR:C/${REGEX_SPECIALS}/\\\\&/g};/usr/src;'
.endif
.if !defined(MLIBDIR) && ${RUMPRUN} != "yes"
+realall: ${SRCS}
+
+.if ${MK_LIBC_TAGS:Uyes} == "yes"
realall: tags
+.endif
+
tags: ${SRCS}
${_MKTARGET_CREATE}
-${TOOL_CTAGS} -f ${.TARGET}.tmp -w ${.ALLSRC:M*.c}
@@ -146,11 +151,14 @@ tags: ${SRCS}
.endif
rm -f ${.TARGET}.tmp
+.if ${MK_LIBC_TAGS:Uyes} == "yes"
FILES= tags
FILESNAME= libc.tags
FILESDIR= /var/db
.endif
+.endif
+
# workaround for I18N stuffs: build singlebyte setlocale() for libc.a,
# multibyte for libc.so. the quirk should be removed when we support
--
2.42.0

View File

@ -28,7 +28,6 @@ mkDerivation {
"out"
"dev"
"man"
"tags"
];
USE_FORT = "yes";
MKPROFILE = "no";
@ -39,32 +38,44 @@ mkDerivation {
"sys"
"external/bsd/jemalloc"
];
patches = [
# https://mail-index.netbsd.org/tech-toolchain/2024/06/24/msg004438.html
#
# The patch is vendored because the archive software inlined my
# attachment so I am not sure how to programmatically download it.
./0001-Allow-building-libc-without-generating-tags.patch
];
nativeBuildInputs = [
bsdSetupHook
netbsdSetupHook
makeMinimal
install
tsort
lorder
mandoc
groff
statHook
flex
byacc
genassym
gencat
lorder
tsort
statHook
rpcgen
];
buildInputs = [
headers
csu
];
env.NIX_CFLAGS_COMPILE = "-B${csu}/lib -fcommon";
meta.platforms = lib.platforms.netbsd;
SHLIBINSTALLDIR = "$(out)/lib";
MKPICINSTALL = "yes";
MK_LIBC_TAGS = "no";
NLSDIR = "$(out)/share/nls";
makeFlags = defaultMakeFlags ++ [ "FILESDIR=$(out)/var/db" ];
postInstall = ''
pushd ${headers}
find include -type d -exec mkdir -p "$dev/{}" ';'
@ -75,11 +86,11 @@ mkDerivation {
find lib -type d -exec mkdir -p "$out/{}" ';'
find lib '(' -type f -o -type l ')' -exec cp -pr "{}" "$out/{}" ';'
popd
moveToOutput var/db/libc.tags "$tags"
'';
postPatch = ''
sed -i 's,/usr\(/include/sys/syscall.h\),${headers}\1,g' lib/lib*/sys/Makefile.inc
'';
meta.platforms = lib.platforms.netbsd;
}