ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> pdk
pdk
shared objects for modules with two-component names in PDK 7.1
by Ingo Schwarze other posts by this author
Feb 5 2008 9:56AM messages near this date
Re: Incrementing a build number in PerlApp | RE: shared objects for modules with two-component names in PDK 7.1
Hi,

about half a year ago, i sent the message included below to this
list, but according to the archive at aspn.activestate.com, there
was never any reply.

I'm still wondering
 * whether PDK 6.0 is indeed unable to compile Perl modules
   with multiple-component names into PDK shared objects
   (or whether i'm just doing something stupid)
 * in case this was a known limitation, whether it is fixed in 7.1
 * in case this is fixed in 7.1, whether it will work together
   with using the shared version of libperl.

This information would be helpful in order to evaluate whether
an upgrade from PDK 6.0 to PDK 7.1 might make sense for us
at astaro.com.  Getting both shared libperl and the chance
to share our own modules mike considerably boost the
performance of some of our software; having only shared
libperl but being forced to statically link all our own
code is probably not worth the hassle, while downgrading
to one-component module names is not an option, either.

Thanks in advance for your help,
  Ingo

-- 
Ingo Schwarze <ischwarze@[...].com>  | Software Engineer | Framework Team
Astaro AG | www.astaro.com | 76227 Karlsruhe | Germany


----- Forwarded message from Ingo Schwarze <ischwarze@[...].com>  -----

From: Ingo Schwarze <ischwarze@[...].com> 
Date: Tue, 26 Jun 2007 15:28:18 +0200
To: pdk@[...].com
Subject: shared objects for modules with two-component names

Hi,

At astaro.com, we are using ActivePerl and PerlApp to wrap modules
for the Astaro Security Gateway.  Currently, i'm trying to evaluate
whether it might be possible to compile various modules into
shared object files in order to load and unload them on demand.
Two goals are involved: (1) Modules should not be accessible when
disabled and (2) unused modules should not bloat the application in
question.

The module names belong to a hierarchy.  Typically, they contain
at least one "::", e.g. modules::IPSec::LocalKey::RSA.pm.
The Modules are clean: they export nothing.  They are intended
to be required, not used.  The module names are saved in
perl scalar variables, so the require statements are wrapped
in eval.

For getting started, i wrote a toy application, but now i'm stuck
even after reading the docs at
  http://aspn.activestate.com/ASPN/docs/PDK/7.0/PerlApp.html and
  http://community.activestate.com/faq-list and
  http://aspn.activestate.com/ASPN/Mail/Browse/Threaded/pdk

Please be so kind to look at this:

ischwarze@sles10:~/Test>  uname -a
Linux sles10 2.6.16.21-0.8-bigsmp #1 SMP Mon Jul 3 18:25:39 UTC 2006   i686 i686 i386 GNU/Li
nux

ischwarze@sles10:~/Test>  /usr/local/ap587/bin/perl --version | head -n9
This is perl, v5.8.7 built for i686-linux-thread-multi
(with 13 registered patches, see perl -V for more detail)
Copyright 1987-2005, Larry Wall
Binary build 815 [211909] provided by ActiveState http://www.ActiveState.com
ActiveState is a division of Sophos.
Built Nov  2 2005 07:43:57

ischwarze@sles10:~/Test>  /usr/local/pdk/bin/perlapp --version
PerlApp 6.0.2 build 203380
Copyright (C) 1998-2005 ActiveState Corp.  All rights reserved.
ActiveState is a division of Sophos Plc.
Commercial license for XXX <XXX@[...].com> 

ischwarze@sles10:~/Test>  find . -exec ls -ald {} \;
drwxr-xr-x 5 ischwarze users 4096 2007-06-26 15:03 .
drwxr-xr-x 2 ischwarze users 4096 2007-06-26 15:03 ./MyPack
-rw-r--r-- 1 ischwarze users 167 2007-06-26 15:03 ./MyPack/MyMod.pm
drwxr-xr-x 2 ischwarze users 4096 2007-06-26 15:01 ./lib
-rw-r--r-- 1 ischwarze users 432 2007-06-26 14:41 ./Makefile
drwxr-xr-x 2 ischwarze users 4096 2007-06-26 15:01 ./bin
-rw-r--r-- 1 ischwarze users 206 2007-06-26 14:36 ./MyApp.pl

ischwarze@sles10:~/Test>  cat MyPack/MyMod.pm
package MyPack::MyMod;
use warnings;
use strict;
BEGIN { print "MyMod: executing BEGIN\n"; }
print "MyMod: DO\n";
sub myFunc { print "MyMod: executing myFunc\n"; }
1;

ischwarze@sles10:~/Test>  cat MyApp.pl 
my $modname = 'MyPack::MyMod';
print "main: require\n";
print "  eval: ".eval("require $modname")."\n";
print $@;
print "main: call\n";
print "  eval: ".eval("${modname}::myFunc()")."\n";
print $@;
exit 0;

ischwarze@sles10:~/Test>  /usr/local/ap587/bin/perl MyApp.pl 
main: require
MyMod: executing BEGIN
MyMod: DO
  eval: 1
main: call
MyMod: executing myFunc
  eval: 1

ischwarze@sles10:~/Test>  cat Makefile 
PERLAPP=/usr/local/pdk/bin/perlapp --perl /usr/local/ap587/bin/perl --force

LIBSRC=MyPack/MyMod.pm
LIBBIN=lib/MyMod.so

APPSRC=MyApp.pl
APPBIN=bin/MyApp

all: $(LIBBIN) $(APPBIN)

$(LIBBIN): $(LIBSRC)
        $(PERLAPP) --shared private $(LIBSRC) --exe $(LIBBIN)

$(APPBIN): $(APPSRC)
        $(PERLAPP) --shared private --runlib ../lib --use $(LIBBIN)                 $(APPSRC
) --exe $(APPBIN)

clean:
        rm -rf /tmp/pdk-ischwarze lib/* bin/*

.PHONY: clean
# end of Makefile

ischwarze@sles10:~/Test>  make
/usr/local/pdk/bin/perlapp --perl /usr/local/ap587/bin/perl --force   --shared private MyPac
k/MyMod.pm --exe lib/MyMod.so
PerlApp 6.0.2 build 203380
Copyright (C) 1998-2005 ActiveState Corp.  All rights reserved.
ActiveState is a division of Sophos Plc.
Commercial license for XXX <XXX@[...].com> 

Created 'lib/MyMod.so'
/usr/local/pdk/bin/perlapp --perl /usr/local/ap587/bin/perl --force   --shared private --run
lib ../lib --use lib/MyMod.so         MyApp.pl --exe bin/MyApp
PerlApp 6.0.2 build 203380
Copyright (C) 1998-2005 ActiveState Corp.  All rights reserved.
ActiveState is a division of Sophos Plc.
Commercial license for XXX <XXX@[...].com> 

Created 'bin/MyApp'
# end of make

schwarze@sles10:~/Test>  ./bin/MyApp 
main: require
  eval: 
Can't locate MyPack/MyMod.pm in @INC   (@INC contains: /home/ischwarze/Test/bin/../lib) at (
eval 3) line 3.
main: call
  eval: 
Undefined subroutine &MyPack::MyMod::myFunc called at (eval 5) line 1.

To summarize, both the module and the application compile, but the
application won't access the module in the shared object.  With
simple module names, this problem does not occur, i.e.
  my $modname = 'MySimple';
is working fine.

I would be grateful for any hints...

Besides, we would need to compile about two dozen modules like
MyPack::MyMod.  Do i understand correctly that each module must
contain the whole perllib?  Do i understand correctly that we
could build these modules without perllib if we were using PDK
version 7?

And finally, what about unloading previouly used modules in order
to free RAM or in order to make the code inaccessible when the
respective features are diabled by the administrator of the
server program, similar to dlclose(3)?  Is there any such
functionality?

Yours,
  Ingo

----- End forwarded message -----
_______________________________________________
PDK mailing list
PDK@[...].com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Thread:
Ingo Schwarze
Jan Dubois

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved