git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 1/2] make: add install-stripped target

From
Đoàn Trần Công Danh <congdanhqx@gmail.com>
Date
Aug 27, 2021, 12:41 UTC
Message-ID
<YSjdc/tNlhbCosC2@danh.dev>
In-Reply-To
<b2005b0f-9181-526b-ebf5-58fca44299b5@gmail.com>
On 2021-08-27 14:57:56+0700, Bagas Sanjaya <bagasdotme@gmail.com> wrote:
Show 23 quoted lines
> On 27/08/21 03.08, Junio C Hamano wrote:
> > It also depends on "strip" not to break handlinks to the same
> > binary.  "git" is linked to many built-in command binary like
> > "git-cat-file" and "git-remote-$curl" for various protocols are
> > installed by creating links to "git-remote-http".  It seems that the
> > "strip" command from GNU binutils package strips such a binary
> > in-place, but I do not think there is no fundamental reason to
> > believe that everybody else's "strip" would behave that way.
> > 
> 
> Maybe hardlinks?
> 
> > I would have expected that 'install-stripped' and 'install' targets
> > would run the same recipe, and when $(install_bindir_programs) are
> > installed in $(bindir) using $(INSTALL), we would optionally pass
> > the '--strip' option to the $(INSTALL) program when the recipe is
> > run for the install-stripped target.  All the tricky symlinking,
> > hardlinking and copying happens only on the result of that step, and
> > the strip step should happen before that, I would think.
> > 
> 
> Did you mean copying recipe of 'install' to 'install-stripped' and the
> latter s/$(INSTALL)/$(INSTALL -s --strip-program="$(STRIP)"/)?
I think Junio meant something like this:
---- 8< ----
diff --git a/Makefile b/Makefile
index 429c276058..70b7ef9ce1 100644
--- a/Makefile
+++ b/Makefile
@@ -3004,7 +3004,8 @@ mergetools_instdir = $(prefix)/$(mergetoolsdir)
 endif
 mergetools_instdir_SQ = $(subst ','\'',$(mergetools_instdir))
 
-install_bindir_programs := $(patsubst %,%$X,$(BINDIR_PROGRAMS_NEED_X)) $(BINDIR_PROGRAMS_NO_X)
+install_bindir_xprograms := $(patsubst %,%$X,$(BINDIR_PROGRAMS_NEED_X))
+install_bindir_programs := $(install_bindir_xprograms) $(BINDIR_PROGRAMS_NO_X)
 
 .PHONY: profile-install profile-fast-install
 profile-install: profile
@@ -3013,12 +3014,18 @@ profile-install: profile
 profile-fast-install: profile-fast
 	$(MAKE) install
 
-install: all
+INSTALL_OPTS :=
+
+install-strip: INSTALL_OPTS := -s --strip-program=$(STRIP)
+
+install-strip install: all
 	$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(bindir_SQ)'
 	$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(gitexec_instdir_SQ)'
-	$(INSTALL) $(ALL_PROGRAMS) '$(DESTDIR_SQ)$(gitexec_instdir_SQ)'
+	$(INSTALL) $(INSTALL_OPTS) $(PROGRAMS) '$(DESTDIR_SQ)$(gitexec_instdir_SQ)'
+	$(INSTALL) $(SCRIPTS) '$(DESTDIR_SQ)$(gitexec_instdir_SQ)'
 	$(INSTALL) -m 644 $(SCRIPT_LIB) '$(DESTDIR_SQ)$(gitexec_instdir_SQ)'
-	$(INSTALL) $(install_bindir_programs) '$(DESTDIR_SQ)$(bindir_SQ)'
+	$(INSTALL) $(INSTALL_OPTS) $(install_bindir_xprograms) '$(DESTDIR_SQ)$(bindir_SQ)'
+	$(INSTALL) $(BINDIR_PROGRAMS_NO_X) '$(DESTDIR_SQ)$(bindir_SQ)'
 ifdef MSVC
 	# We DO NOT install the individual foo.o.pdb files because they
 	# have already been rolled up into the exe's pdb file.
---- >8 -----
-- 
Danh
Previous: Bagas SanjayaNext: Bagas Sanjaya
Message 5 of 8 in “make: install stripped Git”
  1. 0/2 make: install stripped GitBagas Sanjaya, Aug 26, 2021
  2. 1/2 make: add install-stripped targetBagas Sanjaya, Aug 26, 2021
  3. Junio C HamanoAug 26, 2021
  4. Bagas SanjayaAug 27, 2021
  5. Đoàn Trần Công DanhAug 27, 2021
  6. 2/2 make: delete strip targetBagas Sanjaya, Aug 26, 2021
  7. Ævar Arnfjörð BjarmasonAug 26, 2021
  8. Junio C HamanoAug 26, 2021

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.