{"thread":{"id":"56410","subject":"[PATCH RESEND v2] make: add install-stripped target","startedAt":"2021-08-31T01:34:18Z","lastAt":"2021-09-01T17:15:20Z","messageCount":4,"participants":["Bagas Sanjaya","Junio C Hamano"],"isPatch":true,"patchVersion":2,"patchTotal":null},"messages":[{"id":"434215","messageId":"20210831013235.388682-1-bagasdotme@gmail.com","threadId":"56410","inReplyTo":null,"subject":"[PATCH RESEND v2] make: add install-stripped target","fromName":"Bagas Sanjaya","fromEmail":"bagasdotme@gmail.com","sentAt":"2021-08-31T01:32:36Z","receivedAt":"2021-08-31T01:34:18Z","isPatch":true,"sender":{"key":"bagasdotme@gmail.com","avatar":"https://avatars.githubusercontent.com/u/40219486?v=4"},"body":"Add the target that install Git with stripped executables.\n\ninstall and install-stripped share the almost-same recipe, with the\ndifference only on extra arguments to $(INSTALL). In order for this to\nwork properly, installing all programs ($(ALL_PROGRAMS) and\n$(install_bindir_programs)) must be splitted into separate portions for\ncompiled programs and scripts. For the former, add $(INSTALL_OPTS) and\nfor the latter, don't add anything.\n\n$(INSTALL_OPTS) contains stripping options that are passed from\ninstall-stripped.\n\nSigned-off-by: Bagas Sanjaya <bagasdotme@gmail.com>\n---\n\n Changes from v1:\n - Share recipes between install-stripped and install targets (suggested\n   by Junio)\n - Don't delete 'strip' target. There may exist scripts that depend on\n   that target. Once this patch is integrated, deprecation notice can\n   be displayed when running the target, but it is done in separate\n   patch.\n\n Makefile | 18 ++++++++++++++----\n 1 file changed, 14 insertions(+), 4 deletions(-)\n\ndiff --git a/Makefile b/Makefile\nindex d1feab008f..28d1e9bfae 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -3004,7 +3004,8 @@ mergetools_instdir = $(prefix)/$(mergetoolsdir)\n endif\n mergetools_instdir_SQ = $(subst ','\\'',$(mergetools_instdir))\n \n-install_bindir_programs := $(patsubst %,%$X,$(BINDIR_PROGRAMS_NEED_X)) $(BINDIR_PROGRAMS_NO_X)\n+install_bindir_xprograms := $(patsubst %,%$X,$(BINDIR_PROGRAMS_NEED_X))\n+install_bindir_programs := $(install_bindir_xprograms) $(BINDIR_PROGRAMS_NO_X)\n \n .PHONY: profile-install profile-fast-install\n profile-install: profile\n@@ -3013,12 +3014,21 @@ profile-install: profile\n profile-fast-install: profile-fast\n \t$(MAKE) install\n \n-install: all\n+INSTALL_OPTS =\n+\n+.PHONY: install-stripped\n+\n+install-stripped: INSTALL_OPTS = -s --strip-program=$(STRIP)\n+\n+install-stripped install: all\n \t$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(bindir_SQ)'\n \t$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(gitexec_instdir_SQ)'\n-\t$(INSTALL) $(ALL_PROGRAMS) '$(DESTDIR_SQ)$(gitexec_instdir_SQ)'\n+\t$(INSTALL) $(INSTALL_OPTS) $(PROGRAMS) '$(DESTDIR_SQ)$(gitexec_instdir_SQ)'\n+\t$(INSTALL) $(SCRIPTS) '$(DESTDIR_SQ)$(gitexec_instdir_SQ)'\n \t$(INSTALL) -m 644 $(SCRIPT_LIB) '$(DESTDIR_SQ)$(gitexec_instdir_SQ)'\n-\t$(INSTALL) $(install_bindir_programs) '$(DESTDIR_SQ)$(bindir_SQ)'\n+\t$(INSTALL) $(INSTALL_OPTS) $(install_bindir_xprograms) '$(DESTDIR_SQ)$(bindir_SQ)'\n+\t$(INSTALL) $(BINDIR_PROGRAMS_NO_X) '$(DESTDIR_SQ)$(bindir_SQ)'\n+\n ifdef MSVC\n \t# We DO NOT install the individual foo.o.pdb files because they\n \t# have already been rolled up into the exe's pdb file.\n\nbase-commit: c4203212e360b25a1c69467b5a8437d45a373cac\n-- \n2.25.1\n\n"},{"id":"434305","messageId":"xmqq8s0hwnkm.fsf@gitster.g","threadId":"56410","inReplyTo":"20210831013235.388682-1-bagasdotme@gmail.com","subject":"Re: [PATCH RESEND v2] make: add install-stripped target","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2021-08-31T17:06:49Z","receivedAt":"2021-08-31T17:06:52Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Bagas Sanjaya <bagasdotme@gmail.com> writes:\n\n> Add the target that install Git with stripped executables.\n> ...\n> +\n> +install-stripped: INSTALL_OPTS = -s --strip-program=$(STRIP)\n\nNot everybody's $(INSTALL) supports --strip-program, does it?  \n\nFreeBSD seems to lack the option, and instead uses the $STRIPBIN\nenvironment variable to specify which program to use.\n\nThe manual page for macOS [*] does not mention --strip-program or\nSTRIPBIN.\n\nIf the user leaves STRIP as the default (i.e. strip), this target\nfails, not because the user does not have 'strip', but because the\n'install' used by the user does not know the --strip-program option,\neven though there is no need to use the option in such a case.\n\nGiven that, I am not sure if we really want \"install-stripped\"\ntarget.  Adding INSTALL_OPTS make variable that defaults to an empty\nstring is a good idea, but we probably can and should stop there.\n\nThen users can do any of the following:\n\n\t$ make INSTALL_OPTS=-s install\n\n\t$ STRIPBIN=my-strip make INSTALL_OPTS=-s install\n\ndepending on their system, which sounds sufficient, and is a vast\nimprovement over the current\n\n\t$ make ; make strip ; make install \n\nI would think.\n\n\n[Reference]\n\n* https://opensource.apple.com/source/file_cmds/file_cmds-321.40.3/install/install.1.auto.html\n"},{"id":"434414","messageId":"96e4b388-d924-e5a9-b23f-07cc0007c328@gmail.com","threadId":"56410","inReplyTo":"xmqq8s0hwnkm.fsf@gitster.g","subject":"Re: [PATCH RESEND v2] make: add install-stripped target","fromName":"Bagas Sanjaya","fromEmail":"bagasdotme@gmail.com","sentAt":"2021-09-01T11:31:26Z","receivedAt":"2021-09-01T11:31:32Z","isPatch":true,"sender":{"key":"bagasdotme@gmail.com","avatar":"https://avatars.githubusercontent.com/u/40219486?v=4"},"body":"On 01/09/21 00.06, Junio C Hamano wrote:\n> Given that, I am not sure if we really want \"install-stripped\"\n> target.  Adding INSTALL_OPTS make variable that defaults to an empty\n> string is a good idea, but we probably can and should stop there.\n> \n> Then users can do any of the following:\n> \n> \t$ make INSTALL_OPTS=-s install\n> \n> \t$ STRIPBIN=my-strip make INSTALL_OPTS=-s install\n> \n> depending on their system, which sounds sufficient, and is a vast\n> improvement over the current\n> \n> \t$ make ; make strip ; make install\n> \n> I would think.\n\nIf we make $(INSTALL_OPTS) applies to both compiled executables and \nscripts, we have problem that $(INSTALL) -s only works for the former.\n\n-- \nAn old man doll... just what I always wanted! - Clara\n"},{"id":"434456","messageId":"xmqqo89cqkt9.fsf@gitster.g","threadId":"56410","inReplyTo":"96e4b388-d924-e5a9-b23f-07cc0007c328@gmail.com","subject":"Re: [PATCH RESEND v2] make: add install-stripped target","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2021-09-01T17:15:14Z","receivedAt":"2021-09-01T17:15:20Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Bagas Sanjaya <bagasdotme@gmail.com> writes:\n\n> If we make $(INSTALL_OPTS) applies to both compiled executables and\n> scripts, we have problem that $(INSTALL) -s only works for the former.\n\nThen don't make it apply to both ;-)\n\nIsn't that what your patch did for early part of the install target?\n$(PROGRAMS) are installed with $(INSTALL_OPTS) while the invocation\nof $(INSTALL) for $(SCRIPTS) lack $(INSTALL_OPTS).\n\nIf we were to pursue this further, it probably is a good idea to\nrename the $(INSTALL_OPTS) to $(INSTALL_STRIP) to avoid complaints\nby confused users.\n\nSomething like this squashed into your patch, perhaps.\n\n Makefile | 15 +++++++--------\n 1 file changed, 7 insertions(+), 8 deletions(-)\n\ndiff --git c/Makefile w/Makefile\nindex 28d1e9bfae..ebef4da50c 100644\n--- c/Makefile\n+++ w/Makefile\n@@ -465,6 +465,9 @@ all::\n # the global variable _wpgmptr containing the absolute path of the current\n # executable (this is the case on Windows).\n #\n+# INSTALL_STRIP can be set to \"-s\" to strip binaries during installation,\n+# if your $(INSTALL) command supports the option.\n+#\n # Define GENERATE_COMPILATION_DATABASE to \"yes\" to generate JSON compilation\n # database entries during compilation if your compiler supports it, using the\n # `-MJ` flag. The JSON entries will be placed in the `compile_commands/`\n@@ -3014,19 +3017,15 @@ profile-install: profile\n profile-fast-install: profile-fast\n \t$(MAKE) install\n \n-INSTALL_OPTS =\n-\n-.PHONY: install-stripped\n-\n-install-stripped: INSTALL_OPTS = -s --strip-program=$(STRIP)\n+INSTALL_STRIP =\n \n-install-stripped install: all\n+install: all\n \t$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(bindir_SQ)'\n \t$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(gitexec_instdir_SQ)'\n-\t$(INSTALL) $(INSTALL_OPTS) $(PROGRAMS) '$(DESTDIR_SQ)$(gitexec_instdir_SQ)'\n+\t$(INSTALL) $(INSTALL_STRIP) $(PROGRAMS) '$(DESTDIR_SQ)$(gitexec_instdir_SQ)'\n \t$(INSTALL) $(SCRIPTS) '$(DESTDIR_SQ)$(gitexec_instdir_SQ)'\n \t$(INSTALL) -m 644 $(SCRIPT_LIB) '$(DESTDIR_SQ)$(gitexec_instdir_SQ)'\n-\t$(INSTALL) $(INSTALL_OPTS) $(install_bindir_xprograms) '$(DESTDIR_SQ)$(bindir_SQ)'\n+\t$(INSTALL) $(INSTALL_STRIP) $(install_bindir_xprograms) '$(DESTDIR_SQ)$(bindir_SQ)'\n \t$(INSTALL) $(BINDIR_PROGRAMS_NO_X) '$(DESTDIR_SQ)$(bindir_SQ)'\n \n ifdef MSVC\n\n"}]}