From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 9FABF3882123 for ; Fri, 14 Jun 2024 16:05:47 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 9FABF3882123 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 9FABF3882123 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1718381149; cv=none; b=kqFqbvphCFSE2Wrd96Ypo0/JmUx3NwoyA5sUhmblnpOrZ7VrRp2S+Px+5+mt7wTCPgfK6qF0I/Wy4ane9YIgyXesJV7j3XqQfxKLTSSYc9F++gjyqCV1LBtml0mIRJw67Dwv8rDuuHJns6CS4AClWaAnIuUJ8wwV6y5wq4G4Vbc= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1718381149; c=relaxed/simple; bh=yt4XGnX5wpT1TZhEUA6/4Z4dwN9EI3rKLBEFpjwuW3k=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=pd+XIne5KGKQG2GjScobZMOEttKvNmgt8gDN9jAvKTz5t8ki/yumV/HSu1QAP0fcsmHtAD1BiGS9V0nXnlRDzQRZv9s6NMndN/dvM87X/c5P+rH+ieQTkgD1q7Jrus+HAIEE0DBVwY4Gont5SMSf38BTLejnHo4gNLgCx5JASHk= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1718381147; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=6V5yQl7dyL9i9jY4lUNXsOl628Z1YkMIQQLj2eIKbZg=; b=cCFNHBJt+MrtYiW7iFlUFguHoV9B1Q3jK8RcvS2FfbU2dv0ssuML4Zv4hF4VVVkPX5YYBH TUxEILVMd172Lm/lwwfRFOLTl2uDEHaZIZQs2E0uZbDcpwCiNoThcY3EZB2VTB5qfv0jCN neqmPD8HpLy7SlMp5BdcL6NGS408K88= Received: from mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-178-A-tN8Ga4NiybwFu4UER_YA-1; Fri, 14 Jun 2024 12:05:45 -0400 X-MC-Unique: A-tN8Ga4NiybwFu4UER_YA-1 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 07F5F1955D81 for ; Fri, 14 Jun 2024 16:05:41 +0000 (UTC) Received: from oldenburg.str.redhat.com (unknown [10.39.192.96]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id C3E75300021A for ; Fri, 14 Jun 2024 16:05:39 +0000 (UTC) From: Florian Weimer To: libc-alpha@sourceware.org Subject: [PATCH v2] malloc: Always install mtrace (bug 31892) Date: Fri, 14 Jun 2024 18:05:36 +0200 Message-ID: <87plsjqzlb.fsf@oldenburg.str.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-9.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_NONE,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: 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 =E2=80=9C#! /bin/sh=E2=80=9D: 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 =E2=80=9C.=E2=80=9D shell arguments. Perl interpret= s the =E2=80=9C.=E2=80=9D as a string concatenation operator, making the expressi= on syntactically valid. Tested on x86_64-linux-gnu with Perl installed. --- malloc/Makefile | 2 +- malloc/mtrace.pl | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/malloc/Makefile b/malloc/Makefile index c7d6678a40..02aff1bd1d 100644 --- a/malloc/Makefile +++ b/malloc/Makefile @@ -347,7 +347,7 @@ sLIBdir :=3D $(shell echo $(slibdir) | sed 's,lib\(\|64= \)$$,\\\\$$LIB,') =20 $(objpfx)mtrace: mtrace.pl =09rm -f $@.new -=09sed -e 's|@PERL@|$(PERL)|' -e 's|@XXX@|$(address-width)|' \ +=09sed -e 's|@XXX@|$(address-width)|' \ =09 -e 's|@VERSION@|$(version)|' \ =09 -e 's|@PKGVERSION@|$(PKGVERSION)|' \ =09 -e 's|@REPORT_BUGS_TO@|$(REPORT_BUGS_TO)|' $^ > $@.new \ diff --git a/malloc/mtrace.pl b/malloc/mtrace.pl index 075da0d9f1..dc6085820e 100644 --- a/malloc/mtrace.pl +++ b/malloc/mtrace.pl @@ -1,6 +1,6 @@ -#! @PERL@ -eval "exec @PERL@ -S $0 $@" - if 0; +#! /bin/sh +eval exec "perl -e 'shift; \$progname=3Dshift; shift; require \$progname'"= . "$0" . "$@" + if 0; # Copyright (C) 1997-2024 Free Software Foundation, Inc. # This file is part of the GNU C Library. # Based on the mtrace.awk script. @@ -22,7 +22,6 @@ eval "exec @PERL@ -S $0 $@" $VERSION =3D "@VERSION@"; $PKGVERSION =3D "@PKGVERSION@"; $REPORT_BUGS_TO =3D '@REPORT_BUGS_TO@'; -$progname =3D $0; =20 sub usage { print "Usage: mtrace [OPTION]... [Binary] MtraceData\n"; base-commit: 8919429b7553aaee0df74947fee7e0649923674b