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

Using $(LDLIBPTH) when linking miniperl (was Re: [PATCH for5.004_64] Configure patch Config_64-02-03.diff)

Thread Next
From:
Nicholas Clark
Date:
April 28, 2012 15:06
Subject:
Using $(LDLIBPTH) when linking miniperl (was Re: [PATCH for5.004_64] Configure patch Config_64-02-03.diff)
Message ID:
20120428220645.GA28066@plum.flirble.org
On Thu, Apr 23, 1998 at 03:03:20PM -0400, Andy Dougherty wrote:
> Patch Config_64-02-03.diff turned out to be too big for mail, so I've
> posted it at
> 
> http://www.lafayette.edu/~doughera/doughera/perl/patches/Config_64-02-03.diff.gz

where unfortunately it no longer is:

http://workbench.lafayette.edu/~doughera/doughera/perl/patches/

> along with all my other patches for _64.  I'll also put it up on
> PAUSE.

but fortunately this survives on backpan. :-)

> This patch is mostly a documentation patch.  The main functional part
> is an enhancement to Makefile.SH so that you no longer have to
> manually set LD_LIBRARY_PATH=`pwd`:$LD_LIBRARY_PATH.  (You do if you
> want to actually run the ./perl executable manually, but that's a
> slightly separate problem).

I think that it goes slightly too far:

@@ -299,20 +313,20 @@
 # The Module used here must not depend on Config or any extensions.
 
 miniperl: $& miniperlmain$(OBJ_EXT) $(LIBPERL)
-       $(CC) $(LARGE) $(CLDFLAGS) -o miniperl miniperlmain$(OBJ_EXT) $(LLIBPERL) $(libs)
-       @./miniperl -w -Ilib -MExporter -e 0 || $(MAKE) minitest
+       $(LDLIBPTH) $(CC) $(LARGE) $(CLDFLAGS) -o miniperl miniperlmain$(OBJ_EXT) $(LLIBPERL) $(libs)
+       @ $(LDLIBPTH) ./miniperl -w -Ilib -MExporter -e 0 || $(MAKE) minitest


in that I don't think that the $(LDLIBPTH) is needed on the $(CC) line.
As I understand it, LDLIBPTH is something like:

$ grep ^LDLIBPTH Makefile
LDLIBPTH = LD_LIBRARY_PATH=/perl/usr/nick/Perl/perl

or

$ grep ^LDLIBPTH Makefile
LDLIBPTH = DYLD_LIBRARY_PATH=/Volumes/Stuff/Perl/perl


and it's only needed to enable ./perl to find the uninstalled libperl.so.
As it's not to do with linking, it's not needed for the C compiler command.

I've tried removing it with this (smoke-me/no-LDLIBPTH-for-CC) and it's
not thrown up anything crazy*:

commit e2658a697bfb1264a1861479c37cafa53961a558
Author: Nicholas Clark <nick@ccl4.org>
Date:   Fri Apr 27 17:56:34 2012 +0200

    No need to prefix the $(CC) invocation that links miniperl with $(LDLIBPTH).
    
    $(LDLIBPTH) is used to prefix the appropriate LD_LIBRARY_PATH=... before
    commands in the Makefile when perl is build with a shared perl library so
    that the uninstalled ./perl will be able to find it.
    
    Commit c4f23d77f4b3486a (in May 1998) added the code for LDLIBPTH, but
    also added it to the default command line used to invoke $(CC) to link
    miniperl. This command doesn't need to run ./perl, hence the use of
    $(LDLIBPTH) is superfluous here. Removing it makes the code simpler.

diff --git a/Makefile.SH b/Makefile.SH
index ba5ab79..208702a 100755
--- a/Makefile.SH
+++ b/Makefile.SH
@@ -869,7 +869,7 @@ $(MINIPERL_EXE): $& $(mini_obj)
 		$spitshell >>$Makefile <<'!NO!SUBS!'
 $(MINIPERL_EXE): $& $(mini_obj)
 	-@rm -f miniperl.xok
-	$(LDLIBPTH) $(CC) $(CLDFLAGS) -o $(MINIPERL_EXE) \
+	$(CC) $(CLDFLAGS) -o $(MINIPERL_EXE) \
 	    $(mini_obj) $(libs)
 	$(LDLIBPTH) $(RUN) ./miniperl$(HOST_EXE_EXT) -w -Ilib -MExporter -e '<?>' || $(MAKE) minitest
 !NO!SUBS!


Is this sane? It's in a case statement in Makefile.SH as the default for
"none of the above operating systems". Changing this looks like it unlocks
possibilities for considerable simplification in that bit of Makefile.SH, as
all the other explicitly named OSes don't set $(LDLIBPTH) there.
(And other than AIX and darwin, aren't easily testable.)


I'm actually thinking that possibly all the $(LDLIBPTH) lines on the
invocation for $(CC) should also come out. But they aren't getting in the
way of simplification at the moment.

Nicholas Clark

* As in, builds OK on Linux, FreeBSD, Solaris and HP-UX with -Duseshrplib.
  All the smoke-me smokers are happy, but I don't think that any try
  -Duseshrplib

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