From: Ezekiel Newren via GitGitGadget Date: Thu, 02 Oct 2025 23:27:25 GMT Subject: [PATCH v2 0/2] Makefile update libgit.a: Include xdiff and reftable in libgit.a Message-ID: In-Reply-To: Changes in v2: * Add xdiff and reftable objects directly to LIB_OBJS. * Explain why xdiff-objs is removed. Original cover letter: ====================== Add xdiff and reftable to the static library libgit.a that Makefile produces. Meson does not require any changes since it already includes those libraries. The motivation is to simplify Rust's job of linking against the C code by requiring it to only link against a single static library (libgit.a). The Rust compiler only needs to know how to link against libgit.a in 2 cases that I can think of: * Rust unit tests * Rust defining the main function Otherwise Rust can be compiled without linking, and then Makefile and Meson can use Cargo's produced static lib files to build Git. Note: The flag -fPIE or -fPIC is required for Makefile to build libgit.a in a way that Cargo can use. It has been deliberately omitted from the Makefile, for now, since Rust isn't part of Git (yet). Ezekiel Newren (2): make: delete XDIFF_LIB, add xdiff to LIB_OBJS make: delete REFTABLE_LIB, add reftable to LIB_OBJS Makefile | 62 +++++++++++++++++++++----------------------------------- 1 file changed, 23 insertions(+), 39 deletions(-) base-commit: a91ca5db0318b6fda5a6721ee843f56e7e2fadfc Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-2065%2Fezekielnewren%2Fmerge_xdiff_and_reftable_with_libgit-v2 Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-2065/ezekielnewren/merge_xdiff_and_reftable_with_libgit-v2 Pull-Request: https://github.com/git/git/pull/2065 Range-diff vs v1: 1: fdcf5a0de8 < -: ---------- make: move xdiff and reftable objects before GITLIBS 2: 28e7fd27b6 ! 1: b535a456ae make: delete XDIFF_LIB, add xdiff to LIB_OBJS @@ Commit message Changes to Meson are not required as the xdiff library is already included in Meson's libgit.a. + xdiff-objs was a historical make target to allow building just the + objects in xdiff. Since it was defined in terms of XDIFF_OBJS (which + no longer exists) this convenience make target no longer makes sense. + Remove it. + Signed-off-by: Ezekiel Newren ## Makefile ## @@ Makefile: export PYTHON_PATH REFTABLE_LIB = reftable/libreftable.a GENERATED_H += command-list.h -@@ Makefile: XDIFF_OBJS += xdiff/xmerge.o - XDIFF_OBJS += xdiff/xpatience.o - XDIFF_OBJS += xdiff/xprepare.o - XDIFF_OBJS += xdiff/xutils.o --.PHONY: xdiff-objs --xdiff-objs: $(XDIFF_OBJS) -+LIB_OBJS += $(XDIFF_OBJS) +@@ Makefile: LIB_OBJS += write-or-die.o + LIB_OBJS += ws.o + LIB_OBJS += wt-status.o + LIB_OBJS += xdiff-interface.o ++LIB_OBJS += xdiff/xdiffi.o ++LIB_OBJS += xdiff/xemit.o ++LIB_OBJS += xdiff/xhistogram.o ++LIB_OBJS += xdiff/xmerge.o ++LIB_OBJS += xdiff/xpatience.o ++LIB_OBJS += xdiff/xprepare.o ++LIB_OBJS += xdiff/xutils.o - REFTABLE_OBJS += reftable/basics.o - REFTABLE_OBJS += reftable/error.o -@@ Makefile: REFTABLE_OBJS += reftable/table.o - REFTABLE_OBJS += reftable/tree.o - REFTABLE_OBJS += reftable/writer.o + BUILTIN_OBJS += builtin/add.o + BUILTIN_OBJS += builtin/am.o +@@ Makefile: CLAR_TEST_OBJS += $(UNIT_TEST_DIR)/unit-test.o + + UNIT_TEST_OBJS += $(UNIT_TEST_DIR)/test-lib.o -# xdiff and reftable libs may in turn depend on what is in libgit.a -GITLIBS = common-main.o $(LIB_FILE) $(XDIFF_LIB) $(REFTABLE_LIB) $(LIB_FILE) @@ Makefile: REFTABLE_OBJS += reftable/table.o EXTLIBS = GIT_USER_AGENT = git/$(GIT_VERSION) +@@ Makefile: reconfigure config.mak.autogen: config.status + .PHONY: reconfigure # This is a convenience target. + endif + +-XDIFF_OBJS += xdiff/xdiffi.o +-XDIFF_OBJS += xdiff/xemit.o +-XDIFF_OBJS += xdiff/xhistogram.o +-XDIFF_OBJS += xdiff/xmerge.o +-XDIFF_OBJS += xdiff/xpatience.o +-XDIFF_OBJS += xdiff/xprepare.o +-XDIFF_OBJS += xdiff/xutils.o +-.PHONY: xdiff-objs +-xdiff-objs: $(XDIFF_OBJS) +- + REFTABLE_OBJS += reftable/basics.o + REFTABLE_OBJS += reftable/error.o + REFTABLE_OBJS += reftable/block.o @@ Makefile: OBJECTS += $(GIT_OBJS) OBJECTS += $(SCALAR_OBJS) OBJECTS += $(PROGRAM_OBJS) 3: 8549f63415 ! 2: 9031610dc8 make: delete REFTABLE_LIB, add reftable to LIB_OBJS @@ Makefile: export PYTHON_PATH GENERATED_H += command-list.h GENERATED_H += config-list.h -@@ Makefile: REFTABLE_OBJS += reftable/system.o - REFTABLE_OBJS += reftable/table.o - REFTABLE_OBJS += reftable/tree.o - REFTABLE_OBJS += reftable/writer.o -+LIB_OBJS += $(REFTABLE_OBJS) +@@ Makefile: LIB_OBJS += refs/iterator.o + LIB_OBJS += refs/packed-backend.o + LIB_OBJS += refs/ref-cache.o + LIB_OBJS += refspec.o ++LIB_OBJS += reftable/basics.o ++LIB_OBJS += reftable/error.o ++LIB_OBJS += reftable/block.o ++LIB_OBJS += reftable/blocksource.o ++LIB_OBJS += reftable/iter.o ++LIB_OBJS += reftable/merged.o ++LIB_OBJS += reftable/pq.o ++LIB_OBJS += reftable/record.o ++LIB_OBJS += reftable/stack.o ++LIB_OBJS += reftable/system.o ++LIB_OBJS += reftable/table.o ++LIB_OBJS += reftable/tree.o ++LIB_OBJS += reftable/writer.o + LIB_OBJS += remote.o + LIB_OBJS += replace-object.o + LIB_OBJS += repo-settings.o +@@ Makefile: CLAR_TEST_OBJS += $(UNIT_TEST_DIR)/unit-test.o + + UNIT_TEST_OBJS += $(UNIT_TEST_DIR)/test-lib.o -# reftable lib may in turn depend on what is in libgit.a -GITLIBS = common-main.o $(LIB_FILE) $(REFTABLE_LIB) $(LIB_FILE) @@ Makefile: REFTABLE_OBJS += reftable/system.o EXTLIBS = GIT_USER_AGENT = git/$(GIT_VERSION) +@@ Makefile: reconfigure config.mak.autogen: config.status + .PHONY: reconfigure # This is a convenience target. + endif + +-REFTABLE_OBJS += reftable/basics.o +-REFTABLE_OBJS += reftable/error.o +-REFTABLE_OBJS += reftable/block.o +-REFTABLE_OBJS += reftable/blocksource.o +-REFTABLE_OBJS += reftable/iter.o +-REFTABLE_OBJS += reftable/merged.o +-REFTABLE_OBJS += reftable/pq.o +-REFTABLE_OBJS += reftable/record.o +-REFTABLE_OBJS += reftable/stack.o +-REFTABLE_OBJS += reftable/system.o +-REFTABLE_OBJS += reftable/table.o +-REFTABLE_OBJS += reftable/tree.o +-REFTABLE_OBJS += reftable/writer.o +- + TEST_OBJS := $(patsubst %$X,%.o,$(TEST_PROGRAMS)) $(patsubst %,t/helper/%,$(TEST_BUILTINS_OBJS)) + + .PHONY: test-objs @@ Makefile: OBJECTS += $(SCALAR_OBJS) OBJECTS += $(PROGRAM_OBJS) OBJECTS += $(TEST_OBJS) -- gitgitgadget