git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH v3] make: add INSTALL_STRIP option variable
@ 2021-09-02 12:11 Bagas Sanjaya
  2021-09-16  9:50 ` Ævar Arnfjörð Bjarmason
  0 siblings, 1 reply; 5+ messages in thread
From: Bagas Sanjaya @ 2021-09-02 12:11 UTC (permalink / raw)
  To: git
  Cc: Junio C Hamano, Carlo Arenas,
	Đoàn Trần Công Danh, felipe.contreras,
	Ævar Arnfjörð Bjarmason, Eric Sunshine,
	Johannes Schindelin, Bagas Sanjaya

From: Junio C Hamano <gitster@pobox.com>

Add $(INSTALL_STRIP), which allows passing stripping options to
$(INSTALL).

For this to work, installing executables must be split to installing
compiled binaries and scripts portions, since $(INSTALL_STRIP) is only
meaningful to the former.

Users can set this variable depending on their system. For example,
Linux users can use `-s --strip-program=strip`, while FreeBSD users can
simply set to `-s` and choose strip program with $STRIPBIN.

Signed-off-by: Bagas Sanjaya <bagasdotme@gmail.com>
---

 Changes from v3 [1]:
   - Squash suggestion patch from Junio, which suggests dropping
     install-stripped target and rename $(INSTALL_OPTS) to
     $(INSTALL_STRIP).
   - Describe $(INSTALL_STRIP) usage on the top of Makefile

 Note: In the future, we may add global $(INSTALL_OPTS), which applies
 to both compiled binaries and scripts. When such happens, we should
 rename $(INSTALL_STRIP) to $(INSTALL_STRIP_OPTS).

 [1]: https://lore.kernel.org/git/xmqqo89cqkt9.fsf@gitster.g/T/#t

 Makefile | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/Makefile b/Makefile
index d1feab008f..ebef4da50c 100644
--- a/Makefile
+++ b/Makefile
@@ -465,6 +465,9 @@ all::
 # the global variable _wpgmptr containing the absolute path of the current
 # executable (this is the case on Windows).
 #
+# INSTALL_STRIP can be set to "-s" to strip binaries during installation,
+# if your $(INSTALL) command supports the option.
+#
 # Define GENERATE_COMPILATION_DATABASE to "yes" to generate JSON compilation
 # database entries during compilation if your compiler supports it, using the
 # `-MJ` flag. The JSON entries will be placed in the `compile_commands/`
@@ -3004,7 +3007,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 +3017,17 @@ profile-install: profile
 profile-fast-install: profile-fast
 	$(MAKE) install
 
+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_STRIP) $(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_STRIP) $(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.

base-commit: 6c40894d2466d4e7fddc047a05116aa9d14712ee
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH v3] make: add INSTALL_STRIP option variable
  2021-09-02 12:11 [PATCH v3] make: add INSTALL_STRIP option variable Bagas Sanjaya
@ 2021-09-16  9:50 ` Ævar Arnfjörð Bjarmason
  2021-09-16 10:36   ` Bagas Sanjaya
  2021-09-16 19:23   ` Junio C Hamano
  0 siblings, 2 replies; 5+ messages in thread
From: Ævar Arnfjörð Bjarmason @ 2021-09-16  9:50 UTC (permalink / raw)
  To: Bagas Sanjaya
  Cc: git, Junio C Hamano, Carlo Arenas,
	Đoàn Trần Công Danh, felipe.contreras,
	Eric Sunshine, Johannes Schindelin, Jeff Hostetler


On Thu, Sep 02 2021, Bagas Sanjaya wrote:

> From: Junio C Hamano <gitster@pobox.com>
>
> Add $(INSTALL_STRIP), which allows passing stripping options to
> $(INSTALL).
>
> For this to work, installing executables must be split to installing
> compiled binaries and scripts portions, since $(INSTALL_STRIP) is only
> meaningful to the former.
>
> Users can set this variable depending on their system. For example,
> Linux users can use `-s --strip-program=strip`, while FreeBSD users can
> simply set to `-s` and choose strip program with $STRIPBIN.
>
> Signed-off-by: Bagas Sanjaya <bagasdotme@gmail.com>
> ---
>
>  Changes from v3 [1]:
>    - Squash suggestion patch from Junio, which suggests dropping
>      install-stripped target and rename $(INSTALL_OPTS) to
>      $(INSTALL_STRIP).
>    - Describe $(INSTALL_STRIP) usage on the top of Makefile
>
>  Note: In the future, we may add global $(INSTALL_OPTS), which applies
>  to both compiled binaries and scripts. When such happens, we should
>  rename $(INSTALL_STRIP) to $(INSTALL_STRIP_OPTS).

