perl-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Nick *** <doink...@abv.bg>
Subject Re: The final patch needed for mp2 to build on Cygwin
Date Mon, 11 Jul 2005 13:54:10 GMT
Hello, 
the patch is ready after two weeks of nightmare. I managed to make Build.pm create mod_perl.so
pretty easy, when I removed the ld2 dependency. make test did well and I was ready to submit
the patch.
But that's where my problems began, because the static build didn't go well.
At first I had problems with libtool, which didn't want to include mod_perl.a in httpd2core.dll,
because it's a static archive. Very strange.
My first solution was to create .la file for every static archive (mod_perl.a, DynaLoader.a
and Win32CORE.a). It did work, but was too complex and relied on that the format of .la files
won't change in the future.
Finally, I did it by sending mod_perl.a directly to the linker using the -Wl param and now
it works very nice.
But then make test didn't work. The server started, printed that 6 apache2 and 0 apr modules
were loaded and then... just quits!
No errors in the error_log, no segfault, nothing! Just a quit.
This one took me several days. I tested so many things, recompiled mp2 with different args
and so on. GDB didn't help.
On the day I was ready to quit, it just worked. What was the reason? 
On cygwin I have to use preinstalled APR and APU, which are compiled without threads support
and perl was compiled with ithreads. I recompiled perl without ithreads and it worked.
This seems to affect only the static build. I was going to put a check in
Makefile.PL, but I don't know how to check whether APR was compiled with threads. apr-config
doesn't have such info, does it?
Then I had some tiny issues with make install, but managed to solve them fast.

The attached patch is a big one and changes some of my previous patches and that's why I decided
to create a small FAQ, but first
let me introduce you to a tiny "feature" of cygwin's linker, which has a big impact on the
patch.

The ld params should be "ordered", so the libs that supply some symbols should be after the
libs that need these symbols on the command line.
For example:
gcc -o myprog myprog.o -lmydll works, but
gcc -o myprog -lmydll myprog.o dies with "undefined reference" error.
Quite a nasty feature.

So, here's the faq, which covers most of the unpopular changes.
Q: Won't the reorder of the libs in ModPerl::BuildMM affect in some way other platforms?
A: For the last two weeks I also managed to test the patch on:
Win32, FreeBSD, HP-UX, Tru64, RedHat, SuSe and it works fine.

Q: Why the cygwin code from Apache2::Build::ldopts was removed?
A: It's moved into &apache_libs_cygwin, where it should have been from
the beginning.
Q: Why it hasn't been there from the beginning?
A: Because of the order of the libs. The apache libs would show up in the command line before
the libs that need them. But now we reorder the libs at Makefile level (in &dynamic_link_cygwin)
Q: Why this wasn't done earlier?
A: Because I wasn't so familiar with Build.pm and didn't know it's possible without some major
changes.

Q: Why &modperl_libpath was introduced?
A: Because &modperl_libs didn't work well for Cygwin.
&modperl_libs was used for two different cases: 
1. Supplying the path to mod_perl.lib, when linking the Apache2 modules and 2. supplying the
path to mod_perl.lib, when installing it. The first case won't work for cygwin, because MakeMaker
sees the full path to mod_perl.dll.a as an unknown argument. It should be -L/path -lmodperl.
But this won't work for the second case, 
because "cp -Lpath -lmodperl /some/path" is an error.
So, now &modperl_libs returns the linker flags and &modperl_libpath returns the full
path to mod_perl(.lib|.dll.a).

Q: Why &modperl_static_libs_cygwin was removed?
A: Before the introduction of the cygwin's httpd port, apache linked it's modules into httpd.exe
and so was the static mod_perl. In this case
we had to link the Apache2:: modules to something and mod_perl.a was the only solution. This
method prepared the libs and returned the needed linker flags for this. 
Now it's a different story, because httpd includes all modules into httpd2core.dll and in
this case we can link our Apache2:: modules directly to -lhttpd2core.

Q: Why &otherldflags_cygwin was removed?
A: After all the rearrangements with the libs order, this method is not needed anymore.

Q: What's the result of this patch?
A:
Dynamic build:

Failed Test                   Stat Wstat Total Fail  Failed  List of Failed
-------------------------------------------------------------------------------
t/apache/subprocess.t                        5    4  80.00%  2-5
t/filter/out_bbs_filebucket.t               10    2  20.00%  9-10
t/modperl/sameinterp.t         113 28928    12    8  66.67%  9-12
t/protocol/pseudo_http.t                    13    9  69.23%  3-8 11-13
14 tests skipped.
Failed 4/236 test scripts, 98.31% okay. 19/2340 subtests failed, 99.19% okay.

Static build:

Failed Test                   Stat Wstat Total Fail  Failed  List of Failed
-------------------------------------------------------------------------------
t/apr-ext/finfo.t                           27    2   7.41%  2 16
t/apr/finfo.t                               28    2   7.14%  3 17
t/filter/out_bbs_filebucket.t               10    2  20.00%  9-10
t/protocol/pseudo_http.t                    13    3  23.08%  11-13
42 tests skipped.
Failed 4/236 test scripts, 98.31% okay. 9/2028 subtests failed, 99.56% okay.


ModPerl-Registry:
All tests successful, 2 tests skipped.
Files=16, Tests=78, 569 wallclock secs (190.94 cusr + 173.95 csys = 364.90 CPU)


I will send reports for the failing tests later.
P.S. Please feel free to edit the patch, whenever you see the need to.

-----------------------------------------------------------------
http://host.gbg.bg/- Малък бизнес Pro хостинг - Идеална комбинация
от цена и възможности!
Mime
View raw message