Unverified Commit d96726ba authored by John Ericson's avatar John Ericson Committed by GitHub
Browse files

Merge pull request #323402 from obsidiansystems/netbsd-cleanup

netbsd.libcMinimal: Cut down on deps, don't build tags
parents 754f5477 f9dbc8f8
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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
+53 −0
Original line number Diff line number Diff line
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
+20 −9
Original line number Diff line number Diff line
@@ -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;
}