I see this landed on "master" already, but in case you're interested on
follow-ing up:

I think the suggestion in
https://lore.kernel.org/git/xmqqo89cqkt9.fsf@gitster.g/ is to make this
a boolean variable, and in any case I think that makes more sense here,
since....

>  [1]: https://lore.kernel.org/git/xmqqo89cqkt9.fsf@gitster.g/T/#t
>
>  Makefile | 15 ++++++++++++---
>  1 file changed, 12 insertions(+), 3 deletions(-)
>
> diff --git a/Makefile b/Makefile
> index d1feab008f..ebef4da50c 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -465,6 +465,9 @@ all::
>  # the global variable _wpgmptr containing the absolute path of the current
>  # executable (this is the case on Windows).
>  #
> +# INSTALL_STRIP can be set to "-s" to strip binaries during installation,
> +# if your $(INSTALL) command supports the option.
> +#
>  # Define GENERATE_COMPILATION_DATABASE to "yes" to generate JSON compilation
>  # database entries during compilation if your compiler supports it, using the
>  # `-MJ` flag. The JSON entries will be placed in the `compile_commands/`
> @@ -3004,7 +3007,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 +3017,17 @@ profile-install: profile
>  profile-fast-install: profile-fast
>  	$(MAKE) install
>  
> +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_STRIP) $(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_STRIP) $(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.
>
> base-commit: 6c40894d2466d4e7fddc047a05116aa9d14712ee

...this really is not an INSTALL_STRIP but (using some combination of
your own naming) a "INSTALL_XPROGRAMS_OPTS" or "INSTALL_XOPTS". I.e. you
can supply arbitrary options to "install" with this, but only for
binaries.

Also doesn't this misbehave under MSVC when combined with *.pdb files?
See dce7d295514 (msvc: support building Git using MS Visual C++,
2019-06-25) and a8b5355d808 (msvc: copy the correct `.pdb` files in the
Makefile target `install`, 2020-09-21) , i.e. the code at the start of
your diff context.

Does stripping the main binary while having a *.pdb file error or MSCV,
or make the *.pdb file useless, or is *.pdb an unconditional equivalent
of INSTALL_STRIP=-s on MSCV that we should disable if this
hopefully-then-boolean INSTALL_STRIP option is enabled?

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v3] make: add INSTALL_STRIP option variable
  2021-09-16  9:50 ` Ævar Arnfjörð Bjarmason
@ 2021-09-16 10:36   ` Bagas Sanjaya
  2021-09-18  7:46     ` Ævar Arnfjörð Bjarmason
  2021-09-16 19:23   ` Junio C Hamano
  1 sibling, 1 reply; 5+ messages in thread
From: Bagas Sanjaya @ 2021-09-16 10:36 UTC (permalink / raw)
  To: Ævar Arnfjörð Bjarmason
  Cc: git, Junio C Hamano, Carlo Arenas,
	Đoàn Trần Công Danh, felipe.contreras,
	Eric Sunshine, Johannes Schindelin, Jeff Hostetler

On 16/09/21 16.50, Ævar Arnfjörð Bjarmason wrote:
> ...this really is not an INSTALL_STRIP but (using some combination of
> your own naming) a "INSTALL_XPROGRAMS_OPTS" or "INSTALL_XOPTS". I.e. you
> can supply arbitrary options to "install" with this, but only for
> binaries.
> 

I think it should have been "INSTALL_STRIP_OPTS". This could haven't 
been issue if we add global (applicable tobinaries and scripts) 
"INSTALL_OPTS".

> Also doesn't this misbehave under MSVC when combined with *.pdb files?
> See dce7d295514 (msvc: support building Git using MS Visual C++,
> 2019-06-25) and a8b5355d808 (msvc: copy the correct `.pdb` files in the
> Makefile target `install`, 2020-09-21) , i.e. the code at the start of
> your diff context.
> 
> Does stripping the main binary while having a *.pdb file error or MSCV,
> or make the *.pdb file useless, or is *.pdb an unconditional equivalent
> of INSTALL_STRIP=-s on MSCV that we should disable if this
> hopefully-then-boolean INSTALL_STRIP option is enabled?
> 

I'm not familiar with MSVC, so I can't tell further except you can pass 
null ("") to INSTALL_STRIP.

-- 
An old man doll... just what I always wanted! - Clara

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v3] make: add INSTALL_STRIP option variable
  2021-09-16  9:50 ` Ævar Arnfjörð Bjarmason
  2021-09-16 10:36   ` Bagas Sanjaya
