develooper Front page | perl.perl5.porters | Postings from April 2003

LD_PRELOAD hack, still badly flawed / a solution

Thread Next
From:
Enache Adrian
Date:
April 3, 2003 05:01
Subject:
LD_PRELOAD hack, still badly flawed / a solution
Message ID:
20030403125048.GA6107@ratsnest.hole
The LD_PRELOAD trick isn't right at all: If the 'make' process stops
before the link phase and the libperl.so isn't yet there, you simply
cannot do a 'make clean' or 'make distclean' to start from scratch.

I whipped it with a dynamically generated wrapper script that preloads
the perl library only if that really exists: I don't insist on this
particular solution - but this should be fixed somehow.

Regards
Adi

----------------------------------------------------------------------
--- /arc/bleadperl/Makefile.SH	2003-04-02 00:12:01.000000000 +0300
+++ Makefile.SH	2003-04-03 04:26:41.000000000 +0300
@@ -96,26 +96,32 @@
 	    ldlibpth=`echo $ldlibpth | sed 's/:*$//'`
 	    ;;
         esac
-	;;
-*)	pldlflags=''
-	static_target='static'
-	;;
-esac
 
-case "$ldlibpth" in
-# Protect any spaces
-*" "*) ldlibpth=`echo $ldlibpth|sed 's/ /\\\\ /g'` ;;
-esac
+	case "$ldlibpth" in
+	# Protect any spaces
+	*" "*) ldlibpth=`echo $ldlibpth|sed 's/ /\\\\ /g'` ;;
+	esac
 
-case "$osname" in
-linux)
-	case "$useshrplib" in
-	true)
-	    ldlibpth="LD_PRELOAD=\"\$\$LD_PRELOAD `pwd`/$libperl\" $ldlibpth"
-	    ;;
+	case "$osname" in
+	linux)
+		cat <<-'EOT' >| preload
+		#! /bin/sh
+		lib=$1
+		shift
+		test -r $lib && export LD_PRELOAD="$lib $LD_PRELOAD"
+		exec "$@"
+		EOT
+		chmod 755 preload
+		ldlibpth="$ldlibpth `pwd`/preload `pwd`/$libperl"
+		;;
+	os390)	test -f /bin/env && ldlibpth="/bin/env $ldlibpth"
+		;;
 	esac
+
 	;;
-os390)	test -f /bin/env && ldlibpth="/bin/env $ldlibpth"
+
+*)	pldlflags=''
+	static_target='static'
 	;;
 esac
 
@@ -944,6 +950,7 @@
 	rm -f lib/.exists lib/*/.exists lib/*/*/.exists
 	rm -f h2ph.man pstruct
 	rm -rf .config
+	rm -f preload
 	rm -f testcompile compilelog
 	-rmdir lib/B lib/Data lib/Digest
 	rm -rf lib/Encode

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About