[v3] Use builtin sort instead of shell sort

Message ID 20190420062724.20054-1-emeric.dupont@zii.aero
State Superseded
Headers show
Series
  • [v3] Use builtin sort instead of shell sort
Related show

Commit Message

Émeric Dupont April 20, 2019, 6:28 a.m.
Some build environments and configuration options may lead to the make
variable PLUGIN_HEADERS being too long to be passed as parameters to the
shell `echo` command, leading to a "write error" message when making the
target install-plugin.

The following patch fixes this issue by using the [Make $(sort list)][1]
function instead to remove duplicates from the list of headers. There is
no functional change, the value assigned to the shell variable is the
same.

Tested in production on x86 and armv7 cross-compilation toolchains.
    - The length of the headers variable goes from 80000+ chars to 7500+

Tested with make bootstrap and make check on host-x86_64-pc-linux-gnu
    - make bootstrap successful
    - make check fails even before the patch is applied

        WARNING: program timed out.
        FAIL: libgomp.c/../libgomp.c-c++-common/cancel-parallel-1.c execution test
        ...
        make[4]: *** [Makefile:479: check-DEJAGNU] Error 1

2019-04-15  Emeric Dupont  <emeric.dupont@zii.aero>

        * Makefile.in: Use builtin sort instead of shell sort

Signed-off-by: Emeric Dupont <emeric.dupont@zii.aero>


[1]: https://www.gnu.org/software/make/manual/html_node/Text-Functions.html#index-sorting-words
---
 gcc/Makefile.in | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--
2.21.0


________________________________

TriaGnoSys GmbH, Registergericht: München HRB 141647, Vat.: DE 813396184 Geschäftsführer: Núria Riera Díaz, Peter Lewalter

________________________________

This email and any files transmitted with it are confidential & proprietary to Zodiac Inflight Innovations. This information is intended solely for the use of the individual or entity to which it is addressed. Access or transmittal of the information contained in this e-mail, in full or in part, to any other organization or persons is not authorized.

Comments

Andreas Schwab April 20, 2019, 7:23 a.m. | #1
On Apr 20 2019, Émeric Dupont <emeric.dupont@zii.aero> wrote:

> The following patch fixes this issue by using the [Make $(sort list)][1]

> function instead to remove duplicates from the list of headers. There is

> no functional change, the value assigned to the shell variable is the

> same.


Is it?

> diff --git a/gcc/Makefile.in b/gcc/Makefile.in

> index d186d71c91e..3196e774a26 100644

> --- a/gcc/Makefile.in

> +++ b/gcc/Makefile.in

> @@ -3538,7 +3538,7 @@ install-plugin: installdirs lang.install-plugin s-header-vars install-gengtype

>  # We keep the directory structure for files in config or c-family and .def

>  # files. All other files are flattened to a single directory.

>  $(mkinstalldirs) $(DESTDIR)$(plugin_includedir)

> -headers=`echo $(PLUGIN_HEADERS) $$(cd $(srcdir); echo *.h *.def) | tr ' ' '\012' | sort -u`; \

> +headers=$(sort $(PLUGIN_HEADERS) $$(cd $(srcdir); echo *.h *.def)); \


This sorts the words $(PLUGIN_HEADERS) '$(cd' $(srcdir); echo '*.h'
'*.def)' and produces a command line that doesn't make sense.

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."
Émeric Dupont May 27, 2019, 8:15 a.m. | #2
The 20.04.2019 09:23, Andreas Schwab wrote:
>On Apr 20 2019, Émeric Dupont <emeric.dupont@zii.aero> wrote:

>> diff --git a/gcc/Makefile.in b/gcc/Makefile.in

>> index d186d71c91e..3196e774a26 100644

>> --- a/gcc/Makefile.in

>> +++ b/gcc/Makefile.in

>> @@ -3538,7 +3538,7 @@ install-plugin: installdirs lang.install-plugin s-header-vars install-gengtype

>>  # We keep the directory structure for files in config or c-family and .def

>>  # files. All other files are flattened to a single directory.

>>  $(mkinstalldirs) $(DESTDIR)$(plugin_includedir)

>> -headers=`echo $(PLUGIN_HEADERS) $$(cd $(srcdir); echo *.h *.def) | tr ' ' '\012' | sort -u`; \

>> +headers=$(sort $(PLUGIN_HEADERS) $$(cd $(srcdir); echo *.h *.def)); \

>

>This sorts the words $(PLUGIN_HEADERS) '$(cd' $(srcdir); echo '*.h'

>'*.def)' and produces a command line that doesn't make sense.

>

Thanks for pointing this out! I will provide an updated patch as soon as
I made sure the unwanted mail footer disappears (Sorry it took so long,
it had to go through the legal department first.)



--
Emeric Dupont
Zodiac Inflight Innovations
P +49815388678207
Argelsrieder Feld, 22 - 82234 Wessling
www.safran-aerosystems.com

________________________________

TriaGnoSys GmbH, Registergericht: München HRB 141647, Vat.: DE 813396184 Geschäftsführer: Núria Riera Díaz, Peter Lewalter

Patch

diff --git a/gcc/Makefile.in b/gcc/Makefile.in
index d186d71c91e..3196e774a26 100644
--- a/gcc/Makefile.in
+++ b/gcc/Makefile.in
@@ -3538,7 +3538,7 @@  install-plugin: installdirs lang.install-plugin s-header-vars install-gengtype
 # We keep the directory structure for files in config or c-family and .def
 # files. All other files are flattened to a single directory.
 $(mkinstalldirs) $(DESTDIR)$(plugin_includedir)
-headers=`echo $(PLUGIN_HEADERS) $$(cd $(srcdir); echo *.h *.def) | tr ' ' '\012' | sort -u`; \
+headers=$(sort $(PLUGIN_HEADERS) $$(cd $(srcdir); echo *.h *.def)); \
 srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`; \
 for file in $$headers; do \
   if [ -f $$file ] ; then \