The malloc/Makefile conflates PERL=no with running perl code *and* installing mtrace. We should always install mtrace, but we might not always be able to run the script (lack of perl on the host). 252 # The Perl script to analyze the output of the mtrace functions. 253 ifneq ($(PERL),no) 254 install-bin-script = mtrace 255 generated += mtrace 256 257 # The Perl script will print addresses and to do this nicely we must know 258 # whether we are on a 32 or 64 bit machine. 259 ifneq ($(findstring wordsize-32,$(config-sysdirs)),) 260 address-width=10 261 else 262 address-width=18 263 endif 264 endif My position is that we should just always install mtrace. The existing mtrace tests are predicated on PERL being detected, so it should work.
It also conflates the $(PERL) path determined on the system building glibc with the @PERL@ substituted in the mtrace.pl script that's a path on the system running glibc; the paths need not be the same even if perl is found (but obviously a script starting "#! no" would be bad).
The following tests are incorrectly conditionalized: FAIL: misc/tst-allocate_once-mem FAIL: misc/tst-error1-mem FAIL: nptl/tst-stack3-mem FAIL: posix/bug-ga2-mem FAIL: posix/bug-glob2-mem FAIL: posix/bug-regex14-mem FAIL: posix/bug-regex2-mem FAIL: posix/bug-regex21-mem FAIL: posix/bug-regex31-mem FAIL: posix/bug-regex36-mem FAIL: posix/tst-boost-mem FAIL: posix/tst-fnmatch-mem FAIL: posix/tst-glob-tilde-mem FAIL: posix/tst-pcre-mem FAIL: posix/tst-rxspencer-no-utf8-mem FAIL: posix/tst-vfork3-mem FAIL: stdio-common/tst-printf-bz18872-mem FAIL: stdio-common/tst-printf-bz25691-mem FAIL: stdio-common/tst-printf-fp-free-mem FAIL: stdio-common/tst-printf-fp-leak-mem FAIL: stdio-common/tst-vfprintf-width-prec-mem
Patch posted: [PATCH] malloc: Always install mtrace (bug 31892) <https://inbox.sourceware.org/libc-alpha/87bk43u99n.fsf@oldenburg.str.redhat.com/>
More incorrectly conditionalized tests: FAIL: check-local-headers FAIL: catgets/tst-catgets-mem FAIL: elf/noload-mem FAIL: elf/tst-leaks1-mem FAIL: libio/test-fmemopen-mem FAIL: libio/tst-bz22415-mem FAIL: libio/tst-bz24228-mem FAIL: libio/tst-fdopen-seek-failure-mem FAIL: libio/tst-fopenloc-mem
(In reply to Florian Weimer from comment #3) > Patch posted: > > [PATCH] malloc: Always install mtrace (bug 31892) > <https://inbox.sourceware.org/libc-alpha/87bk43u99n.fsf@oldenburg.str.redhat. > com/> Florian and I disucssed that this patch needs to take into account what happens when perl is not installed. So we need a v2 to account for more details e.g. fallback default if perl isn't installed (like in the minimized buildroots on Fedora builders if you disable certain parts of the glibc build). I think there is a valid use case where you haven't yet bootstrapped perl and are building glibc and want this to succeed with some sensible default.
(In reply to Carlos O'Donell from comment #5) > (In reply to Florian Weimer from comment #3) > > Patch posted: > > > > [PATCH] malloc: Always install mtrace (bug 31892) > > <https://inbox.sourceware.org/libc-alpha/87bk43u99n.fsf@oldenburg.str.redhat. > > com/> > > Florian and I disucssed that this patch needs to take into account what > happens when perl is not installed. So we need a v2 to account for more > details e.g. fallback default if perl isn't installed (like in the minimized > buildroots on Fedora builders if you disable certain parts of the glibc > build). I just posted a v2: [PATCH v2] malloc: Always install mtrace (bug 31892) <https://inbox.sourceware.org/libc-alpha/87plsjqzlb.fsf@oldenburg.str.redhat.com/> It took me a while to figure out a way to get Perl to run a Perl script with a #!/bin/sh line.
Fixed for 2.40 via: commit 086910fc41655152812b515dc324d2ac0dc36e67 Author: Florian Weimer <fweimer@redhat.com> Date: Thu Jun 20 10:32:16 2024 +0200 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>
The script now has insufficient quoting.
The quoting issue was fixed via: commit dd144dce21c864781fade4561581d50fb4549956 Author: Florian Weimer <fweimer@redhat.com> Date: Thu Jun 20 20:55:10 2024 +0200 malloc: Replace shell/Perl gate in mtrace The previous version expanded $0 and $@ twice. The new version defines a q no-op shell command. The Perl syntax error is masked by the eval Perl function. The q { … } construct is executed by the shell without errors because the q shell function was defined, but treated as a non-expanding quoted string by Perl, effectively hiding its context from the Perl interpreter. As before the script is read by require instead of executed directly, to avoid infinite recursion because the #! line contains /bin/sh. Introduce the “fatal” function to produce diagnostics that are not suppressed by “do”. Use “do” instead of “require” because it has fewer requirements on the executed script than “require”. Prefix relative paths with './' because “do” (and “require“ before) searches for the script in @INC if the path is relative and does not start with './'. Use $_ to make the trampoline shorter. Add an Emacs mode marker to indentify the script as a Perl script.