From 06b05d2289599dd434b6991fa25685ce5cb9a136 Mon Sep 17 00:00:00 2001 From: Artemis Tosini Date: Sat, 27 Apr 2024 02:22:23 +0000 Subject: [PATCH 1/2] freebsd: Cleanup, get ready to support version 14 * Extend libc Include non-libc core libraries in the libc package. Many of these mirror libraries present in glibc on linux, such as libgcc, libraries used for iconv, and libraries used for reading kernel info (libkvm, libprocstat, libmemstat). Without this many packages outside the freebsd tree would need to be modified to include standard dependencies which would already be on the system for other packages. * Mark FreeBSD as using LLVM * Update default LLVM version FreeBSD * Use patch monolith The patchesRoot system combined with the fact that each derivation will Request specific names of patches makes it very annoying to use other FreeBSD source trees with nixpkgs. This new system allows providing one Or more entire trees of patches whose contents will be dynamically Parsed and only the relevant patches will be applied for any one Derivation. With this commit, the following knobs are available for specifying the FreeBSD source: - overriding `freebsd.versionInfo`, for picking another official supported FreeBSD release. - overriding `freebsd.source` for specifying a specific unpatched FreeBSD source tree. - overriding `freebsd.patches`, for specifying the patches to apply. Co-Authored-by: Audrey Dutcher Co-Authored-by: John Ericson --- lib/systems/default.nix | 2 + pkgs/os-specific/bsd/freebsd/package-set.nix | 28 +- .../freebsd/patches/13.1/mtree-Makefile.patch | 13 + .../bsd/freebsd/pkgs/compat/package.nix | 24 +- pkgs/os-specific/bsd/freebsd/pkgs/csu.nix | 1 + .../bsd/freebsd/pkgs/ctfconvert.nix | 23 +- .../bsd/freebsd/pkgs/filterSource.nix | 23 ++ .../pkgs/freebsdSetupHook/setup-hook.sh | 11 + .../bsd/freebsd/pkgs/include/package.nix | 26 +- pkgs/os-specific/bsd/freebsd/pkgs/install.nix | 20 +- .../bsd/freebsd/pkgs/libc/package.nix | 272 +++++++++++++----- .../os-specific/bsd/freebsd/pkgs/libdwarf.nix | 23 +- pkgs/os-specific/bsd/freebsd/pkgs/libelf.nix | 35 --- pkgs/os-specific/bsd/freebsd/pkgs/libmd.nix | 49 ++++ .../bsd/freebsd/pkgs/libnetbsd/package.nix | 7 - pkgs/os-specific/bsd/freebsd/pkgs/libspl.nix | 23 +- pkgs/os-specific/bsd/freebsd/pkgs/libutil.nix | 1 - pkgs/os-specific/bsd/freebsd/pkgs/lorder.nix | 3 +- .../bsd/freebsd/pkgs/makeMinimal.nix | 4 +- .../bsd/freebsd/pkgs/mkDerivation.nix | 111 +++++-- .../bsd/freebsd/pkgs/mkcsmapper.nix | 22 ++ pkgs/os-specific/bsd/freebsd/pkgs/mkesdb.nix | 19 ++ pkgs/os-specific/bsd/freebsd/pkgs/mtree.nix | 37 ++- .../bsd/freebsd/pkgs/rpcgen/package.nix | 4 +- .../rpcgen}/rpcgen-glibc-hack.patch | 0 pkgs/os-specific/bsd/freebsd/pkgs/sed.nix | 3 +- pkgs/os-specific/bsd/freebsd/pkgs/source.nix | 1 - .../bsd/freebsd/pkgs/sys/package.nix | 9 +- pkgs/os-specific/bsd/freebsd/pkgs/tsort.nix | 7 + .../netbsd/pkgs/netbsdSetupHook/setup-hook.sh | 1 + pkgs/os-specific/bsd/setup-hook.sh | 1 - pkgs/top-level/all-packages.nix | 6 +- pkgs/top-level/stage.nix | 4 +- 33 files changed, 558 insertions(+), 255 deletions(-) create mode 100644 pkgs/os-specific/bsd/freebsd/patches/13.1/mtree-Makefile.patch create mode 100644 pkgs/os-specific/bsd/freebsd/pkgs/filterSource.nix delete mode 100644 pkgs/os-specific/bsd/freebsd/pkgs/libelf.nix create mode 100644 pkgs/os-specific/bsd/freebsd/pkgs/libmd.nix create mode 100644 pkgs/os-specific/bsd/freebsd/pkgs/mkcsmapper.nix create mode 100644 pkgs/os-specific/bsd/freebsd/pkgs/mkesdb.nix rename pkgs/os-specific/bsd/freebsd/{patches/13.1 => pkgs/rpcgen}/rpcgen-glibc-hack.patch (100%) diff --git a/lib/systems/default.nix b/lib/systems/default.nix index 7e9aadeef72e..fbd6c323bf42 100644 --- a/lib/systems/default.nix +++ b/lib/systems/default.nix @@ -81,6 +81,8 @@ let && final.parsed.kernel == platform.parsed.kernel; isCompatible = _: throw "2022-05-23: isCompatible has been removed in favor of canExecute, refer to the 22.11 changelog for details"; # Derived meta-data + useLLVM = final.isFreeBSD; + libc = /**/ if final.isDarwin then "libSystem" else if final.isMinGW then "msvcrt" diff --git a/pkgs/os-specific/bsd/freebsd/package-set.nix b/pkgs/os-specific/bsd/freebsd/package-set.nix index 000377c6af91..dfde4a0a31fa 100644 --- a/pkgs/os-specific/bsd/freebsd/package-set.nix +++ b/pkgs/os-specific/bsd/freebsd/package-set.nix @@ -17,6 +17,7 @@ lib.packagesFromDirectoryRecursive { } // { inherit sourceData patchesRoot versionData; + patches = ./patches/${self.versionData.revision}; # Keep the crawled portion of Nixpkgs finite. buildFreebsd = lib.dontRecurseIntoAttrs buildFreebsd; @@ -26,7 +27,8 @@ lib.packagesFromDirectoryRecursive { sha256 = "BpHqJfnGOeTE7tkFJBx0Wk8ryalmf4KNTit/Coh026E="; }; - compatIfNeeded = lib.optional (!stdenvNoCC.hostPlatform.isFreeBSD) self.compat; + compatIsNeeded = !stdenvNoCC.hostPlatform.isFreeBSD; + compatIfNeeded = lib.optional self.compatIsNeeded self.compat; freebsd-lib = import ./lib { version = lib.concatStringsSep "." ( map toString ( @@ -44,7 +46,7 @@ lib.packagesFromDirectoryRecursive { compat = self.callPackage ./pkgs/compat/package.nix { inherit stdenv; - inherit (buildFreebsd) makeMinimal boot-install; + inherit (buildFreebsd) makeMinimal; }; csu = self.callPackage ./pkgs/csu.nix { @@ -52,13 +54,11 @@ lib.packagesFromDirectoryRecursive { inherit (self) include; }; - include = self.callPackage ./pkgs/include/package.nix { - inherit (buildFreebsd) makeMinimal install rpcgen; - }; + include = self.callPackage ./pkgs/include/package.nix { inherit (buildFreebsd) rpcgen mtree; }; install = self.callPackage ./pkgs/install.nix { inherit (buildFreebsd) makeMinimal; - inherit (self) mtree libnetbsd; + inherit (self) libmd libnetbsd; }; libc = self.callPackage ./pkgs/libc/package.nix { @@ -67,16 +67,30 @@ lib.packagesFromDirectoryRecursive { install gencat rpcgen + mkcsmapper + mkesdb ; inherit (self) csu include; }; libnetbsd = self.callPackage ./pkgs/libnetbsd/package.nix { inherit (buildFreebsd) makeMinimal; }; + libmd = self.callPackage ./pkgs/libmd.nix { inherit (buildFreebsd) makeMinimal; }; + mkDerivation = self.callPackage ./pkgs/mkDerivation.nix { inherit stdenv; - inherit (buildFreebsd) makeMinimal install tsort; + inherit (buildFreebsd) + freebsdSetupHook + makeMinimal + install + tsort + lorder + ; }; makeMinimal = self.callPackage ./pkgs/makeMinimal.nix { inherit (self) make; }; + + mtree = self.callPackage ./pkgs/mtree.nix { inherit (self) libnetbsd libmd; }; + + tsort = self.callPackage ./pkgs/tsort.nix { inherit (buildFreebsd) makeMinimal install; }; } diff --git a/pkgs/os-specific/bsd/freebsd/patches/13.1/mtree-Makefile.patch b/pkgs/os-specific/bsd/freebsd/patches/13.1/mtree-Makefile.patch new file mode 100644 index 000000000000..2a6e560d1d28 --- /dev/null +++ b/pkgs/os-specific/bsd/freebsd/patches/13.1/mtree-Makefile.patch @@ -0,0 +1,13 @@ +--- a/contrib/mtree/Makefile 2023-12-04 23:02:13.919144141 -0700 ++++ b/contrib/mtree/Makefile 2023-12-04 23:02:58.371810109 -0700 +@@ -10,8 +10,8 @@ + SRCS= compare.c crc.c create.c excludes.c misc.c mtree.c spec.c specspec.c \ + verify.c getid.c pack_dev.c only.c + .if (${HOSTPROG:U} == "") +-DPADD+= ${LIBUTIL} +-LDADD+= -lutil ++LIBADD+= ${LIBUTIL} ++#LIBADD+= -lutil + .endif + + CPPFLAGS+= -I${NETBSDSRCDIR}/sbin/mknod diff --git a/pkgs/os-specific/bsd/freebsd/pkgs/compat/package.nix b/pkgs/os-specific/bsd/freebsd/pkgs/compat/package.nix index be3a7a910474..a002bcfce53f 100644 --- a/pkgs/os-specific/bsd/freebsd/pkgs/compat/package.nix +++ b/pkgs/os-specific/bsd/freebsd/pkgs/compat/package.nix @@ -2,7 +2,7 @@ lib, stdenv, mkDerivation, - patchesRoot, + versionData, bsdSetupHook, freebsdSetupHook, makeMinimal, @@ -17,7 +17,7 @@ let inherit (freebsd-lib) mkBsdArch; in -mkDerivation rec { +mkDerivation { pname = "compat"; path = "tools/build"; extraPaths = @@ -80,6 +80,12 @@ mkDerivation rec { "sys/sys/font.h" "sys/sys/consio.h" "sys/sys/fnv_hash.h" + #"sys/sys/cdefs.h" + #"sys/sys/param.h" + "sys/sys/_null.h" + #"sys/sys/types.h" + "sys/sys/_pthreadtypes.h" + "sys/sys/_stdint.h" "sys/crypto/chacha20/_chacha.h" "sys/crypto/chacha20/chacha.h" @@ -92,12 +98,11 @@ mkDerivation rec { "lib/libcapsicum" "lib/libcasper" - ]; + "lib/libmd" - patches = [ - /${patchesRoot}/compat-install-dirs.patch - /${patchesRoot}/compat-fix-typedefs-locations.patch - ]; + # idk bro + "sys/sys/kbio.h" + ]; preBuild = '' @@ -151,4 +156,9 @@ mkDerivation rec { + lib.optionalString stdenv.hostPlatform.isDarwin '' cp --no-preserve=mode -r cross-build/include/darwin/* $out/1-include ''; + + # Compat is for making other platforms look like FreeBSD (e.g. to + # build build-time dependencies for building FreeBSD packages). It is + # not needed when building for FreeBSD. + meta.broken = stdenv.hostPlatform.isFreeBSD; } diff --git a/pkgs/os-specific/bsd/freebsd/pkgs/csu.nix b/pkgs/os-specific/bsd/freebsd/pkgs/csu.nix index fd62338d7f9f..0f74d78b1d13 100644 --- a/pkgs/os-specific/bsd/freebsd/pkgs/csu.nix +++ b/pkgs/os-specific/bsd/freebsd/pkgs/csu.nix @@ -12,6 +12,7 @@ }: mkDerivation { + isStatic = true; path = "lib/csu"; extraPaths = [ "lib/Makefile.inc" diff --git a/pkgs/os-specific/bsd/freebsd/pkgs/ctfconvert.nix b/pkgs/os-specific/bsd/freebsd/pkgs/ctfconvert.nix index a85836e58b8d..9e653bb4f51e 100644 --- a/pkgs/os-specific/bsd/freebsd/pkgs/ctfconvert.nix +++ b/pkgs/os-specific/bsd/freebsd/pkgs/ctfconvert.nix @@ -1,15 +1,7 @@ { lib, - stdenv, mkDerivation, - bsdSetupHook, - freebsdSetupHook, - makeMinimal, - install, - mandoc, - groff, compatIfNeeded, - libelf, libdwarf, zlib, libspl, @@ -26,21 +18,18 @@ mkDerivation { ]; OPENSOLARIS_USR_DISTDIR = "$(SRCTOP)/cddl/contrib/opensolaris"; OPENSOLARIS_SYS_DISTDIR = "$(SRCTOP)/sys/cddl/contrib/opensolaris"; - nativeBuildInputs = [ - bsdSetupHook - freebsdSetupHook - makeMinimal - install - mandoc - groff - # flex byacc file2c + makeFlags = [ + "STRIP=-s" + "MK_WERROR=no" + "MK_TESTS=no" ]; + buildInputs = compatIfNeeded ++ [ - libelf libdwarf zlib libspl ]; + meta.license = lib.licenses.cddl; } diff --git a/pkgs/os-specific/bsd/freebsd/pkgs/filterSource.nix b/pkgs/os-specific/bsd/freebsd/pkgs/filterSource.nix new file mode 100644 index 000000000000..dc215c18aecb --- /dev/null +++ b/pkgs/os-specific/bsd/freebsd/pkgs/filterSource.nix @@ -0,0 +1,23 @@ +{ + lib, + pkgsBuildBuild, + runCommand, + writeText, + source, +}: + +{ + pname, + path, + extraPaths ? [ ], +}: + +let + sortedPaths = lib.naturalSort ([ path ] ++ extraPaths); + filterText = writeText "${pname}-src-include" ( + lib.concatMapStringsSep "\n" (path: "/${path}") sortedPaths + ); +in +runCommand "${pname}-filtered-src" { nativeBuildInputs = [ pkgsBuildBuild.rsync ]; } '' + rsync -a -r --files-from=${filterText} ${source}/ $out +'' diff --git a/pkgs/os-specific/bsd/freebsd/pkgs/freebsdSetupHook/setup-hook.sh b/pkgs/os-specific/bsd/freebsd/pkgs/freebsdSetupHook/setup-hook.sh index 929782954ba7..96a3d14c80f7 100644 --- a/pkgs/os-specific/bsd/freebsd/pkgs/freebsdSetupHook/setup-hook.sh +++ b/pkgs/os-specific/bsd/freebsd/pkgs/freebsdSetupHook/setup-hook.sh @@ -5,7 +5,18 @@ setFreeBSDSrcTop() { addFreeBSDMakeFlags() { makeFlags="SBINDIR=${!outputBin}/bin $makeFlags" makeFlags="LIBEXECDIR=${!outputLib}/libexec $makeFlags" + makeFlags="LIBDATADIR=${!outputLib}/data $makeFlags" makeFlags="INCLUDEDIR=${!outputDev}/include $makeFlags" + makeFlags="CONFDIR=${!outputBin}/etc $makeFlags" + makeFlags="MANDIR=${!outputMan}/share/man/man $makeFlags" + + if [ -n "$debug" ]; then + makeFlags="DEBUGFILEDIR=${debug}/lib/debug $makeFlags" + else + makeFlags="DEBUGFILEDIR=${out}/lib/debug $makeFlags" + fi + + echo $makeFlags } postUnpackHooks+=(setFreeBSDSrcTop) diff --git a/pkgs/os-specific/bsd/freebsd/pkgs/include/package.nix b/pkgs/os-specific/bsd/freebsd/pkgs/include/package.nix index fd17dcbb99e0..70734226a54f 100644 --- a/pkgs/os-specific/bsd/freebsd/pkgs/include/package.nix +++ b/pkgs/os-specific/bsd/freebsd/pkgs/include/package.nix @@ -1,19 +1,13 @@ { lib, mkDerivation, - patchesRoot, buildPackages, - bsdSetupHook, - freebsdSetupHook, - makeMinimal, - install, - mandoc, - groff, - rsync, # , nbperf rpcgen, + mtree, }: mkDerivation { + isStatic = true; path = "include"; extraPaths = [ @@ -22,22 +16,11 @@ mkDerivation { "sys" ]; - nativeBuildInputs = [ - bsdSetupHook - freebsdSetupHook - makeMinimal - install - mandoc - groff - rsync # nbperf + extraNativeBuildInputs = [ rpcgen - - # HACK use NetBSD's for now - buildPackages.netbsd.mtree + mtree ]; - patches = [ /${patchesRoot}/no-perms-BSD.include.dist.patch ]; - # The makefiles define INCSDIR per subdirectory, so we have to set # something else on the command line so those definitions aren't # overridden. @@ -46,6 +29,7 @@ mkDerivation { sed -i -E \ -e 's_/usr/include_''${INCSDIR0}_' \ {} \; + sed -E -i -e "/_PATH_LOGIN/d" $BSDSRCDIR/include/paths.h ''; makeFlags = [ "RPCGEN_CPP=${buildPackages.stdenv.cc.cc}/bin/cpp" ]; diff --git a/pkgs/os-specific/bsd/freebsd/pkgs/install.nix b/pkgs/os-specific/bsd/freebsd/pkgs/install.nix index 0f70087618df..b8e59adb09c5 100644 --- a/pkgs/os-specific/bsd/freebsd/pkgs/install.nix +++ b/pkgs/os-specific/bsd/freebsd/pkgs/install.nix @@ -4,7 +4,6 @@ mkDerivation, writeShellScript, freebsd-lib, - mtree, bsdSetupHook, freebsdSetupHook, makeMinimal, @@ -30,7 +29,7 @@ let in mkDerivation { path = "usr.bin/xinstall"; - extraPaths = [ mtree.path ]; + extraPaths = [ "contrib/mtree" ]; nativeBuildInputs = [ bsdSetupHook freebsdSetupHook @@ -44,13 +43,18 @@ mkDerivation { libmd libnetbsd ]; - makeFlags = [ - "STRIP=-s" # flag to install, not command - "MK_WERROR=no" - "TESTSDIR=${builtins.placeholder "test"}" - ] ++ lib.optional (stdenv.hostPlatform == stdenv.buildPlatform) "INSTALL=boot-install"; + makeFlags = + [ + "STRIP=-s" # flag to install, not command + "MK_WERROR=no" + "TESTSDIR=${builtins.placeholder "test"}" + ] + ++ lib.optionals (stdenv.hostPlatform == stdenv.buildPlatform) [ + "BOOTSTRAPPING=1" + "INSTALL=boot-install" + ]; postInstall = '' - install -D -m 0550 ${binstall} $out/bin/binstall + install -C -m 0550 ${binstall} $out/bin/binstall substituteInPlace $out/bin/binstall --subst-var out mv $out/bin/install $out/bin/xinstall ln -s ./binstall $out/bin/install diff --git a/pkgs/os-specific/bsd/freebsd/pkgs/libc/package.nix b/pkgs/os-specific/bsd/freebsd/pkgs/libc/package.nix index 6cf2216ba05f..ac01af113b95 100644 --- a/pkgs/os-specific/bsd/freebsd/pkgs/libc/package.nix +++ b/pkgs/os-specific/bsd/freebsd/pkgs/libc/package.nix @@ -1,8 +1,8 @@ { lib, + buildPackages, stdenv, mkDerivation, - patchesRoot, bsdSetupHook, freebsdSetupHook, @@ -12,62 +12,105 @@ byacc, gencat, rpcgen, + mkcsmapper, + mkesdb, csu, include, + versionData, }: -mkDerivation rec { +mkDerivation { + isStatic = true; pname = "libc"; path = "lib/libc"; - extraPaths = [ - "etc/group" - "etc/master.passwd" - "etc/shells" - "lib/libmd" - "lib/libutil" - "lib/msun" - "sys/kern" - "sys/libkern" - "sys/sys" - "sys/crypto/chacha20" - "include/rpcsvc" - "contrib/jemalloc" - "contrib/gdtoa" - "contrib/libc-pwcache" - "contrib/libc-vis" - "contrib/tzcode/stdtime" + extraPaths = + [ + "lib/libc_nonshared" + "etc/group" + "etc/master.passwd" + "etc/shells" + "lib/libmd" + "lib/libutil" + "lib/msun" + "sys/kern" + "sys/libkern" + "sys/sys" + "sys/crypto/chacha20" + "include/rpcsvc" + "contrib/jemalloc" + "contrib/gdtoa" + "contrib/libc-pwcache" + "contrib/libc-vis" + "contrib/tzcode/stdtime" - # libthr - "lib/libthr" - "lib/libthread_db" - "libexec/rtld-elf" + # libthr + "lib/libthr" + "lib/libthread_db" + "libexec/rtld-elf" + "lib/csu/common/crtbrand.S" + "lib/csu/common/notes.h" - # librpcsvc - "lib/librpcsvc" + # librpcsvc + "lib/librpcsvc" - # librt - "lib/librt" + # librt + "lib/librt" - # libcrypt - "lib/libcrypt" - "lib/libmd" - "sys/crypto/sha2" - ]; + # libcrypt + "lib/libcrypt" + "lib/libmd" + "sys/crypto/sha2" + "sys/crypto/skein" - patches = [ - # Hack around broken propogating MAKEFLAGS to submake, just inline logic - /${patchesRoot}/libc-msun-arch-subdir.patch + # libgcc and friends + "lib/libgcc_eh" + "lib/libgcc_s" + "lib/libcompiler_rt" + "contrib/llvm-project/libunwind" + "contrib/llvm-project/compiler-rt" + #"contrib/llvm-project/libcxx" - # Don't force -lcompiler-rt, we don't actually call it that - /${patchesRoot}/libc-no-force--lcompiler-rt.patch + # terminfo + "lib/ncurses" + "contrib/ncurses" + "lib/Makefile.inc" + ] + ++ lib.optionals (stdenv.hostPlatform.isx86_32) [ "lib/libssp_nonshared" ] + ++ [ + "lib/libexecinfo" + "contrib/libexecinfo" - # Fix extra include dir to get rpcsvc headers. - /${patchesRoot}/librpcsvc-include-subdir.patch - ]; + "lib/libkvm" + "sys" # ummmmmmmmmm libkvm wants arch-specific headers from the kernel tree + + "lib/libmemstat" + + "lib/libprocstat" + "sys/contrib/openzfs" + "sys/contrib/pcg-c" + "sys/opencrypto" + "sys/contrib/ck" + "sys/crypto" + + "lib/libdevstat" + + "lib/libelf" + "contrib/elftoolchain" + + "lib/libiconv_modules" + "share/i18n" + "include/paths.h" + + "lib/libdl" + ]; postPatch = '' substituteInPlace $COMPONENT_PATH/Makefile --replace '.include ' "" + + substituteInPlace $BSDSRCDIR/include/paths.h \ + --replace '/usr/lib/i18n' '${builtins.placeholder "out"}/lib/i18n' \ + --replace '/usr/share/i18n' '${builtins.placeholder "out"}/share/i18n' ''; nativeBuildInputs = [ @@ -80,16 +123,20 @@ mkDerivation rec { byacc gencat rpcgen + mkcsmapper + mkesdb ]; buildInputs = [ include csu ]; - env.NIX_CFLAGS_COMPILE = "-B${csu}/lib"; - - # Suppress lld >= 16 undefined version errors - # https://github.com/freebsd/freebsd-src/commit/2ba84b4bcdd6012e8cfbf8a0d060a4438623a638 - env.NIX_LDFLAGS = lib.optionalString (stdenv.targetPlatform.linker == "lld") "--undefined-version"; + env.NIX_CFLAGS_COMPILE = toString [ + "-B${csu}/lib" + # These are supposed to have _RTLD_COMPAT_LIB_SUFFIX so we can get things like "lib32" + # but that's unnecessary + "-DSTANDARD_LIBRARY_PATH=\"${builtins.placeholder "out"}/lib\"" + "-D_PATH_RTLD=\"${builtins.placeholder "out"}/libexec/ld-elf.so.1\"" + ]; makeFlags = [ "STRIP=-s" # flag to install, not command @@ -100,7 +147,7 @@ mkDerivation rec { MK_SYMVER = "yes"; MK_SSP = "yes"; MK_NLS = "yes"; - MK_ICONV = "no"; # TODO make srctop + MK_ICONV = "yes"; MK_NS_CACHING = "yes"; MK_INET6_SUPPORT = "yes"; MK_HESIOD = "yes"; @@ -112,44 +159,125 @@ mkDerivation rec { MK_MALLOC_PRODUCTION = "yes"; MK_TESTS = "no"; + MACHINE_ABI = ""; + MK_DETECT_TZ_CHANGES = "no"; + MK_MACHDEP_OPTIMIZATIONS = "yes"; + MK_ASAN = "no"; + MK_UBSAN = "no"; - postInstall = '' - pushd ${include} - find . -type d -exec mkdir -p $out/\{} \; - find . \( -type f -o -type l \) -exec cp -pr \{} $out/\{} \; - popd + NO_FSCHG = "yes"; - pushd ${csu} - find . -type d -exec mkdir -p $out/\{} \; - find . \( -type f -o -type l \) -exec cp -pr \{} $out/\{} \; - popd + preBuild = lib.optionalString (stdenv.hostPlatform.isx86_32) '' + make -C $BSDSRCDIR/lib/libssp_nonshared $makeFlags + make -C $BSDSRCDIR/lib/libssp_nonshared $makeFlags install + ''; - sed -i -e 's| [^ ]*/libc_nonshared.a||' $out/lib/libc.so + postInstall = + '' + pushd ${include} + find . -type d -exec mkdir -p $out/\{} \; + find . \( -type f -o -type l \) -exec cp -pr \{} $out/\{} \; + popd - $CC -nodefaultlibs -lgcc -shared -o $out/lib/libgcc_s.so + pushd ${csu} + find . -type d -exec mkdir -p $out/\{} \; + find . \( -type f -o -type l \) -exec cp -pr \{} $out/\{} \; + popd - NIX_CFLAGS_COMPILE+=" -B$out/lib" - NIX_CFLAGS_COMPILE+=" -I$out/include" - NIX_LDFLAGS+=" -L$out/lib" + mkdir $BSDSRCDIR/lib/libcompiler_rt/i386 + make -C $BSDSRCDIR/lib/libcompiler_rt $makeFlags + make -C $BSDSRCDIR/lib/libcompiler_rt $makeFlags install - make -C $BSDSRCDIR/lib/libthr $makeFlags - make -C $BSDSRCDIR/lib/libthr $makeFlags install + make -C $BSDSRCDIR/lib/libgcc_eh $makeFlags + make -C $BSDSRCDIR/lib/libgcc_eh $makeFlags install - make -C $BSDSRCDIR/lib/msun $makeFlags - make -C $BSDSRCDIR/lib/msun $makeFlags install + ln -s $BSDSRCDIR/lib/libc/libc.so.7 $BSDSRCDIR/lib/libc/libc.so # not sure + mkdir $BSDSRCDIR/lib/libgcc_s/i386 + make -C $BSDSRCDIR/lib/libgcc_s $makeFlags + make -C $BSDSRCDIR/lib/libgcc_s $makeFlags install - make -C $BSDSRCDIR/lib/librpcsvc $makeFlags - make -C $BSDSRCDIR/lib/librpcsvc $makeFlags install + NIX_CFLAGS_COMPILE+=" -B$out/lib" + NIX_CFLAGS_COMPILE+=" -I$out/include" + NIX_LDFLAGS+=" -L$out/lib" - make -C $BSDSRCDIR/lib/libutil $makeFlags - make -C $BSDSRCDIR/lib/libutil $makeFlags install + make -C $BSDSRCDIR/lib/libc_nonshared $makeFlags + make -C $BSDSRCDIR/lib/libc_nonshared $makeFlags install - make -C $BSDSRCDIR/lib/librt $makeFlags - make -C $BSDSRCDIR/lib/librt $makeFlags install + mkdir $BSDSRCDIR/lib/libmd/sys + make -C $BSDSRCDIR/lib/libmd $makeFlags + make -C $BSDSRCDIR/lib/libmd $makeFlags install - make -C $BSDSRCDIR/lib/libcrypt $makeFlags - make -C $BSDSRCDIR/lib/libcrypt $makeFlags install + make -C $BSDSRCDIR/lib/libthr $makeFlags + make -C $BSDSRCDIR/lib/libthr $makeFlags install + + make -C $BSDSRCDIR/lib/msun $makeFlags + make -C $BSDSRCDIR/lib/msun $makeFlags install + + make -C $BSDSRCDIR/lib/librpcsvc $makeFlags + make -C $BSDSRCDIR/lib/librpcsvc $makeFlags install + + make -C $BSDSRCDIR/lib/libutil $makeFlags + make -C $BSDSRCDIR/lib/libutil $makeFlags install + + make -C $BSDSRCDIR/lib/librt $makeFlags + make -C $BSDSRCDIR/lib/librt $makeFlags install + + make -C $BSDSRCDIR/lib/libcrypt $makeFlags + make -C $BSDSRCDIR/lib/libcrypt $makeFlags install + + make -C $BSDSRCDIR/lib/libelf $makeFlags + make -C $BSDSRCDIR/lib/libelf $makeFlags install + + make -C $BSDSRCDIR/lib/libexecinfo $makeFlags + make -C $BSDSRCDIR/lib/libexecinfo $makeFlags install + + make -C $BSDSRCDIR/lib/libkvm $makeFlags + make -C $BSDSRCDIR/lib/libkvm $makeFlags install + + make -C $BSDSRCDIR/lib/libmemstat $makeFlags + make -C $BSDSRCDIR/lib/libmemstat $makeFlags install + + make -C $BSDSRCDIR/lib/libprocstat $makeFlags + make -C $BSDSRCDIR/lib/libprocstat $makeFlags install + + make -C $BSDSRCDIR/lib/libdevstat $makeFlags + make -C $BSDSRCDIR/lib/libdevstat $makeFlags install + + make -C $BSDSRCDIR/lib/libiconv_modules $makeFlags + make -C $BSDSRCDIR/lib/libiconv_modules $makeFlags SHLIBDIR=${builtins.placeholder "out"}/lib/i18n install + + make -C $BSDSRCDIR/lib/libdl $makeFlags + make -C $BSDSRCDIR/lib/libdl $makeFlags install + + make -C $BSDSRCDIR/share/i18n $makeFlags + make -C $BSDSRCDIR/share/i18n $makeFlags ESDBDIR=${builtins.placeholder "out"}/share/i18n/esdb CSMAPPERDIR=${builtins.placeholder "out"}/share/i18n/csmapper install + + '' + + lib.optionalString stdenv.hostPlatform.isx86_32 '' + $CC -c $BSDSRCDIR/contrib/llvm-project/compiler-rt/lib/builtins/udivdi3.c -o $BSDSRCDIR/contrib/llvm-project/compiler-rt/lib/builtins/udivdi3.o + ORIG_NIX_LDFLAGS="$NIX_LDFLAGS" + NIX_LDFLAGS+=" $BSDSRCDIR/contrib/llvm-project/compiler-rt/lib/builtins/udivdi3.o" + '' + + '' + make -C $BSDSRCDIR/libexec/rtld-elf $makeFlags + make -C $BSDSRCDIR/libexec/rtld-elf $makeFlags install + rm -f $out/libexec/ld-elf.so.1 + mv $out/bin/ld-elf.so.1 $out/libexec + ''; + + # libc should not be allowed to refer to anything other than itself + postFixup = '' + find $out -type f | xargs -n1 ${buildPackages.patchelf}/bin/patchelf --shrink-rpath --allowed-rpath-prefixes $out || true ''; meta.platforms = lib.platforms.freebsd; + + # definitely a bad idea to enable stack protection on the stack protection initializers + hardeningDisable = [ "stackprotector" ]; + + outputs = [ + "out" + "man" + "debug" + ]; } diff --git a/pkgs/os-specific/bsd/freebsd/pkgs/libdwarf.nix b/pkgs/os-specific/bsd/freebsd/pkgs/libdwarf.nix index 84115b626a7a..ee4d57b021b1 100644 --- a/pkgs/os-specific/bsd/freebsd/pkgs/libdwarf.nix +++ b/pkgs/os-specific/bsd/freebsd/pkgs/libdwarf.nix @@ -1,16 +1,8 @@ { - lib, - stdenv, mkDerivation, - bsdSetupHook, - freebsdSetupHook, - makeMinimal, - install, - mandoc, - groff, m4, compatIfNeeded, - libelf, + zlib, }: mkDerivation { @@ -22,16 +14,7 @@ mkDerivation { "sys/sys/elf64.h" "sys/sys/elf_common.h" ]; - nativeBuildInputs = [ - bsdSetupHook - freebsdSetupHook - makeMinimal - install - mandoc - groff - - m4 - ]; - buildInputs = compatIfNeeded ++ [ libelf ]; + extraNativeBuildInputs = [ m4 ]; + buildInputs = compatIfNeeded ++ [ zlib ]; MK_TESTS = "no"; } diff --git a/pkgs/os-specific/bsd/freebsd/pkgs/libelf.nix b/pkgs/os-specific/bsd/freebsd/pkgs/libelf.nix deleted file mode 100644 index 881cbfcd811c..000000000000 --- a/pkgs/os-specific/bsd/freebsd/pkgs/libelf.nix +++ /dev/null @@ -1,35 +0,0 @@ -{ - lib, - stdenv, - mkDerivation, - bsdSetupHook, - freebsdSetupHook, - makeMinimal, - install, - mandoc, - groff, - m4, -}: - -mkDerivation { - path = "lib/libelf"; - extraPaths = [ - "contrib/elftoolchain/libelf" - "contrib/elftoolchain/common" - "sys/sys/elf32.h" - "sys/sys/elf64.h" - "sys/sys/elf_common.h" - ]; - BOOTSTRAPPING = !stdenv.isFreeBSD; - nativeBuildInputs = [ - bsdSetupHook - freebsdSetupHook - makeMinimal - install - mandoc - groff - - m4 - ]; - MK_TESTS = "no"; -} diff --git a/pkgs/os-specific/bsd/freebsd/pkgs/libmd.nix b/pkgs/os-specific/bsd/freebsd/pkgs/libmd.nix new file mode 100644 index 000000000000..71d0c1e50d5e --- /dev/null +++ b/pkgs/os-specific/bsd/freebsd/pkgs/libmd.nix @@ -0,0 +1,49 @@ +{ + lib, + stdenv, + mkDerivation, + freebsdSetupHook, + bsdSetupHook, + makeMinimal, +}: +mkDerivation { + path = "lib/libmd"; + extraPaths = [ + "sys/sys/md5.h" + "sys/crypto/sha2" + "sys/crypto/skein" + ]; + nativeBuildInputs = [ + makeMinimal + bsdSetupHook + freebsdSetupHook + ]; + + makeFlags = [ + "STRIP=-s" # flag to install, not command + "RELDIR=." + ] ++ lib.optional (!stdenv.hostPlatform.isFreeBSD) "MK_WERROR=no"; + + preBuild = '' + mkdir sys + ''; + + installPhase = '' + # libmd is used by install. do it yourself! + mkdir -p $out/include $out/lib $man/share/man + cp libmd.a $out/lib/libmd.a + for f in $(make $makeFlags -V INCS); do + if [ -e "$f" ]; then cp "$f" "$out/include/$f"; fi + if [ -e "$BSDSRCDIR/sys/crypto/sha2/$f" ]; then cp "$BSDSRCDIR/sys/crypto/sha2/$f" "$out/include/$f"; fi + if [ -e "$BSDSRCDIR/sys/crypto/skein/$f" ]; then cp "$BSDSRCDIR/sys/crypto/skein/$f" "$out/include/$f"; fi + done + for f in $(make $makeFlags -V MAN); do + cp "$f" "$man/share/man/$f" + done + ''; + + outputs = [ + "out" + "man" + ]; +} diff --git a/pkgs/os-specific/bsd/freebsd/pkgs/libnetbsd/package.nix b/pkgs/os-specific/bsd/freebsd/pkgs/libnetbsd/package.nix index 80ea685a3162..82a9e140102f 100644 --- a/pkgs/os-specific/bsd/freebsd/pkgs/libnetbsd/package.nix +++ b/pkgs/os-specific/bsd/freebsd/pkgs/libnetbsd/package.nix @@ -2,7 +2,6 @@ lib, stdenv, mkDerivation, - patchesRoot, bsdSetupHook, freebsdSetupHook, makeMinimal, @@ -10,7 +9,6 @@ groff, boot-install, install, - compatIfNeeded, }: mkDerivation { @@ -23,13 +21,8 @@ mkDerivation { groff (if stdenv.hostPlatform == stdenv.buildPlatform then boot-install else install) ]; - patches = lib.optionals (!stdenv.hostPlatform.isFreeBSD) [ - /${patchesRoot}/libnetbsd-do-install.patch - #/${patchesRoot}/libnetbsd-define-__va_list.patch - ]; makeFlags = [ "STRIP=-s" # flag to install, not command "MK_WERROR=no" ] ++ lib.optional (stdenv.hostPlatform == stdenv.buildPlatform) "INSTALL=boot-install"; - buildInputs = compatIfNeeded; } diff --git a/pkgs/os-specific/bsd/freebsd/pkgs/libspl.nix b/pkgs/os-specific/bsd/freebsd/pkgs/libspl.nix index da5445a09fcd..c444975549ad 100644 --- a/pkgs/os-specific/bsd/freebsd/pkgs/libspl.nix +++ b/pkgs/os-specific/bsd/freebsd/pkgs/libspl.nix @@ -3,19 +3,20 @@ mkDerivation { path = "cddl/lib/libspl"; extraPaths = [ - "sys/contrib/openzfs/lib/libspl" - "sys/contrib/openzfs/include" - "cddl/compat/opensolaris/include" + "sys/contrib/openzfs/include" + "sys/contrib/openzfs/lib/libspl" "sys/contrib/openzfs/module/icp/include" - "sys/modules/zfs" + "sys/modules/zfs/zfs_config.h" ]; - # nativeBuildInputs = [ - # bsdSetupHook freebsdSetupHook - # makeMinimal install mandoc groff - # flex byacc file2c - # ]; - # buildInputs = compatIfNeeded ++ [ libnv libsbuf ]; - meta.license = lib.licenses.cddl; + # Without a prefix it will try to put object files in nonexistant directories + preBuild = '' + export MAKEOBJDIRPREFIX=$TMP/obj + ''; + + meta = with lib; { + platform = platforms.freebsd; + license = licenses.cddl; + }; } diff --git a/pkgs/os-specific/bsd/freebsd/pkgs/libutil.nix b/pkgs/os-specific/bsd/freebsd/pkgs/libutil.nix index 683396d140c2..6df6fa740f45 100644 --- a/pkgs/os-specific/bsd/freebsd/pkgs/libutil.nix +++ b/pkgs/os-specific/bsd/freebsd/pkgs/libutil.nix @@ -6,6 +6,5 @@ mkDerivation { path = "lib/libutil"; extraPaths = [ "lib/libc/gen" ]; - clangFixup = true; MK_TESTS = "no"; } diff --git a/pkgs/os-specific/bsd/freebsd/pkgs/lorder.nix b/pkgs/os-specific/bsd/freebsd/pkgs/lorder.nix index abbe2079855e..25e7f491a1c9 100644 --- a/pkgs/os-specific/bsd/freebsd/pkgs/lorder.nix +++ b/pkgs/os-specific/bsd/freebsd/pkgs/lorder.nix @@ -3,8 +3,7 @@ bsdSetupHook, freebsdSetupHook, }: - -mkDerivation rec { +mkDerivation { path = "usr.bin/lorder"; noCC = true; dontBuild = true; diff --git a/pkgs/os-specific/bsd/freebsd/pkgs/makeMinimal.nix b/pkgs/os-specific/bsd/freebsd/pkgs/makeMinimal.nix index c510a4da4b82..069e74474852 100644 --- a/pkgs/os-specific/bsd/freebsd/pkgs/makeMinimal.nix +++ b/pkgs/os-specific/bsd/freebsd/pkgs/makeMinimal.nix @@ -7,7 +7,7 @@ freebsdSetupHook, }: -mkDerivation rec { +mkDerivation { inherit (make) path; buildInputs = [ ]; @@ -25,6 +25,8 @@ mkDerivation rec { ${make.postPatch} ''; + configureFlags = [ "--with-filemon=no" ]; + buildPhase = '' runHook preBuild diff --git a/pkgs/os-specific/bsd/freebsd/pkgs/mkDerivation.nix b/pkgs/os-specific/bsd/freebsd/pkgs/mkDerivation.nix index b5c962064fad..470cb1cb64bb 100644 --- a/pkgs/os-specific/bsd/freebsd/pkgs/mkDerivation.nix +++ b/pkgs/os-specific/bsd/freebsd/pkgs/mkDerivation.nix @@ -2,11 +2,12 @@ lib, stdenv, stdenvNoCC, + versionData, + writeText, + patches, compatIfNeeded, - runCommand, - rsync, freebsd-lib, - source, + filterSource, bsdSetupHook, freebsdSetupHook, makeMinimal, @@ -24,21 +25,13 @@ lib.makeOverridable ( in stdenv'.mkDerivation ( rec { - pname = "${attrs.pname or (baseNameOf attrs.path)}-freebsd"; inherit (freebsd-lib) version; - src = runCommand "${pname}-filtered-src" { nativeBuildInputs = [ rsync ]; } '' - for p in ${lib.concatStringsSep " " ([ attrs.path ] ++ attrs.extraPaths or [ ])}; do - set -x - path="$out/$p" - mkdir -p "$(dirname "$path")" - src_path="${source}/$p" - if [[ -d "$src_path" ]]; then src_path+=/; fi - rsync --chmod="+w" -r "$src_path" "$path" - set +x - done - ''; - - extraPaths = [ ]; + pname = "${attrs.pname or (baseNameOf attrs.path)}"; + src = filterSource { + inherit pname; + inherit (attrs) path; + extraPaths = attrs.extraPaths or [ ]; + }; nativeBuildInputs = [ bsdSetupHook @@ -48,8 +41,8 @@ lib.makeOverridable ( tsort lorder mandoc - groff # statHook - ]; + groff + ] ++ attrs.extraNativeBuildInputs or [ ]; buildInputs = compatIfNeeded; HOST_SH = stdenv'.shell; @@ -72,11 +65,17 @@ lib.makeOverridable ( strictDeps = true; - meta = with lib; { - maintainers = with maintainers; [ ericson2314 ]; - platforms = platforms.unix; - license = licenses.bsd2; - }; + meta = + with lib; + { + maintainers = with maintainers; [ + rhelmot + artemist + ]; + platforms = platforms.unix; + license = licenses.bsd2; + } + // attrs.meta or { }; } // lib.optionalAttrs stdenv'.hasCC { # TODO should CC wrapper set this? @@ -95,5 +94,69 @@ lib.makeOverridable ( dontBuild = true; } // attrs + // lib.optionalAttrs (stdenv'.hasCC && stdenv'.cc.isClang or false && attrs.clangFixup or true) { + preBuild = + '' + export NIX_CFLAGS_COMPILE="$NIX_CFLAGS_COMPILE -D_VA_LIST -D_VA_LIST_DECLARED -Dva_list=__builtin_va_list -D_SIZE_T_DECLARED -D_SIZE_T -Dsize_t=__SIZE_TYPE__ -D_WCHAR_T" + export NIX_LDFLAGS="$NIX_LDFLAGS --undefined-version" + '' + + (attrs.preBuild or ""); + } + // { + patches = + let + isDir = + file: + let + base = baseNameOf file; + type = (builtins.readDir (dirOf file)).${base} or null; + in + file == /. || type == "directory"; + consolidatePatches = + patches: + if (lib.isDerivation patches) then + [ patches ] + else if (builtins.isPath patches) then + (if (isDir patches) then (lib.filesystem.listFilesRecursive patches) else [ patches ]) + else if (builtins.isList patches) then + (lib.flatten (builtins.map consolidatePatches patches)) + else + throw "Bad patches - must be path or derivation or list thereof"; + consolidated = consolidatePatches patches; + splitPatch = + patchFile: + let + foldFunc = + a: b: + if (lib.strings.hasPrefix "--- " b) then + (a ++ [ [ b ] ]) + else + ((lib.lists.init a) ++ (lib.lists.singleton ((lib.lists.last a) ++ [ b ]))); + partitionedPatches' = lib.lists.foldl foldFunc [ [ ] ] ( + lib.strings.splitString "\n" (builtins.readFile patchFile) + ); + partitionedPatches = + if (builtins.length partitionedPatches' > 1) then + (lib.lists.drop 1 partitionedPatches') + else + (throw "${patchFile} does not seem to be a unified patch (diff -u). this is required for FreeBSD."); + filterFunc = + patchLines: + let + prefixedPath = builtins.elemAt (builtins.split " |\t" (builtins.elemAt patchLines 1)) 2; + unfixedPath = lib.path.subpath.join (lib.lists.drop 1 (lib.path.subpath.components prefixedPath)); + in + lib.lists.any (included: lib.path.hasPrefix (/. + ("/" + included)) (/. + ("/" + unfixedPath))) ( + (attrs.extraPaths or [ ]) ++ [ attrs.path ] + ); + filteredLines = builtins.filter filterFunc partitionedPatches; + derive = patchLines: writeText "freebsd-patch" (lib.concatLines patchLines); + derivedPatches = builtins.map derive filteredLines; + in + derivedPatches; + picked = lib.lists.concatMap splitPatch consolidated; + in + picked ++ attrs.patches or [ ]; + } ) ) diff --git a/pkgs/os-specific/bsd/freebsd/pkgs/mkcsmapper.nix b/pkgs/os-specific/bsd/freebsd/pkgs/mkcsmapper.nix new file mode 100644 index 000000000000..60cef347446e --- /dev/null +++ b/pkgs/os-specific/bsd/freebsd/pkgs/mkcsmapper.nix @@ -0,0 +1,22 @@ +{ + stdenv, + mkDerivation, + byacc, + flex, +}: + +mkDerivation { + path = "usr.bin/mkcsmapper"; + + extraPaths = [ + "lib/libc/iconv" + "lib/libiconv_modules/mapper_std" + ]; + + BOOTSTRAPPING = !stdenv.hostPlatform.isFreeBSD; + + extraNativeBuildInputs = [ + byacc + flex + ]; +} diff --git a/pkgs/os-specific/bsd/freebsd/pkgs/mkesdb.nix b/pkgs/os-specific/bsd/freebsd/pkgs/mkesdb.nix new file mode 100644 index 000000000000..a503af529f27 --- /dev/null +++ b/pkgs/os-specific/bsd/freebsd/pkgs/mkesdb.nix @@ -0,0 +1,19 @@ +{ + stdenv, + mkDerivation, + byacc, + flex, +}: + +mkDerivation { + path = "usr.bin/mkesdb"; + + extraPaths = [ "lib/libc/iconv" ]; + + BOOTSTRAPPING = !stdenv.hostPlatform.isFreeBSD; + + extraNativeBuildInputs = [ + byacc + flex + ]; +} diff --git a/pkgs/os-specific/bsd/freebsd/pkgs/mtree.nix b/pkgs/os-specific/bsd/freebsd/pkgs/mtree.nix index 23a4672069e6..bbcaff3a1c6a 100644 --- a/pkgs/os-specific/bsd/freebsd/pkgs/mtree.nix +++ b/pkgs/os-specific/bsd/freebsd/pkgs/mtree.nix @@ -1,6 +1,39 @@ -{ mkDerivation, mknod }: +{ + lib, + stdenv, + mkDerivation, + compatIfNeeded, + compatIsNeeded, + libmd, + libnetbsd, + libutil, +}: mkDerivation { path = "contrib/mtree"; - extraPaths = [ mknod.path ]; + extraPaths = [ "contrib/mknod" ]; + buildInputs = + compatIfNeeded + ++ [ + libmd + libnetbsd + ] + ++ lib.optional (stdenv.isFreeBSD) libutil; + + postPatch = '' + ln -s $BSDSRCDIR/contrib/mknod/*.c $BSDSRCDIR/contrib/mknod/*.h $BSDSRCDIR/contrib/mtree + ''; + + preBuild = '' + export NIX_LDFLAGS="$NIX_LDFLAGS ${ + toString ( + [ + "-lmd" + "-lnetbsd" + ] + ++ lib.optional compatIsNeeded "-legacy" + ++ lib.optional stdenv.isFreeBSD "-lutil" + ) + }" + ''; } diff --git a/pkgs/os-specific/bsd/freebsd/pkgs/rpcgen/package.nix b/pkgs/os-specific/bsd/freebsd/pkgs/rpcgen/package.nix index 409064f2b65d..e187cacbb0d0 100644 --- a/pkgs/os-specific/bsd/freebsd/pkgs/rpcgen/package.nix +++ b/pkgs/os-specific/bsd/freebsd/pkgs/rpcgen/package.nix @@ -5,7 +5,7 @@ patchesRoot, }: -mkDerivation rec { +mkDerivation { path = "usr.bin/rpcgen"; patches = lib.optionals (stdenv.hostPlatform.libc == "glibc") [ # `WUNTRACED` is defined privately `bits/waitflags.h` in glibc. @@ -22,6 +22,6 @@ mkDerivation rec { # # This hacks around this by manually including `WUNTRACED` until # the problem is fixed properly in glibc. - /${patchesRoot}/rpcgen-glibc-hack.patch + ./rpcgen-glibc-hack.patch ]; } diff --git a/pkgs/os-specific/bsd/freebsd/patches/13.1/rpcgen-glibc-hack.patch b/pkgs/os-specific/bsd/freebsd/pkgs/rpcgen/rpcgen-glibc-hack.patch similarity index 100% rename from pkgs/os-specific/bsd/freebsd/patches/13.1/rpcgen-glibc-hack.patch rename to pkgs/os-specific/bsd/freebsd/pkgs/rpcgen/rpcgen-glibc-hack.patch diff --git a/pkgs/os-specific/bsd/freebsd/pkgs/sed.nix b/pkgs/os-specific/bsd/freebsd/pkgs/sed.nix index 07b55afe133f..ec5bfee17d2c 100644 --- a/pkgs/os-specific/bsd/freebsd/pkgs/sed.nix +++ b/pkgs/os-specific/bsd/freebsd/pkgs/sed.nix @@ -1,7 +1,6 @@ -{ mkDerivation, source }: +{ mkDerivation }: mkDerivation { path = "usr.bin/sed"; - TESTSRC = "${source}/contrib/netbsd-tests"; MK_TESTS = "no"; } diff --git a/pkgs/os-specific/bsd/freebsd/pkgs/source.nix b/pkgs/os-specific/bsd/freebsd/pkgs/source.nix index 5e31f900e821..c14d26559047 100644 --- a/pkgs/os-specific/bsd/freebsd/pkgs/source.nix +++ b/pkgs/os-specific/bsd/freebsd/pkgs/source.nix @@ -4,7 +4,6 @@ # If you want you could fetchgit from "https://git.FreeBSD.org/src.git" instead. # The update script still pulls directly from git.freebsd.org fetchFromGitHub { - name = "src"; # Want to rename this next rebuild owner = "freebsd"; repo = "freebsd-src"; inherit (sourceData) rev hash; diff --git a/pkgs/os-specific/bsd/freebsd/pkgs/sys/package.nix b/pkgs/os-specific/bsd/freebsd/pkgs/sys/package.nix index 50fff7738919..86f847cbd45c 100644 --- a/pkgs/os-specific/bsd/freebsd/pkgs/sys/package.nix +++ b/pkgs/os-specific/bsd/freebsd/pkgs/sys/package.nix @@ -2,7 +2,6 @@ stdenv, mkDerivation, freebsd-lib, - patchesRoot, buildPackages, bsdSetupHook, freebsdSetupHook, @@ -15,7 +14,7 @@ file2c, gawk, uudecode, - xargs-j, # , ctfconvert + xargs-j, }: mkDerivation ( @@ -39,12 +38,6 @@ mkDerivation ( gawk uudecode xargs-j - #ctfconvert - ]; - - patches = [ - /${patchesRoot}/sys-gnu-date.patch - /${patchesRoot}/sys-no-explicit-intrinsics-dep.patch ]; # --dynamic-linker /red/herring is used when building the kernel. diff --git a/pkgs/os-specific/bsd/freebsd/pkgs/tsort.nix b/pkgs/os-specific/bsd/freebsd/pkgs/tsort.nix index ab0101789f49..04a45ff980cb 100644 --- a/pkgs/os-specific/bsd/freebsd/pkgs/tsort.nix +++ b/pkgs/os-specific/bsd/freebsd/pkgs/tsort.nix @@ -1,4 +1,5 @@ { + lib, mkDerivation, bsdSetupHook, freebsdSetupHook, @@ -10,6 +11,12 @@ mkDerivation { path = "usr.bin/tsort"; + extraPaths = [ ]; + outputs = [ "out" ]; + MK_TESTS = "no"; + makeFlags = [ + "STRIP=-s" # flag to install, not command + ]; nativeBuildInputs = [ bsdSetupHook freebsdSetupHook diff --git a/pkgs/os-specific/bsd/netbsd/pkgs/netbsdSetupHook/setup-hook.sh b/pkgs/os-specific/bsd/netbsd/pkgs/netbsdSetupHook/setup-hook.sh index fa8b19e7d8ce..ef00ea418e53 100644 --- a/pkgs/os-specific/bsd/netbsd/pkgs/netbsdSetupHook/setup-hook.sh +++ b/pkgs/os-specific/bsd/netbsd/pkgs/netbsdSetupHook/setup-hook.sh @@ -9,6 +9,7 @@ mergeNetBSDSourceDir() { addNetBSDMakeFlags() { makeFlags="INCSDIR=${!outputDev}/include $makeFlags" + makeFlags="MANDIR=${!outputMan}/share/man $makeFlags" } postUnpackHooks+=(mergeNetBSDSourceDir) diff --git a/pkgs/os-specific/bsd/setup-hook.sh b/pkgs/os-specific/bsd/setup-hook.sh index e0afefcd73f7..f9453708ab5d 100644 --- a/pkgs/os-specific/bsd/setup-hook.sh +++ b/pkgs/os-specific/bsd/setup-hook.sh @@ -49,7 +49,6 @@ addMakeFlags() { makeFlags="LIBDIR=${!outputLib}/lib $makeFlags" makeFlags="SHLIBDIR=${!outputLib}/lib $makeFlags" makeFlags="SHAREDIR=${!outputLib}/share $makeFlags" - makeFlags="MANDIR=${!outputMan}/share/man $makeFlags" makeFlags="INFODIR=${!outputInfo}/share/info $makeFlags" makeFlags="DOCDIR=${!outputDoc}/share/doc $makeFlags" makeFlags="LOCALEDIR=${!outputLib}/share/locale $makeFlags" diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index fdbb8ac7ff6a..20411b8bd435 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -193,7 +193,7 @@ with pkgs; pythonInterpreter = "${python3.withPackages (ps: [ ps.pyelftools ])}/bin/python"; autoPatchelfScript = ../build-support/setup-hooks/auto-patchelf.py; }; - meta.platforms = lib.platforms.linux; + meta.platforms = lib.platforms.linux ++ lib.platforms.freebsd; } ../build-support/setup-hooks/auto-patchelf.sh; tomato-c = callPackage ../applications/misc/tomato-c { }; @@ -16343,7 +16343,7 @@ with pkgs; # assumption is that or any later version is good. choose = platform: /**/ if platform.isDarwin then 16 - else if platform.isFreeBSD then 12 + else if platform.isFreeBSD then 16 else if platform.isAndroid then 12 else if platform.isLinux then 17 else if platform.isWasm then 16 @@ -22564,7 +22564,7 @@ with pkgs; # We also provide `libiconvReal`, which will always be a standalone libiconv, # just in case you want it regardless of platform. libiconv = - if lib.elem stdenv.hostPlatform.libc [ "glibc" "musl" "nblibc" "wasilibc" ] + if lib.elem stdenv.hostPlatform.libc [ "glibc" "musl" "nblibc" "wasilibc" "fblibc" ] then libcIconv (if stdenv.hostPlatform != stdenv.buildPlatform then libcCross else stdenv.cc.libc) diff --git a/pkgs/top-level/stage.nix b/pkgs/top-level/stage.nix index 3b84026b4696..e8d4cd4a4724 100644 --- a/pkgs/top-level/stage.nix +++ b/pkgs/top-level/stage.nix @@ -57,9 +57,7 @@ in , # Non-GNU/Linux OSes are currently "impure" platforms, with their libc # outside of the store. Thus, GCC, GFortran, & co. must always look for files # in standard system directories (/usr/include, etc.) - noSysDirs ? stdenv.buildPlatform.system != "x86_64-freebsd" - && stdenv.buildPlatform.system != "i686-freebsd" - && stdenv.buildPlatform.system != "x86_64-solaris" + noSysDirs ? stdenv.buildPlatform.system != "x86_64-solaris" && stdenv.buildPlatform.system != "x86_64-kfreebsd-gnu" , # The configuration attribute set From 2cc214b4c3e8e116e6af6f40735e99a505b653be Mon Sep 17 00:00:00 2001 From: Audrey Dutcher Date: Sat, 11 May 2024 21:45:23 -0400 Subject: [PATCH 2/2] freebsd: 13.1.0 -> 14.0.0 The old patches are kept because the version is actually configurable. In the future both versions may be exposed. Co-Auhtored-By: Artemis Tosini Co-Authored-by: John Ericson --- pkgs/os-specific/bsd/freebsd/default.nix | 2 +- .../patches/14.0/bmake-no-compiler-rt.patch | 11 +++++ .../14.0/compat-fix-typedefs-locations.patch | 32 ++++++++++++++ .../patches/14.0/compat-install-dirs.patch | 40 ++++++++++++++++++ .../14.0/install-bootstrap-Makefile.patch | 11 +++++ .../patches/14.0/libc-msun-arch-subdir.patch | 11 +++++ .../14.0/libc-no-force--lcompiler-rt.patch | 10 +++++ .../patches/14.0/libnetbsd-do-install.patch | 32 ++++++++++++++ .../14.0/librpcsvc-include-subdir.patch | 11 +++++ .../freebsd/patches/14.0/mtree-Makefile.patch | 13 ++++++ .../14.0/no-perms-BSD.include.dist.patch | 11 +++++ .../14.0/rtld-no-force--lcompiler-rt.patch | 10 +++++ .../freebsd/patches/14.0/sys-gnu-date.patch | 13 ++++++ .../14.0/sys-no-explicit-intrinsics-dep.patch | 42 +++++++++++++++++++ .../bsd/freebsd/pkgs/compat/package.nix | 10 +++++ .../bsd/freebsd/pkgs/libc/package.nix | 5 ++- .../bsd/freebsd/pkgs/mkDerivation.nix | 2 + 17 files changed, 264 insertions(+), 2 deletions(-) create mode 100644 pkgs/os-specific/bsd/freebsd/patches/14.0/bmake-no-compiler-rt.patch create mode 100644 pkgs/os-specific/bsd/freebsd/patches/14.0/compat-fix-typedefs-locations.patch create mode 100644 pkgs/os-specific/bsd/freebsd/patches/14.0/compat-install-dirs.patch create mode 100644 pkgs/os-specific/bsd/freebsd/patches/14.0/install-bootstrap-Makefile.patch create mode 100644 pkgs/os-specific/bsd/freebsd/patches/14.0/libc-msun-arch-subdir.patch create mode 100644 pkgs/os-specific/bsd/freebsd/patches/14.0/libc-no-force--lcompiler-rt.patch create mode 100644 pkgs/os-specific/bsd/freebsd/patches/14.0/libnetbsd-do-install.patch create mode 100644 pkgs/os-specific/bsd/freebsd/patches/14.0/librpcsvc-include-subdir.patch create mode 100644 pkgs/os-specific/bsd/freebsd/patches/14.0/mtree-Makefile.patch create mode 100644 pkgs/os-specific/bsd/freebsd/patches/14.0/no-perms-BSD.include.dist.patch create mode 100644 pkgs/os-specific/bsd/freebsd/patches/14.0/rtld-no-force--lcompiler-rt.patch create mode 100644 pkgs/os-specific/bsd/freebsd/patches/14.0/sys-gnu-date.patch create mode 100644 pkgs/os-specific/bsd/freebsd/patches/14.0/sys-no-explicit-intrinsics-dep.patch diff --git a/pkgs/os-specific/bsd/freebsd/default.nix b/pkgs/os-specific/bsd/freebsd/default.nix index 4295dc213af9..c605d9f70937 100644 --- a/pkgs/os-specific/bsd/freebsd/default.nix +++ b/pkgs/os-specific/bsd/freebsd/default.nix @@ -5,7 +5,7 @@ callPackage, crossLibcStdenv, attributePathToSplice ? [ "freebsd" ], - branch ? "release/13.1.0", + branch ? "release/14.0.0", }: let diff --git a/pkgs/os-specific/bsd/freebsd/patches/14.0/bmake-no-compiler-rt.patch b/pkgs/os-specific/bsd/freebsd/patches/14.0/bmake-no-compiler-rt.patch new file mode 100644 index 000000000000..f43d87c01e54 --- /dev/null +++ b/pkgs/os-specific/bsd/freebsd/patches/14.0/bmake-no-compiler-rt.patch @@ -0,0 +1,11 @@ +--- a/share/mk/src.libnames.mk 2023-12-21 23:56:50.767042385 -0800 ++++ b/share/mk/src.libnames.mk 2023-12-21 23:56:39.671089506 -0800 +@@ -392,7 +392,7 @@ + _DP_ztest= geom m nvpair umem zpool pthread avl zfs_core spl zutil zfs uutil icp + # The libc dependencies are not strictly needed but are defined to make the + # assert happy. +-_DP_c= compiler_rt ++_DP_c= + # Use libssp_nonshared only on i386 and power*. Other archs emit direct calls + # to __stack_chk_fail, not __stack_chk_fail_local provided by libssp_nonshared. + .if ${MK_SSP} != "no" && \ diff --git a/pkgs/os-specific/bsd/freebsd/patches/14.0/compat-fix-typedefs-locations.patch b/pkgs/os-specific/bsd/freebsd/patches/14.0/compat-fix-typedefs-locations.patch new file mode 100644 index 000000000000..3336a2504e58 --- /dev/null +++ b/pkgs/os-specific/bsd/freebsd/patches/14.0/compat-fix-typedefs-locations.patch @@ -0,0 +1,32 @@ +--- a/tools/build/cross-build/include/common/sys/_types.h ++++ b/tools/build/cross-build/include/common/sys/_types.h +@@ -47,3 +47,6 @@ + * Neither GLibc nor macOS define __va_list but many FreeBSD headers require it. + */ + typedef __builtin_va_list __va_list; ++ ++typedef __UINTPTR_TYPE__ __uintptr_t; ++typedef __INTPTR_TYPE__ __intptr_t; +--- a/tools/build/cross-build/include/common/sys/types.h ++++ b/tools/build/cross-build/include/common/sys/types.h +@@ -49,9 +49,6 @@ + #include + #endif + +-typedef __UINTPTR_TYPE__ __uintptr_t; +-typedef __INTPTR_TYPE__ __intptr_t; +- + /* needed for gencat */ + typedef int __nl_item; + +--- a/tools/build/cross-build/include/linux/sys/types.h ++++ b/tools/build/cross-build/include/linux/sys/types.h +@@ -39,6 +39,8 @@ + + #include_next + ++#include ++ + #ifndef __size_t + typedef __SIZE_TYPE__ __size_t; + #endif diff --git a/pkgs/os-specific/bsd/freebsd/patches/14.0/compat-install-dirs.patch b/pkgs/os-specific/bsd/freebsd/patches/14.0/compat-install-dirs.patch new file mode 100644 index 000000000000..4bc21cf8eb14 --- /dev/null +++ b/pkgs/os-specific/bsd/freebsd/patches/14.0/compat-install-dirs.patch @@ -0,0 +1,40 @@ +diff --git a/tools/build/Makefile b/tools/build/Makefile +index 948a5f9dfdb..592af84eeae 100644 +--- a/tools/build/Makefile ++++ b/tools/build/Makefile +@@ -327,14 +327,14 @@ host-symlinks: + # and cross-tools stages. We do this here using mkdir since mtree may not exist + # yet (this happens if we are crossbuilding from Linux/Mac). + INSTALLDIR_LIST= \ +- bin \ +- lib/geom \ +- usr/include/casper \ +- usr/include/private/ucl \ +- usr/include/private/zstd \ +- usr/lib \ +- usr/libdata/pkgconfig \ +- usr/libexec ++ ${BINDIR} \ ++ ${LIBDIR}/geom \ ++ ${INCLUDEDIR}/casper \ ++ ${INCLUDEDIR}/private/ucl \ ++ ${INCLUDEDIR}/private/zstd \ ++ ${LIBDIR} \ ++ ${LIBDIR}/libdata/pkgconfig \ ++ ${LIBEXECDIR} + + installdirs: + mkdir -p ${INSTALLDIR_LIST:S,^,${DESTDIR}/,} +@@ -352,9 +352,9 @@ installdirs: + rm -rf "${DESTDIR}/${_dir}"; \ + fi + .endfor +- ln -sfn bin ${DESTDIR}/sbin +- ln -sfn ../bin ${DESTDIR}/usr/bin +- ln -sfn ../bin ${DESTDIR}/usr/sbin ++ ln -sfn bin ${DESTDIR}/${SBINDIR} ++ ln -sfn ../bin ${DESTDIR}/${BINDIR} ++ ln -sfn ../bin ${DESTDIR}/${SBINDIR} + .for _group in ${INCSGROUPS:NINCS} + mkdir -p "${DESTDIR}/${${_group}DIR}" + .endfor diff --git a/pkgs/os-specific/bsd/freebsd/patches/14.0/install-bootstrap-Makefile.patch b/pkgs/os-specific/bsd/freebsd/patches/14.0/install-bootstrap-Makefile.patch new file mode 100644 index 000000000000..a69c5501ddd1 --- /dev/null +++ b/pkgs/os-specific/bsd/freebsd/patches/14.0/install-bootstrap-Makefile.patch @@ -0,0 +1,11 @@ +--- a/usr.bin/xinstall/Makefile 2023-09-23 19:18:49.165192183 -0700 ++++ b/usr.bin/xinstall/Makefile 2023-12-06 17:06:57.836888028 -0700 +@@ -14,7 +14,7 @@ + CFLAGS+= -I${SRCTOP}/lib/libnetbsd + + LIBADD= md +-CFLAGS+= -DWITH_MD5 -DWITH_RIPEMD160 ++CFLAGS+= -I${BSDSRCDIR}/contrib/libc-vis -I${BSDSRCDIR}/lib/libnetbsd + + .ifdef BOOTSTRAPPING + # For the bootstrap we disable copy_file_range() diff --git a/pkgs/os-specific/bsd/freebsd/patches/14.0/libc-msun-arch-subdir.patch b/pkgs/os-specific/bsd/freebsd/patches/14.0/libc-msun-arch-subdir.patch new file mode 100644 index 000000000000..4a69e85a986a --- /dev/null +++ b/pkgs/os-specific/bsd/freebsd/patches/14.0/libc-msun-arch-subdir.patch @@ -0,0 +1,11 @@ +--- a/lib/libc/Makefile ++++ b/lib/libc/Makefile +@@ -194,7 +194,7 @@ SUBDIR.${MK_TESTS}+= tests + # recording a build dependency + CFLAGS+= -I${SRCTOP}/lib/libutil + # Same issue with libm +-MSUN_ARCH_SUBDIR != ${MAKE} -B -C ${SRCTOP}/lib/msun -V ARCH_SUBDIR ++MSUN_ARCH_SUBDIR = ${MACHINE_CPUARCH:S/i386/i387/} + # unfortunately msun/src contains both private and public headers + CFLAGS+= -I${SRCTOP}/lib/msun/${MSUN_ARCH_SUBDIR} + .if ${MACHINE_CPUARCH} == "i386" || ${MACHINE_CPUARCH} == "amd64" diff --git a/pkgs/os-specific/bsd/freebsd/patches/14.0/libc-no-force--lcompiler-rt.patch b/pkgs/os-specific/bsd/freebsd/patches/14.0/libc-no-force--lcompiler-rt.patch new file mode 100644 index 000000000000..60176fb73cf7 --- /dev/null +++ b/pkgs/os-specific/bsd/freebsd/patches/14.0/libc-no-force--lcompiler-rt.patch @@ -0,0 +1,10 @@ +--- a/lib/libc/Makefile ++++ b/lib/libc/Makefile +@@ -58,7 +58,6 @@ CFLAGS+=${CANCELPOINTS_CFLAGS} + # Link with static libcompiler_rt.a. + # + LDFLAGS+= -nodefaultlibs +-LIBADD+= compiler_rt + + .if ${MK_SSP} != "no" && \ + (${LIBC_ARCH} == "i386" || ${MACHINE_ARCH:Mpower*} != "") diff --git a/pkgs/os-specific/bsd/freebsd/patches/14.0/libnetbsd-do-install.patch b/pkgs/os-specific/bsd/freebsd/patches/14.0/libnetbsd-do-install.patch new file mode 100644 index 000000000000..a7bd032d2be5 --- /dev/null +++ b/pkgs/os-specific/bsd/freebsd/patches/14.0/libnetbsd-do-install.patch @@ -0,0 +1,32 @@ +diff --git a/Makefile b/Makefile +index 22710f3d933..22effc848cf 100644 +--- a/lib/libnetbsd/Makefile ++++ b/lib/libnetbsd/Makefile +@@ -9,6 +9,26 @@ CFLAGS+= -I${.CURDIR} + + SRCS+= efun.c sockaddr_snprintf.c strsuftoll.c util.c util.h + +-INTERNALLIB= ++INCSGROUPS= INCS SYSINCS NETINETINCS ++ ++INCS+= \ ++ glob.h \ ++ pthread.h \ ++ rmd160.h \ ++ sha1.h \ ++ sha2.h \ ++ stdlib.h \ ++ util.h ++ ++SYSINCSDIR= ${INCLUDEDIR}/sys ++SYSINCS+= \ ++ sys/cdefs.h \ ++ sys/event.h \ ++ sys/types.h \ ++ sys/wait.h ++ ++NETINETINCSDIR= ${INCLUDEDIR}/netinet ++NETINETINCS+= \ ++ netinet/in.h + + .include diff --git a/pkgs/os-specific/bsd/freebsd/patches/14.0/librpcsvc-include-subdir.patch b/pkgs/os-specific/bsd/freebsd/patches/14.0/librpcsvc-include-subdir.patch new file mode 100644 index 000000000000..38e06682869f --- /dev/null +++ b/pkgs/os-specific/bsd/freebsd/patches/14.0/librpcsvc-include-subdir.patch @@ -0,0 +1,11 @@ +--- a/lib/librpcsvc/Makefile ++++ b/lib/librpcsvc/Makefile +@@ -20,7 +20,7 @@ OTHERSRCS+= yp_passwd.c yp_update.c + + RPCCOM= RPCGEN_CPP=${CPP:Q} rpcgen -C + +-INCDIRS= -I${SYSROOT:U${DESTDIR}}/usr/include/rpcsvc ++INCDIRS= -I${INCLUDEDIR}/rpcsvc + + CFLAGS+= -DYP ${INCDIRS} + diff --git a/pkgs/os-specific/bsd/freebsd/patches/14.0/mtree-Makefile.patch b/pkgs/os-specific/bsd/freebsd/patches/14.0/mtree-Makefile.patch new file mode 100644 index 000000000000..2a6e560d1d28 --- /dev/null +++ b/pkgs/os-specific/bsd/freebsd/patches/14.0/mtree-Makefile.patch @@ -0,0 +1,13 @@ +--- a/contrib/mtree/Makefile 2023-12-04 23:02:13.919144141 -0700 ++++ b/contrib/mtree/Makefile 2023-12-04 23:02:58.371810109 -0700 +@@ -10,8 +10,8 @@ + SRCS= compare.c crc.c create.c excludes.c misc.c mtree.c spec.c specspec.c \ + verify.c getid.c pack_dev.c only.c + .if (${HOSTPROG:U} == "") +-DPADD+= ${LIBUTIL} +-LDADD+= -lutil ++LIBADD+= ${LIBUTIL} ++#LIBADD+= -lutil + .endif + + CPPFLAGS+= -I${NETBSDSRCDIR}/sbin/mknod diff --git a/pkgs/os-specific/bsd/freebsd/patches/14.0/no-perms-BSD.include.dist.patch b/pkgs/os-specific/bsd/freebsd/patches/14.0/no-perms-BSD.include.dist.patch new file mode 100644 index 000000000000..985617ee0f45 --- /dev/null +++ b/pkgs/os-specific/bsd/freebsd/patches/14.0/no-perms-BSD.include.dist.patch @@ -0,0 +1,11 @@ +--- a/etc/mtree/BSD.include.dist ++++ b/etc/mtree/BSD.include.dist +@@ -3,7 +3,7 @@ + # Please see the file src/etc/mtree/README before making changes to this file. + # + +-/set type=dir uname=root gname=wheel mode=0755 ++/set type=dir + . + arpa + .. diff --git a/pkgs/os-specific/bsd/freebsd/patches/14.0/rtld-no-force--lcompiler-rt.patch b/pkgs/os-specific/bsd/freebsd/patches/14.0/rtld-no-force--lcompiler-rt.patch new file mode 100644 index 000000000000..45f0d0c51eec --- /dev/null +++ b/pkgs/os-specific/bsd/freebsd/patches/14.0/rtld-no-force--lcompiler-rt.patch @@ -0,0 +1,10 @@ +--- a/libexec/rtld-elf/Makefile ++++ b/libexec/rtld-elf/Makefile +@@ -86,7 +86,6 @@ + + # Some of the required math functions (div & mod) are implemented in + # libcompiler_rt on some architectures. +-LIBADD+= compiler_rt + + .include + ${PROG_FULL}: ${VERSION_MAP} diff --git a/pkgs/os-specific/bsd/freebsd/patches/14.0/sys-gnu-date.patch b/pkgs/os-specific/bsd/freebsd/patches/14.0/sys-gnu-date.patch new file mode 100644 index 000000000000..2356446baf85 --- /dev/null +++ b/pkgs/os-specific/bsd/freebsd/patches/14.0/sys-gnu-date.patch @@ -0,0 +1,13 @@ +diff --git a/sys/conf/newvers.sh b/sys/conf/newvers.sh +index c594724d814..d5287c7b992 100644 +--- a/sys/conf/newvers.sh ++++ b/sys/conf/newvers.sh +@@ -177,7 +177,7 @@ u=${USER:-root} + d=$(pwd) + h=${HOSTNAME:-$(hostname)} + if [ -n "$SOURCE_DATE_EPOCH" ]; then +- if ! t=$(date -r $SOURCE_DATE_EPOCH 2>/dev/null); then ++ if ! t=$(date -d @$SOURCE_DATE_EPOCH 2>/dev/null); then + echo "Invalid SOURCE_DATE_EPOCH" >&2 + exit 1 + fi diff --git a/pkgs/os-specific/bsd/freebsd/patches/14.0/sys-no-explicit-intrinsics-dep.patch b/pkgs/os-specific/bsd/freebsd/patches/14.0/sys-no-explicit-intrinsics-dep.patch new file mode 100644 index 000000000000..5cf926d4519b --- /dev/null +++ b/pkgs/os-specific/bsd/freebsd/patches/14.0/sys-no-explicit-intrinsics-dep.patch @@ -0,0 +1,42 @@ +--- a/sys/modules/aesni/Makefile 2023-12-16 09:19:28.454892154 -0700 ++++ b/sys/Modules/aesni/Makefile 2023-12-16 09:19:41.975047684 -0700 +@@ -1,6 +1,5 @@ + + .PATH: ${SRCTOP}/sys/crypto/aesni +-.PATH: ${SRCTOP}/contrib/llvm-project/clang/lib/Headers + + KMOD= aesni + SRCS= aesni.c +@@ -39,8 +38,8 @@ + aesni_ghash.o: aesni.h + aesni_wrap.o: aesni.h + aesni_ccm.o: aesni.h +-intel_sha1.o: sha_sse.h immintrin.h shaintrin.h tmmintrin.h xmmintrin.h +-intel_sha256.o: sha_sse.h immintrin.h shaintrin.h tmmintrin.h xmmintrin.h ++intel_sha1.o: sha_sse.h ++intel_sha256.o: sha_sse.h + + .include + +diff --git a/sys/modules/blake2/Makefile b/sys/modules/blake2/Makefile +index e4b3fb9f126..5bfd9c2ae02 100644 +--- a/sys/modules/blake2/Makefile ++++ b/sys/modules/blake2/Makefile +@@ -3,7 +3,6 @@ + .PATH: ${SRCTOP}/sys/contrib/libb2 + .PATH: ${SRCTOP}/sys/crypto/blake2 + .PATH: ${SRCTOP}/sys/opencrypto +-.PATH: ${SRCTOP}/contrib/llvm-project/clang/lib/Headers + + KMOD = blake2 + +@@ -64,8 +63,7 @@ ${src:S/.c/.o/}: ${src} + -D_MM_MALLOC_H_INCLUDED -Wno-unused-function ${.IMPSRC} + ${CTFCONVERT_CMD} + +-${src:S/.c/.o/}: intrin.h emmintrin.h tmmintrin.h smmintrin.h immintrin.h \ +- x86intrin.h ${SRCS:M*.h} ++${src:S/.c/.o/}: ${SRCS:M*.h} + .endfor + + # FreeBSD-specific sources: diff --git a/pkgs/os-specific/bsd/freebsd/pkgs/compat/package.nix b/pkgs/os-specific/bsd/freebsd/pkgs/compat/package.nix index a002bcfce53f..f597d6e3705b 100644 --- a/pkgs/os-specific/bsd/freebsd/pkgs/compat/package.nix +++ b/pkgs/os-specific/bsd/freebsd/pkgs/compat/package.nix @@ -40,6 +40,9 @@ mkDerivation { # Take only individual headers, or else we will clobber native libc, etc. "sys/rpc/types.h" + ] + ++ lib.optionals (versionData.major == 14) [ "sys/sys/bitcount.h" ] + ++ [ # Listed in Makekfile as INC "include/mpool.h" @@ -53,6 +56,13 @@ mkDerivation { "include/nl_types.h" "include/elf.h" "sys/sys/ctf.h" + ] + ++ lib.optionals (versionData.major == 14) [ + "include/bitstring.h" + "sys/sys/bitstring.h" + "sys/sys/nv_namespace.h" + ] + ++ [ # Listed in Makekfile as SYSINC diff --git a/pkgs/os-specific/bsd/freebsd/pkgs/libc/package.nix b/pkgs/os-specific/bsd/freebsd/pkgs/libc/package.nix index ac01af113b95..8f2cc976463e 100644 --- a/pkgs/os-specific/bsd/freebsd/pkgs/libc/package.nix +++ b/pkgs/os-specific/bsd/freebsd/pkgs/libc/package.nix @@ -42,7 +42,10 @@ mkDerivation { "contrib/gdtoa" "contrib/libc-pwcache" "contrib/libc-vis" - "contrib/tzcode/stdtime" + ] + ++ lib.optionals (versionData.major == 13) [ "contrib/tzcode/stdtime" ] + ++ lib.optionals (versionData.major == 14) [ "contrib/tzcode" ] + ++ [ # libthr "lib/libthr" diff --git a/pkgs/os-specific/bsd/freebsd/pkgs/mkDerivation.nix b/pkgs/os-specific/bsd/freebsd/pkgs/mkDerivation.nix index 470cb1cb64bb..be195b3bc6fa 100644 --- a/pkgs/os-specific/bsd/freebsd/pkgs/mkDerivation.nix +++ b/pkgs/os-specific/bsd/freebsd/pkgs/mkDerivation.nix @@ -98,6 +98,8 @@ lib.makeOverridable ( preBuild = '' export NIX_CFLAGS_COMPILE="$NIX_CFLAGS_COMPILE -D_VA_LIST -D_VA_LIST_DECLARED -Dva_list=__builtin_va_list -D_SIZE_T_DECLARED -D_SIZE_T -Dsize_t=__SIZE_TYPE__ -D_WCHAR_T" + '' + + lib.optionalString (versionData.major == 13) '' export NIX_LDFLAGS="$NIX_LDFLAGS --undefined-version" '' + (attrs.preBuild or "");