@ 2021-09-16 19:23   ` Junio C Hamano
  1 sibling, 0 replies; 5+ messages in thread
From: Junio C Hamano @ 2021-09-16 19:23 UTC (permalink / raw)
  To: Ævar Arnfjörð Bjarmason
  Cc: Bagas Sanjaya, git, Carlo Arenas,
	Đoàn Trần Công Danh, felipe.contreras,
	Eric Sunshine, Johannes Schindelin, Jeff Hostetler

Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:

> I think the suggestion in
> https://lore.kernel.org/git/xmqqo89cqkt9.fsf@gitster.g/ is to make this
> a boolean variable, and in any case I think that makes more sense here,

I do not think I ever suggested to use a boolean in that message nor
in the other message in thread.  A boolean may convey the wish of
the users to cause the binaries installed in a stripped form, but
does not allow them to express how to do so on their particular
platform (e.g. where is "strip" installed? how to tell "install"
to strip?).

> since....
> ...
> ...this really is not an INSTALL_STRIP but (using some combination of
> your own naming) a "INSTALL_XPROGRAMS_OPTS" or "INSTALL_XOPTS". I.e. you
> can supply arbitrary options to "install" with this, but only for
> binaries.

INSTALL_STRIP_OPTS is a perfectly fine name for this thing.  

It should not say XPROGRAMS but should say STRIP to express the
intent, i.e. why we have it, not what we do with it.  The fact that
it wants to apply to binaries and not to scripts is an
implementation detail.

Of course, when you want to "affect" only binaries but not scripts,
even if the effect you are trying to cause on them is _not_ "strip",
you could abuse the option, but the name must make it clear that
such a use is an abuse.  By naming the variable with STRIP in its
name, we reserve the right to change to which instance of $(INSTALL)
the option is applied to to better implement the goal to "strip
while installing", which might not be a simple "binaries get it,
scripts don't" we currently have, and it will be clear to those who
have been abusing the option to affect "only binaries and not
scripts" that they have no right to complain.

HTH.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v3] make: add INSTALL_STRIP option variable
  2021-09-16 10:36   ` Bagas Sanjaya
@ 2021-09-18  7:46     ` Ævar Arnfjörð Bjarmason
  0 siblings, 0 replies; 5+ messages in thread
From: Ævar Arnfjörð Bjarmason @ 2021-09-18  7:46 UTC (permalink / raw)
  To: Bagas Sanjaya
  Cc: git, Junio C Hamano, Carlo Arenas,
	Đoàn Trần Công Danh, felipe.contreras,
	Eric Sunshine, Johannes Schindelin, Jeff Hostetler


On Thu, Sep 16 2021, Bagas Sanjaya wrote:

> On 16/09/21 16.50, Ævar Arnfjörð Bjarmason wrote:
>> ...this really is not an INSTALL_STRIP but (using some combination of
>> your own naming) a "INSTALL_XPROGRAMS_OPTS" or "INSTALL_XOPTS". I.e. you
>> can supply arbitrary options to "install" with this, but only for
>> binaries.
>> 
>
> I think it should have been "INSTALL_STRIP_OPTS". This could haven't
> been issue if we add global (applicable tobinaries and scripts) 
> "INSTALL_OPTS".

Isn't the reason to have that split-up because it would break if you try
to strip(1) a Perl or shellscript?

>> Also doesn't this misbehave under MSVC when combined with *.pdb files?
>> See dce7d295514 (msvc: support building Git using MS Visual C++,
>> 2019-06-25) and a8b5355d808 (msvc: copy the correct `.pdb` files in the
>> Makefile target `install`, 2020-09-21) , i.e. the code at the start of
>> your diff context.
>> Does stripping the main binary while having a *.pdb file error or
>> MSCV,
>> or make the *.pdb file useless, or is *.pdb an unconditional equivalent
>> of INSTALL_STRIP=-s on MSCV that we should disable if this
>> hopefully-then-boolean INSTALL_STRIP option is enabled?
>> 
>
> I'm not familiar with MSVC, so I can't tell further except you can
> pass null ("") to INSTALL_STRIP.

Yes, to be clear I'm not asking for practical assistance in building git
with MSVC.

I'm pointing out that it seems that the option you added introduces an
edge case in how we combine with an existing option/ifdef that may not
be desirable, and that you might be interested in looking at
it/submitting a follow-up patch if it does turn out that the interaction
is undesirable.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-09-18  7:49 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-02 12:11 [PATCH v3] make: add INSTALL_STRIP option variable Bagas Sanjaya
2021-09-16  9:50 ` Ævar Arnfjörð Bjarmason
2021-09-16 10:36   ` Bagas Sanjaya
2021-09-18  7:46     ` Ævar Arnfjörð Bjarmason
2021-09-16 19:23   ` Junio C Hamano

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).