From 8c8f1a1cc17ce49c1311f6e67763b94e7f6640ef Mon Sep 17 00:00:00 2001 From: Max Larsson Date: Sat, 19 Jul 2025 21:59:19 -0700 Subject: [PATCH] uboot: add Darwin build support - Add darwin.DarwinTools for sw_vers command on Darwin, which is used by uboot config to determine which gcc flags to provide - Use gccStdenv.cc instead of stdenv.cc for Darwin support (Darwin defaults to clang otherwise) - Add HOSTCFLAGS=-fcommon to allow duplicate function definitions - Parallelize defconfig generation with -j$NIX_BUILD_CORES --- pkgs/misc/uboot/default.nix | 39 +++++++++++++++++++++---------------- 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/pkgs/misc/uboot/default.nix b/pkgs/misc/uboot/default.nix index 8142ede3407d..65ba960a2089 100644 --- a/pkgs/misc/uboot/default.nix +++ b/pkgs/misc/uboot/default.nix @@ -29,6 +29,7 @@ armTrustedFirmwareS905, opensbi, buildPackages, + darwin, }@pkgs: let @@ -82,22 +83,25 @@ let patchShebangs scripts ''; - nativeBuildInputs = [ - ncurses # tools/kwboot - bc - bison - flex - installShellFiles - (buildPackages.python3.withPackages (p: [ - p.libfdt - p.setuptools # for pkg_resources - p.pyelftools - ])) - swig - which # for scripts/dtc-version.sh - perl # for oid build (secureboot) - ] ++ lib.optionals (!crossTools) toolsDeps; - depsBuildBuild = [ buildPackages.stdenv.cc ]; + nativeBuildInputs = + [ + ncurses # tools/kwboot + bc + bison + flex + installShellFiles + (buildPackages.python3.withPackages (p: [ + p.libfdt + p.setuptools # for pkg_resources + p.pyelftools + ])) + swig + which # for scripts/dtc-version.sh + perl # for oid build (secureboot) + ] + ++ lib.optionals (!crossTools) toolsDeps + ++ lib.optionals stdenv.buildPlatform.isDarwin [ darwin.DarwinTools ]; # sw_vers command is needed on darwin + depsBuildBuild = [ buildPackages.gccStdenv.cc ]; # gccStdenv is needed for Darwin buildPlatform buildInputs = lib.optionals crossTools toolsDeps; hardeningDisable = [ "all" ]; @@ -107,6 +111,7 @@ let makeFlags = [ "DTC=${lib.getExe buildPackages.dtc}" "CROSS_COMPILE=${stdenv.cc.targetPrefix}" + "HOSTCFLAGS=-fcommon" ] ++ extraMakeFlags; passAsFile = [ "extraConfig" ]; @@ -114,7 +119,7 @@ let configurePhase = '' runHook preConfigure - make ${defconfig} + make -j$NIX_BUILD_CORES ${defconfig} cat $extraConfigPath >> .config