1
0
mirror of https://sourceware.org/git/glibc.git synced 2025-08-08 17:42:12 +03:00

malloc: Always install mtrace (bug 31892)

Generation of the Perl script does not depend on Perl, so we can
always install it even if $(PERL) is not set during the build.

Change the malloc/mtrace.pl text substition not to rely on $(PERL).
Instead use PATH at run time to find the Perl interpreter. The Perl
interpreter cannot execute directly a script that starts with
“#! /bin/sh”: it always executes it with /bin/sh.  There is no
perl command line switch to disable this behavior.  Instead, use
the Perl require function to execute the script.  The additional
shift calls remove the “.” shell arguments.  Perl interprets the
“.” as a string concatenation operator, making the expression
syntactically valid.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
This commit is contained in:
Florian Weimer
2024-06-20 10:32:16 +02:00
parent da905bb706
commit 086910fc41
2 changed files with 4 additions and 7 deletions

View File

@@ -250,7 +250,6 @@ others-extras = mcheck-init.o
aux := set-freeres thread-freeres aux := set-freeres thread-freeres
# The Perl script to analyze the output of the mtrace functions. # The Perl script to analyze the output of the mtrace functions.
ifneq ($(PERL),no)
install-bin-script = mtrace install-bin-script = mtrace
generated += mtrace generated += mtrace
@@ -261,7 +260,6 @@ address-width=10
else else
address-width=18 address-width=18
endif endif
endif
# Unless we get a test for the availability of libgd which also works # Unless we get a test for the availability of libgd which also works
# for cross-compiling we disable the memusagestat generation in this # for cross-compiling we disable the memusagestat generation in this
@@ -349,7 +347,7 @@ sLIBdir := $(shell echo $(slibdir) | sed 's,lib\(\|64\)$$,\\\\$$LIB,')
$(objpfx)mtrace: mtrace.pl $(objpfx)mtrace: mtrace.pl
rm -f $@.new rm -f $@.new
sed -e 's|@PERL@|$(PERL)|' -e 's|@XXX@|$(address-width)|' \ sed -e 's|@XXX@|$(address-width)|' \
-e 's|@VERSION@|$(version)|' \ -e 's|@VERSION@|$(version)|' \
-e 's|@PKGVERSION@|$(PKGVERSION)|' \ -e 's|@PKGVERSION@|$(PKGVERSION)|' \
-e 's|@REPORT_BUGS_TO@|$(REPORT_BUGS_TO)|' $^ > $@.new \ -e 's|@REPORT_BUGS_TO@|$(REPORT_BUGS_TO)|' $^ > $@.new \

View File

@@ -1,6 +1,6 @@
#! @PERL@ #! /bin/sh
eval "exec @PERL@ -S $0 $@" eval exec "perl -e 'shift; \$progname=shift; shift; require \$progname'" . "$0" . "$@"
if 0; if 0;
# Copyright (C) 1997-2024 Free Software Foundation, Inc. # Copyright (C) 1997-2024 Free Software Foundation, Inc.
# This file is part of the GNU C Library. # This file is part of the GNU C Library.
# Based on the mtrace.awk script. # Based on the mtrace.awk script.
@@ -22,7 +22,6 @@ eval "exec @PERL@ -S $0 $@"
$VERSION = "@VERSION@"; $VERSION = "@VERSION@";
$PKGVERSION = "@PKGVERSION@"; $PKGVERSION = "@PKGVERSION@";
$REPORT_BUGS_TO = '@REPORT_BUGS_TO@'; $REPORT_BUGS_TO = '@REPORT_BUGS_TO@';
$progname = $0;
sub usage { sub usage {
print "Usage: mtrace [OPTION]... [Binary] MtraceData\n"; print "Usage: mtrace [OPTION]... [Binary] MtraceData\n";