Re: [mp2 patch] getting APR to work w/o modperl

2004-05-16 Thread Randy Kobes
On Sat, 15 May 2004, Stas Bekman wrote:

 Randy Kobes wrote:
  On Mon, 10 May 2004, Stas Bekman wrote:
 
 How about a quick workaround as follows: For windows only,
 link APR.so statically with all APR/Foo.o and the required
 modperl_foo.o and arrange for the bootstrap not to call it
 for windows if APR.so is loaded?
 
 
  That sounds good ...

 So can you try to tackle that? I guess my latest patch
 won't apply against the current cvs and I'll need to
 re-sync it and resolve collisions.

I'll give it a go ... So as I'll be current, could you
re-sync it, if it's not too difficult? Alternatively,
if the patch is OK on others (apart from Win32, and
perhaps aix), is it ready to apply, and we'll work
from there?

 I guess all you need to do is to change
 xs/APR/APR/Makefile.PL to collect all .o files from under
 xs/APR and a few selected src/modules/perl/modperl_xxx.o
 and link them statically with APR.so if under win32. (and
 may be some other platforms too (aix comes to mind)).

Just so I understand correctly, in this approach we'll have
one (big) APR.so that has collected all the functionality of
the individual APR::* modules (as well as the old APR.so
itself and selected symbols from modperl_xxx.o)? Or does APR
stay essentially the same (with the added symbols from
selected modperl_xxx.o), and then one links each APR::* with
APR.so?

