dtc: fix static building

authored by Tero Tervala and committed by Alyssa Ross 7f3cdfd2 f5b87a82

+94 -1
+90
pkgs/development/compilers/dtc/0001-Depend-on-.a-instead-of-.so-when-building-static.patch
···
··· 1 + From c1d426bdd477ffeb3dfa03501de089a341b85d0b Mon Sep 17 00:00:00 2001 2 + From: Tero Tervala <tero.tervala@unikie.com> 3 + Date: Wed, 15 Jun 2022 13:44:55 +0300 4 + Subject: [PATCH] Depend on .a instead of .so when building static 5 + 6 + Static build needs to be indicated with environment variable: 7 + STATIC_BUILD=1 8 + 9 + Checks are skipped on static builds 10 + 11 + Signed-off-by: Tero Tervala <tero.tervala@unikie.com> 12 + --- 13 + Makefile | 12 +++++++++--- 14 + tests/Makefile.tests | 11 ++++++++--- 15 + 2 files changed, 17 insertions(+), 6 deletions(-) 16 + 17 + diff --git a/Makefile b/Makefile 18 + index ee77115..9f550b4 100644 19 + --- a/Makefile 20 + +++ b/Makefile 21 + @@ -198,6 +198,12 @@ LIBFDT_lib = $(LIBFDT_dir)/$(LIBFDT_LIB) 22 + LIBFDT_include = $(addprefix $(LIBFDT_dir)/,$(LIBFDT_INCLUDES)) 23 + LIBFDT_version = $(addprefix $(LIBFDT_dir)/,$(LIBFDT_VERSION)) 24 + 25 + +ifeq ($(STATIC_BUILD),1) 26 + + LIBFDT_dep = $(LIBFDT_archive) 27 + +else 28 + + LIBFDT_dep = $(LIBFDT_lib) 29 + +endif 30 + + 31 + include $(LIBFDT_dir)/Makefile.libfdt 32 + 33 + .PHONY: libfdt 34 + @@ -261,11 +267,11 @@ convert-dtsv0: $(CONVERT_OBJS) 35 + 36 + fdtdump: $(FDTDUMP_OBJS) 37 + 38 + -fdtget: $(FDTGET_OBJS) $(LIBFDT_lib) 39 + +fdtget: $(FDTGET_OBJS) $(LIBFDT_dep) 40 + 41 + -fdtput: $(FDTPUT_OBJS) $(LIBFDT_lib) 42 + +fdtput: $(FDTPUT_OBJS) $(LIBFDT_dep) 43 + 44 + -fdtoverlay: $(FDTOVERLAY_OBJS) $(LIBFDT_lib) 45 + +fdtoverlay: $(FDTOVERLAY_OBJS) $(LIBFDT_dep) 46 + 47 + dist: 48 + git archive --format=tar --prefix=dtc-$(dtc_version)/ HEAD \ 49 + diff --git a/tests/Makefile.tests b/tests/Makefile.tests 50 + index 2f78952..f13b16d 100644 51 + --- a/tests/Makefile.tests 52 + +++ b/tests/Makefile.tests 53 + @@ -60,17 +60,17 @@ TESTS_CLEANDIRS = $(TESTS_CLEANDIRS_L:%=$(TESTS_PREFIX)%) 54 + .PHONY: tests 55 + tests: $(TESTS) $(TESTS_TREES) 56 + 57 + -$(LIB_TESTS): %: $(TESTS_PREFIX)testutils.o util.o $(LIBFDT_lib) 58 + +$(LIB_TESTS): %: $(TESTS_PREFIX)testutils.o util.o $(LIBFDT_dep) 59 + 60 + # Not necessary on all platforms; allow -ldl to be excluded instead of forcing 61 + # other platforms to patch it out. 62 + LIBDL = -ldl 63 + -$(DL_LIB_TESTS): %: %.o $(TESTS_PREFIX)testutils.o util.o $(LIBFDT_lib) 64 + +$(DL_LIB_TESTS): %: %.o $(TESTS_PREFIX)testutils.o util.o $(LIBFDT_dep) 65 + @$(VECHO) LD [libdl] $@ 66 + $(LINK.c) -o $@ $^ $(LIBDL) 67 + 68 + $(LIBTREE_TESTS): %: $(TESTS_PREFIX)testutils.o $(TESTS_PREFIX)trees.o \ 69 + - util.o $(LIBFDT_lib) 70 + + util.o $(LIBFDT_dep) 71 + 72 + $(TESTS_PREFIX)dumptrees: $(TESTS_PREFIX)trees.o 73 + 74 + @@ -83,8 +83,13 @@ tests_clean: 75 + rm -f $(TESTS_CLEANFILES) 76 + rm -rf $(TESTS_CLEANDIRS) 77 + 78 + +ifeq ($(STATIC_BUILD),1) 79 + +check: 80 + + @echo Skipping checks for static build 81 + +else 82 + check: tests ${TESTS_BIN} $(TESTS_PYLIBFDT) 83 + cd $(TESTS_PREFIX); ./run_tests.sh 84 + +endif 85 + 86 + ifeq ($(NO_VALGRIND),1) 87 + checkm: 88 + -- 89 + 2.33.3 90 +
+4 -1
pkgs/development/compilers/dtc/default.nix
··· 27 # based on without requiring the setup.py rework 28 # https://git.kernel.org/pub/scm/utils/dtc/dtc.git/commit/?id=383e148b70a47ab15f97a19bb999d54f9c3e810f 29 ./python-3.10.patch 30 ]; 31 32 nativeBuildInputs = [ flex bison pkg-config which ] ··· 38 patchShebangs pylibfdt/ 39 ''; 40 41 - makeFlags = [ "PYTHON=python" ]; 42 installFlags = [ "INSTALL=install" "PREFIX=$(out)" "SETUP_PREFIX=$(out)" ]; 43 44 # Checks are broken on aarch64 darwin
··· 27 # based on without requiring the setup.py rework 28 # https://git.kernel.org/pub/scm/utils/dtc/dtc.git/commit/?id=383e148b70a47ab15f97a19bb999d54f9c3e810f 29 ./python-3.10.patch 30 + 31 + # fix dtc static building 32 + ./0001-Depend-on-.a-instead-of-.so-when-building-static.patch 33 ]; 34 35 nativeBuildInputs = [ flex bison pkg-config which ] ··· 41 patchShebangs pylibfdt/ 42 ''; 43 44 + makeFlags = [ "PYTHON=python" "STATIC_BUILD=${toString stdenv.hostPlatform.isStatic}" ]; 45 installFlags = [ "INSTALL=install" "PREFIX=$(out)" "SETUP_PREFIX=$(out)" ]; 46 47 # Checks are broken on aarch64 darwin