{"thread":{"id":"56430","subject":"[PATCH v3] make: add INSTALL_STRIP option variable","startedAt":"2021-09-02T12:14:50Z","lastAt":"2021-09-18T07:49:49Z","messageCount":5,"participants":["Bagas Sanjaya","Ævar Arnfjörð Bjarmason","Junio C Hamano"],"isPatch":true,"patchVersion":3,"patchTotal":null},"messages":[{"id":"434516","messageId":"20210902121104.14778-1-bagasdotme@gmail.com","threadId":"56430","inReplyTo":null,"subject":"[PATCH v3] make: add INSTALL_STRIP option variable","fromName":"Bagas Sanjaya","fromEmail":"bagasdotme@gmail.com","sentAt":"2021-09-02T12:11:05Z","receivedAt":"2021-09-02T12:14:50Z","isPatch":true,"sender":{"key":"bagasdotme@gmail.com","avatar":"https://avatars.githubusercontent.com/u/40219486?v=4"},"body":"From: Junio C Hamano <gitster@pobox.com>\n\nAdd $(INSTALL_STRIP), which allows passing stripping options to\n$(INSTALL).\n\nFor this to work, installing executables must be split to installing\ncompiled binaries and scripts portions, since $(INSTALL_STRIP) is only\nmeaningful to the former.\n\nUsers can set this variable depending on their system. For example,\nLinux users can use `-s --strip-program=strip`, while FreeBSD users can\nsimply set to `-s` and choose strip program with $STRIPBIN.\n\nSigned-off-by: Bagas Sanjaya <bagasdotme@gmail.com>\n---\n\n Changes from v3 [1]:\n   - Squash suggestion patch from Junio, which suggests dropping\n     install-stripped target and rename $(INSTALL_OPTS) to\n     $(INSTALL_STRIP).\n   - Describe $(INSTALL_STRIP) usage on the top of Makefile\n\n Note: In the future, we may add global $(INSTALL_OPTS), which applies\n to both compiled binaries and scripts. When such happens, we should\n rename $(INSTALL_STRIP) to $(INSTALL_STRIP_OPTS).\n\n [1]: https://lore.kernel.org/git/xmqqo89cqkt9.fsf@gitster.g/T/#t\n\n Makefile | 15 ++++++++++++---\n 1 file changed, 12 insertions(+), 3 deletions(-)\n\ndiff --git a/Makefile b/Makefile\nindex d1feab008f..ebef4da50c 100644\n--- a/Makefile\n+++ b/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@@ -3004,7 +3007,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 +3017,17 @@ profile-install: profile\n profile-fast-install: profile-fast\n \t$(MAKE) install\n \n+INSTALL_STRIP =\n+\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) $(ALL_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_bindir_programs) '$(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 \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: 6c40894d2466d4e7fddc047a05116aa9d14712ee\n-- \n2.25.1\n\n"},{"id":"436095","messageId":"87a6kchlqc.fsf@evledraar.gmail.com","threadId":"56430","inReplyTo":"20210902121104.14778-1-bagasdotme@gmail.com","subject":"Re: [PATCH v3] make: add INSTALL_STRIP option variable","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2021-09-16T09:50:30Z","receivedAt":"2021-09-16T10:13:20Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"\nOn Thu, Sep 02 2021, Bagas Sanjaya wrote:\n\n> From: Junio C Hamano <gitster@pobox.com>\n>\n> Add $(INSTALL_STRIP), which allows passing stripping options to\n> $(INSTALL).\n>\n> For this to work, installing executables must be split to installing\n> compiled binaries and scripts portions, since $(INSTALL_STRIP) is only\n> meaningful to the former.\n>\n> Users can set this variable depending on their system. For example,\n> Linux users can use `-s --strip-program=strip`, while FreeBSD users can\n> simply set to `-s` and choose strip program with $STRIPBIN.\n>\n> Signed-off-by: Bagas Sanjaya <bagasdotme@gmail.com>\n> ---\n>\n>  Changes from v3 [1]:\n>    - Squash suggestion patch from Junio, which suggests dropping\n>      install-stripped target and rename $(INSTALL_OPTS) to\n>      $(INSTALL_STRIP).\n>    - Describe $(INSTALL_STRIP) usage on the top of Makefile\n>\n>  Note: In the future, we may add global $(INSTALL_OPTS), which applies\n>  to both compiled binaries and scripts. When such happens, we should\n>  rename $(INSTALL_STRIP) to $(INSTALL_STRIP_OPTS).\n\nI see this landed on \"master\" already, but in case you're interested on\nfollow-ing up:\n\nI think the suggestion in\nhttps://lore.kernel.org/git/xmqqo89cqkt9.fsf@gitster.g/ is to make this\na boolean variable, and in any case I think that makes more sense here,\nsince....\n\n>  [1]: https://lore.kernel.org/git/xmqqo89cqkt9.fsf@gitster.g/T/#t\n>\n>  Makefile | 15 ++++++++++++---\n>  1 file changed, 12 insertions(+), 3 deletions(-)\n>\n> diff --git a/Makefile b/Makefile\n> index d1feab008f..ebef4da50c 100644\n> --- a/Makefile\n> +++ b/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> @@ -3004,7 +3007,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 +3017,17 @@ profile-install: profile\n>  profile-fast-install: profile-fast\n>  \t$(MAKE) install\n>  \n> +INSTALL_STRIP =\n> +\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) $(ALL_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_bindir_programs) '$(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>  \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>\n> base-commit: 6c40894d2466d4e7fddc047a05116aa9d14712ee\n\n...this really is not an INSTALL_STRIP but (using some combination of\nyour own naming) a \"INSTALL_XPROGRAMS_OPTS\" or \"INSTALL_XOPTS\". I.e. you\ncan supply arbitrary options to \"install\" with this, but only for\nbinaries.\n\nAlso doesn't this misbehave under MSVC when combined with *.pdb files?\nSee dce7d295514 (msvc: support building Git using MS Visual C++,\n2019-06-25) and a8b5355d808 (msvc: copy the correct `.pdb` files in the\nMakefile target `install`, 2020-09-21) , i.e. the code at the start of\nyour diff context.\n\nDoes stripping the main binary while having a *.pdb file error or MSCV,\nor make the *.pdb file useless, or is *.pdb an unconditional equivalent\nof INSTALL_STRIP=-s on MSCV that we should disable if this\nhopefully-then-boolean INSTALL_STRIP option is enabled?\n"},{"id":"436106","messageId":"e5e9848b-4378-8478-6ade-8e5f97295181@gmail.com","threadId":"56430","inReplyTo":"87a6kchlqc.fsf@evledraar.gmail.com","subject":"Re: [PATCH v3] make: add INSTALL_STRIP option variable","fromName":"Bagas Sanjaya","fromEmail":"bagasdotme@gmail.com","sentAt":"2021-09-16T10:36:17Z","receivedAt":"2021-09-16T10:36:26Z","isPatch":true,"sender":{"key":"bagasdotme@gmail.com","avatar":"https://avatars.githubusercontent.com/u/40219486?v=4"},"body":"On 16/09/21 16.50, Ævar Arnfjörð Bjarmason wrote:\n> ...this really is not an INSTALL_STRIP but (using some combination of\n> your own naming) a \"INSTALL_XPROGRAMS_OPTS\" or \"INSTALL_XOPTS\". I.e. you\n> can supply arbitrary options to \"install\" with this, but only for\n> binaries.\n> \n\nI think it should have been \"INSTALL_STRIP_OPTS\". This could haven't \nbeen issue if we add global (applicable tobinaries and scripts) \n\"INSTALL_OPTS\".\n\n> Also doesn't this misbehave under MSVC when combined with *.pdb files?\n> See dce7d295514 (msvc: support building Git using MS Visual C++,\n> 2019-06-25) and a8b5355d808 (msvc: copy the correct `.pdb` files in the\n> Makefile target `install`, 2020-09-21) , i.e. the code at the start of\n> your diff context.\n> \n> Does stripping the main binary while having a *.pdb file error or MSCV,\n> or make the *.pdb file useless, or is *.pdb an unconditional equivalent\n> of INSTALL_STRIP=-s on MSCV that we should disable if this\n> hopefully-then-boolean INSTALL_STRIP option is enabled?\n> \n\nI'm not familiar with MSVC, so I can't tell further except you can pass \nnull (\"\") to INSTALL_STRIP.\n\n-- \nAn old man doll... just what I always wanted! - Clara\n"},{"id":"436146","messageId":"xmqqlf3wtjcq.fsf@gitster.g","threadId":"56430","inReplyTo":"87a6kchlqc.fsf@evledraar.gmail.com","subject":"Re: [PATCH v3] make: add INSTALL_STRIP option variable","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2021-09-16T19:23:49Z","receivedAt":"2021-09-16T19:23:55Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:\n\n> I think the suggestion in\n> https://lore.kernel.org/git/xmqqo89cqkt9.fsf@gitster.g/ is to make this\n> a boolean variable, and in any case I think that makes more sense here,\n\nI do not think I ever suggested to use a boolean in that message nor\nin the other message in thread.  A boolean may convey the wish of\nthe users to cause the binaries installed in a stripped form, but\ndoes not allow them to express how to do so on their particular\nplatform (e.g. where is \"strip\" installed? how to tell \"install\"\nto strip?).\n\n> since....\n> ...\n> ...this really is not an INSTALL_STRIP but (using some combination of\n> your own naming) a \"INSTALL_XPROGRAMS_OPTS\" or \"INSTALL_XOPTS\". I.e. you\n> can supply arbitrary options to \"install\" with this, but only for\n> binaries.\n\nINSTALL_STRIP_OPTS is a perfectly fine name for this thing.  \n\nIt should not say XPROGRAMS but should say STRIP to express the\nintent, i.e. why we have it, not what we do with it.  The fact that\nit wants to apply to binaries and not to scripts is an\nimplementation detail.\n\nOf course, when you want to \"affect\" only binaries but not scripts,\neven if the effect you are trying to cause on them is _not_ \"strip\",\nyou could abuse the option, but the name must make it clear that\nsuch a use is an abuse.  By naming the variable with STRIP in its\nname, we reserve the right to change to which instance of $(INSTALL)\nthe option is applied to to better implement the goal to \"strip\nwhile installing\", which might not be a simple \"binaries get it,\nscripts don't\" we currently have, and it will be clear to those who\nhave been abusing the option to affect \"only binaries and not\nscripts\" that they have no right to complain.\n\nHTH.\n"},{"id":"436298","messageId":"87mtoacoh6.fsf@evledraar.gmail.com","threadId":"56430","inReplyTo":"e5e9848b-4378-8478-6ade-8e5f97295181@gmail.com","subject":"Re: [PATCH v3] make: add INSTALL_STRIP option variable","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2021-09-18T07:46:44Z","receivedAt":"2021-09-18T07:49:49Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"\nOn Thu, Sep 16 2021, Bagas Sanjaya wrote:\n\n> On 16/09/21 16.50, Ævar Arnfjörð Bjarmason wrote:\n>> ...this really is not an INSTALL_STRIP but (using some combination of\n>> your own naming) a \"INSTALL_XPROGRAMS_OPTS\" or \"INSTALL_XOPTS\". I.e. you\n>> can supply arbitrary options to \"install\" with this, but only for\n>> binaries.\n>> \n>\n> I think it should have been \"INSTALL_STRIP_OPTS\". This could haven't\n> been issue if we add global (applicable tobinaries and scripts) \n> \"INSTALL_OPTS\".\n\nIsn't the reason to have that split-up because it would break if you try\nto strip(1) a Perl or shellscript?\n\n>> Also doesn't this misbehave under MSVC when combined with *.pdb files?\n>> See dce7d295514 (msvc: support building Git using MS Visual C++,\n>> 2019-06-25) and a8b5355d808 (msvc: copy the correct `.pdb` files in the\n>> Makefile target `install`, 2020-09-21) , i.e. the code at the start of\n>> your diff context.\n>> Does stripping the main binary while having a *.pdb file error or\n>> MSCV,\n>> or make the *.pdb file useless, or is *.pdb an unconditional equivalent\n>> of INSTALL_STRIP=-s on MSCV that we should disable if this\n>> hopefully-then-boolean INSTALL_STRIP option is enabled?\n>> \n>\n> I'm not familiar with MSVC, so I can't tell further except you can\n> pass null (\"\") to INSTALL_STRIP.\n\nYes, to be clear I'm not asking for practical assistance in building git\nwith MSVC.\n\nI'm pointing out that it seems that the option you added introduces an\nedge case in how we combine with an existing option/ifdef that may not\nbe desirable, and that you might be interested in looking at\nit/submitting a follow-up patch if it does turn out that the interaction\nis undesirable.\n"}]}