It should be relatively straightforward to do the latter (as
long as APR.so is built before APR::*). However, with the
former, there'd be problems building the individual APR::*
modules first, to be used as components in building APR.so,
for the same reason that exists now - to build APR::*, one
has to specify the library where the symbols are found, and
one can't specify a library (APR.so) that hasn't been built
yet. This could be resolved in some cases by linking APR::*
against the relevant modperl_xxx.o files; however, for those
that require some functionality within APR.so itself, there
might be a problem ...

  The only alternative I was able
  to come up with is to use LoadLibrary/GetProcAddress
  to set a function pointer to that of a function
  within a dll. I tried to cut this down to the
  minimal needed, and came up with something along
  the lines of, generically,
 
  typdef ... /* delare the function pointers */
 
  HINSTANCE hlib;
  if (GetProcAddresses(hlib, Some.dll,
   fn_1, func_1,
   fn_2, func_2,
   ...) {
/* the functions are available */
  }
  if (hlib != NULL) FreeLibrary(hlib);
 
  where GetProcAddresses() is a simple (generic) routine that
  associates, from Some.dll, func_1, func_2, ... with fn_1,
  fn_2, ... So, in this approach, for each APR::* as
  appropriate, necessary function pointers must be declared,
  GetProcAddresses() is invoked, and finally, if necessary,
  FreeLibrary() called at the end.
 
  However, I don't have enough experience with the build
  system to compare if the above would be easier or harder to
  set up and maintain, compared to linking against the
  appropriate .so files.

 The biggest problem I see here, is that we won't be able
 to test whether things still work on windows, every time
 we change or add something. So I'd prefer not to use it.
 If this can be done automatically, without touching the
 existing code, then i guess it's OK. But I'm not quite
 sure this is possible.

That's certainly a concern ... If this is ever
attempted, I think some (most?) of it could be
done somewhat automatically, but maybe it'd be
better to explore the above approach first.

-- 
best regards,
randy

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: [mp2 patch] getting APR to work w/o modperl

2004-05-16 Thread Stas Bekman
On Sun, 16 May 2004, Randy Kobes wrote:

 On Sat, 15 May 2004, Stas Bekman wrote:
 
  Randy Kobes wrote:
   On Mon, 10 May 2004, Stas Bekman wrote:
  
  How about a quick workaround as follows: For windows only,
  link APR.so statically with all APR/Foo.o and the required
  modperl_foo.o and arrange for the bootstrap not to call it
  for windows if APR.so is loaded?
  
  
   That sounds good ...
 
  So can you try to tackle that? I guess my latest patch
  won't apply against the current cvs and I'll need to
  re-sync it and resolve collisions.
 
 I'll give it a go ... So as I'll be current, could you
 re-sync it, if it's not too difficult? Alternatively,
 if the patch is OK on others (apart from Win32, and
 perhaps aix), is it ready to apply, and we'll work
 from there?

Well, I don't want to destabilize the tree, we should make a new release 
pretty soon. I think while you are playing with various solutions you 
could just check the cvs tree for the day I've posted my second patch and 
it should apply just fine. Your work is going to be in the xs/APR/APR 
area, not really touching anything else. If you think it's a problem I'll 
then try to post an up-to-date patch, but it may quickly become 
out-of-date in a few days.
 
  I guess all you need to do is to change
  xs/APR/APR/Makefile.PL to collect all .o files from under
  xs/APR and a few selected src/modules/perl/modperl_xxx.o
  and link them statically with APR.so if under win32. (and
  may be some other platforms too (aix comes to mind)).
 
 Just so I understand correctly, in this approach we'll have
 one (big) APR.so that has collected all the functionality of
 the individual APR::* modules (as well as the old APR.so
 itself and selected symbols from modperl_xxx.o)? Or does APR
 stay essentially the same (with the added symbols from
 selected modperl_xxx.o), and then one links each APR::* with
 APR.so?

I was talking about the former, where APR.so will include all 
objects in Wrap/APR/*/.o (not .so) and some 
of src/modules/perl/modperl_xxx.o.

I'm not sure how can you go with the latter idea. I mean, I'll work 
perfectly fine without mod_perl. But how is it going to work under 
mod_perl, when both mod_perl.so and APR.so will have the same symbols, and 
according to your suggestion, both will be loaded (since APR/Foo.so will 
be linked against APR.so). It would have worked perfectly if we could also 
link mod_perl.so against APR.so and not include those symbols in 
mod_perl.so. Which is probably the best solution possible. The problem is 
that the loaded will somehow have to find APR.so when trying to load 
mod_perl.so. This could have been done by installing APR.so along with 
libapr.so I suppose.

In that case we will have APR a totally autonomous systems and mod_perl 
will use it. May be it makes perfect sense, but I haven't thought of the 
implications for users.

 It should be relatively straightforward to do the latter (as
 long as APR.so is built before APR::*). However, with the
 former, there'd be problems building the individual APR::*
 modules first, to be used as components in building APR.so,
 for the same reason that exists now - to build APR::*, one
 has to specify the library where the symbols are found, and
 one can't specify a library (APR.so) that hasn't been built
 yet.

But I was talking about building .o objects, not shared libs. and linking 
those .o objects with APR.so. Will that be a problem too? AFAIK you never 
need to provide information about shared libs, during compilation time. Is 
that different on windows?


__
Stas BekmanJAm_pH -- Just Another mod_perl Hacker
http://stason.org/ mod_perl Guide --- http://perl.apache.org 
mailto:[EMAIL PROTECTED] http://use.perl.org http://apacheweek.com  
http://modperlbook.org http://apache.org   http://ticketmaster.com

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: [mp2 patch] getting APR to work w/o modperl

2004-05-16 Thread Randy Kobes
On Sun, 16 May 2004, Stas Bekman wrote:

 On Sun, 16 May 2004, Randy Kobes wrote:
[ .. ]
 Well, I don't want to destabilize the tree, we should make
 a new release pretty soon. I think while you are playing
 with various solutions you could just check the cvs tree
 for the day I've posted my second patch and it should
 apply just fine. Your work is going to be in the
 xs/APR/APR area, not really touching anything else. If you
 think it's a problem I'll then try to post an up-to-date
 patch, but it may quickly become out-of-date in a few
 days.

Sounds good ...

   I guess all you need to do is to change
   xs/APR/APR/Makefile.PL to collect all .o files from under
   xs/APR and a few selected src/modules/perl/modperl_xxx.o
   and link them statically with APR.so if under win32. (and
   may be some other platforms too (aix comes to mind)).
 
  Just so I understand correctly, in this approach we'll have
  one (big) APR.so that has collected all the functionality of
  the individual APR::* modules (as well as the old APR.so
  itself and selected symbols from modperl_xxx.o)? Or does APR
  stay essentially the same (with the added symbols from
  selected modperl_xxx.o), and then one links each APR::* with
  APR.so?

 I was talking about the former, where APR.so will include all
 objects in Wrap/APR/*/.o (not .so) and some
 of src/modules/perl/modperl_xxx.o.

OK, that makes sense ...

 I'm not sure how can you go with the latter idea. I mean,
 I'll work perfectly fine without mod_perl. But how is it
 going to work under mod_perl, when both mod_perl.so and
 APR.so will have the same symbols, and according to your
 suggestion, both will be loaded (since APR/Foo.so will be
 linked against APR.so).

In this approach I don't there's a problem on Windows with
linking against libraries with the same symbols; depending
on the order of the libraries in the link command, VC++
will resolve the symbols not found in the object files in
the 1st library file it finds that has them (which then
registers the corresponding .so, if it's a shared library),
so any identical symbols in a later library used in the link
command are ignored. Thus, you could in principle build
an application linked against two dlls that have the
same symbols in them and there shouldn't be a conflict,
as the application knows, from how it was linked, which
dll each symbol comes from.

However, this also means that no symbols can be resolved
through mod_perl.lib, as this would require loading
mod_perl.so (unless one used the -delayload link option,
to load the dll only if a symbol is invoked).

 It would have worked perfectly if
 we could also link mod_perl.so against APR.so and not
 include those symbols in mod_perl.so. Which is probably
 the best solution possible. The problem is that the loaded
 will somehow have to find APR.so when trying to load
 mod_perl.so. This could have been done by installing
 APR.so along with libapr.so I suppose.
 In that case we will have APR a totally autonomous systems and mod_perl
 will use it. May be it makes perfect sense, but I haven't thought of the
 implications for users.

  It should be relatively straightforward to do the latter (as
  long as APR.so is built before APR::*). However, with the
  former, there'd be problems building the individual APR::*
  modules first, to be used as components in building APR.so,
  for the same reason that exists now - to build APR::*, one
  has to specify the library where the symbols are found, and
  one can't specify a library (APR.so) that hasn't been built
  yet.

 But I was talking about building .o objects, not shared
 libs. and linking those .o objects with APR.so. Will that
 be a problem too? AFAIK you never need to provide
 information about shared libs, during compilation time. Is
 that different on windows?

No, you're right - resolving all symbols only is required at
link time, so this could be done by just compiling (with -c)
the APR::* files to build the object files, and skip
building the associated APR::* dlls, as is done now.

I think things are becoming clearer to me - thanks.
It looks like most of this can be done by fiddling
with the compiling/linking commands, without the need
(hopefully) of any source code modifications. I'll
try it and see.

-- 
best regards,
randy

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: [mp2 patch] getting APR to work w/o modperl

2004-05-16 Thread Stas Bekman
Randy Kobes wrote:
[...]
I'm not sure how can you go with the latter idea. I mean,
I'll work perfectly fine without mod_perl. But how is it
going to work under mod_perl, when both mod_perl.so and
APR.so will have the same symbols, and according to your
suggestion, both will be loaded (since APR/Foo.so will be
linked against APR.so).

In this approach I don't there's a problem on Windows with
linking against libraries with the same symbols; depending
on the order of the libraries in the link command, VC++
will resolve the symbols not found in the object files in
the 1st library file it finds that has them (which then
registers the corresponding .so, if it's a shared library),
so any identical symbols in a later library used in the link
command are ignored. Thus, you could in principle build
an application linked against two dlls that have the
same symbols in them and there shouldn't be a conflict,
as the application knows, from how it was linked, which
dll each symbol comes from.
That's excellent. So you link APR/Foo.so against APR.so which contains the 
minimal amount of modperl_xxx.o in it which is already provided by my patch 
(you only need to arrange linking against APR.lib instead of mod_perl.lib). 
APR/Foo.pm then must make sure that APR.pm (and so APR.so) are loaded before 
it loads its own APR/Foo.so. But this could be done later, for now let's say 
that we do it manually, by doing

  PerlModule APR
immediately after
  LoadModule mod_perl.so
Now the question is, whether the same could work for all other platforms. I 
was sure that's it's not possible to load two objects with the same symbols, 
but I could be wrong. Do you know whether this is true for all platforms?

However, this also means that no symbols can be resolved
through mod_perl.lib, as this would require loading
mod_perl.so (unless one used the -delayload link option,
to load the dll only if a symbol is invoked).
That's perfectly fine.
It would have worked perfectly if
we could also link mod_perl.so against APR.so and not
include those symbols in mod_perl.so. Which is probably
the best solution possible. The problem is that the loaded
will somehow have to find APR.so when trying to load
mod_perl.so. This could have been done by installing
APR.so along with libapr.so I suppose.
In that case we will have APR a totally autonomous systems and mod_perl
will use it. May be it makes perfect sense, but I haven't thought of the
implications for users.

It should be relatively straightforward to do the latter (as
long as APR.so is built before APR::*). However, with the
former, there'd be problems building the individual APR::*
modules first, to be used as components in building APR.so,
for the same reason that exists now - to build APR::*, one
has to specify the library where the symbols are found, and
one can't specify a library (APR.so) that hasn't been built
yet.
But I was talking about building .o objects, not shared
libs. and linking those .o objects with APR.so. Will that
be a problem too? AFAIK you never need to provide
information about shared libs, during compilation time. Is
that different on windows?

No, you're right - resolving all symbols only is required at
link time, so this could be done by just compiling (with -c)
the APR::* files to build the object files, and skip
building the associated APR::* dlls, as is done now.
I think things are becoming clearer to me - thanks.
It looks like most of this can be done by fiddling
with the compiling/linking commands, without the need
(hopefully) of any source code modifications. I'll
try it and see.
Correct. I think your suggestion at the top is much better that dumping all .o 
into APR.so. If it works for every platform then we are gold.


--
__
Stas BekmanJAm_pH -- Just Another mod_perl Hacker
http://stason.org/ mod_perl Guide --- http://perl.apache.org
mailto:[EMAIL PROTECTED] http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Re: [mp2 patch] getting APR to work w/o modperl

2004-05-11 Thread Stas Bekman
Randy Kobes wrote:
On Sun, 9 May 2004, Stas Bekman wrote:


Yes, that sounds like a much better idea. There should be
a way to tell the application that certain symbols will be
resolved at run-time, and no matter who will provide them
(application, another library or else). On AIX the linker
is just as picky, but lets you shut up itself by telling
it that the missing symbols will be resolved at run time
and that it shouldn't worry about it. using the -brtl
option (see lib/Apache/Build.pm).


There is a link option on VC++ 6, -delayload:some.dll, which
delays the loading of a dll until a function inside it is
actually called by an application. But this is used in
situations like
  if (some_condition_is_true) {
call_the_dll_function();
  }
  else {
do_something_else();
  }
where the dll may not be available on some target machine.
What seems different on Windows compared to Unix, even with
this delayload thing (which still requires you to link
against the .lib file corresponding to the relevant .dll),
is that when you link against a .lib file which resolves
symbols, information about those symbols appears in the
result which contains references to the specific dll where
those symbols appear. What Jan suggested, in some sense, is
to try to fool Win32 by building, eg, APR.so, in a way to
make it go by the name of mod_perl.so, by using the same
.def file for both (and specifying a library name). But this
doesn't seem to quite work, at least in a simple way.
In short, no go, right?

How about a quick workaround as follows: For windows only, link APR.so 
statically with all APR/Foo.o and the required modperl_foo.o and arrange for 
the bootstrap not to call it for windows if APR.so is loaded?

--
__
Stas BekmanJAm_pH -- Just Another mod_perl Hacker
http://stason.org/ mod_perl Guide --- http://perl.apache.org
mailto:[EMAIL PROTECTED] http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Re: [mp2 patch] getting APR to work w/o modperl

2004-05-10 Thread Randy Kobes
On Sun, 9 May 2004, Stas Bekman wrote:

 Yes, that sounds like a much better idea. There should be
 a way to tell the application that certain symbols will be
 resolved at run-time, and no matter who will provide them
 (application, another library or else). On AIX the linker
 is just as picky, but lets you shut up itself by telling
 it that the missing symbols will be resolved at run time
 and that it shouldn't worry about it. using the -brtl
 option (see lib/Apache/Build.pm).

There is a link option on VC++ 6, -delayload:some.dll, which
delays the loading of a dll until a function inside it is
actually called by an application. But this is used in
situations like
  if (some_condition_is_true) {
call_the_dll_function();
  }
  else {
do_something_else();
  }
where the dll may not be available on some target machine.

What seems different on Windows compared to Unix, even with
this delayload thing (which still requires you to link
against the .lib file corresponding to the relevant .dll),
is that when you link against a .lib file which resolves
symbols, information about those symbols appears in the
result which contains references to the specific dll where
those symbols appear. What Jan suggested, in some sense, is
to try to fool Win32 by building, eg, APR.so, in a way to
make it go by the name of mod_perl.so, by using the same
.def file for both (and specifying a library name). But this
doesn't seem to quite work, at least in a simple way.

-- 
best regards,
randy

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]