diff --git a/deps/libfdt/CMakeLists.txt b/deps/libfdt/CMakeLists.txt deleted file mode 100644 index d54f7ad32..000000000 --- a/deps/libfdt/CMakeLists.txt +++ /dev/null @@ -1,29 +0,0 @@ -cmake_minimum_required(VERSION 3.31.6) - -project(libfdt) - -set(SRC_S - dtc/libfdt/fdt.c - dtc/libfdt/fdt_ro.c - dtc/libfdt/fdt_wip.c - dtc/libfdt/fdt_sw.c - dtc/libfdt/fdt_rw.c - dtc/libfdt/fdt_strerror.c - dtc/libfdt/fdt_empty_tree.c - dtc/libfdt/fdt_addresses.c - dtc/libfdt/fdt_overlay.c -) - -set(HEADERS - dtc/libfdt/fdt.h - dtc/libfdt/libfdt.h - dtc/libfdt/libfdt_env.h -) - -include_directories(dtc/libfdt) - -add_library(fdt STATIC ${SRC_S}) - -INSTALL(TARGETS fdt DESTINATION "lib") - -INSTALL(FILES ${HEADERS} DESTINATION "include") diff --git a/deps/libfdt/clang-no-suggest-attr-format.patch b/deps/libfdt/clang-no-suggest-attr-format.patch new file mode 100644 index 000000000..e063104c1 --- /dev/null +++ b/deps/libfdt/clang-no-suggest-attr-format.patch @@ -0,0 +1,16 @@ +diff --git a/Makefile b/Makefile +index f1f0ab3..edbcb4a 100644 +--- a/Makefile ++++ b/Makefile +@@ -20,7 +20,10 @@ ASSUME_MASK ?= 0 + CPPFLAGS = -I libfdt -I . -DFDT_ASSUME_MASK=$(ASSUME_MASK) + WARNINGS = -Wall -Wpointer-arith -Wcast-qual -Wnested-externs -Wsign-compare \ + -Wstrict-prototypes -Wmissing-prototypes -Wredundant-decls -Wshadow \ +- -Wsuggest-attribute=format -Wwrite-strings ++ -Wwrite-strings ++ifeq ($(findstring gcc,$(notdir $(CC))),gcc) ++WARNINGS += -Wsuggest-attribute=format ++endif + CFLAGS = -g -Os $(SHAREDLIB_CFLAGS) -Werror $(WARNINGS) $(EXTRA_CFLAGS) + + BISON = bison diff --git a/deps/libfdt/default.nix b/deps/libfdt/default.nix new file mode 100644 index 000000000..4614fb11b --- /dev/null +++ b/deps/libfdt/default.nix @@ -0,0 +1,48 @@ +{ + pkgs, + stdenv +}: + +let + self = stdenv.mkDerivation rec { + pname = "libfdt"; + version = "1.7.2"; + src = pkgs.fetchzip { + url = "https://mirrors.edge.kernel.org/pub/software/utils/dtc/dtc-${version}.tar.xz"; + hash = "sha256-KZCzrvdWd6zfQHppjyp4XzqNCfH2UnuRneu+BNIRVAY="; + }; + meta.license = pkgs.lib.licenses.bsd2; + + nativeBuildInputs = with pkgs.buildPackages; [ + pkg-config flex bison + ]; + outputs = [ "out" "dev" ]; + + patches = [ + ./clang-no-suggest-attr-format.patch # TODO: upstream + ]; + + buildPhase = '' + runHook preBuild + make -j"$NIX_BUILD_CORES" libfdt/libfdt.a + runHook postBuild + ''; + + installPhase = '' + runHook preInstall + install -D -m644 -t "$out/lib/" libfdt/libfdt.a + install -D -m644 -t "$dev/include/fdt" libfdt/*.h + runHook postInstall + ''; + }; + + dev = pkgs.lib.getDev self; +in + self.overrideAttrs (prev: { + passthru = { + include_root = "${dev}/include"; + include = "${dev}/include/fdt"; + lib = "${self}/lib"; + }; + }) + diff --git a/overlay.nix b/overlay.nix index 94b2d34ba..e2fcf3623 100644 --- a/overlay.nix +++ b/overlay.nix @@ -92,6 +92,7 @@ final: prev: { http-parser = self.callPackage ./deps/http-parser/default.nix { }; s2n-tls = self.callPackage ./deps/s2n/default.nix { }; uzlib = self.callPackage ./deps/uzlib/default.nix { }; + libfdt = self.callPackage ./deps/libfdt/default.nix { }; vmbuild = self.callPackage ./vmbuild.nix { }; @@ -165,6 +166,7 @@ final: prev: { prev.pkgsStatic.openssl prev.pkgsStatic.rapidjson #self.s2n-tls 👈 This is postponed until we can fix the s2n build. + self.libfdt self.uzlib self.vmbuild ]; @@ -209,6 +211,7 @@ final: prev: { inherit (self) http-parser; inherit (self) botan2; inherit (self) libfmt; + inherit (self) libfdt; #inherit (self) s2n-tls; inherit (self) cmake; inherit (self) vmbuild;