perl-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Nick *** <doink...@abv.bg>
Subject Re: [PATCH] Dynamic linking on Cygwin
Date Thu, 28 Apr 2005 10:48:42 GMT
 >-------- Оригинално писмо --------
 >От:  Stas Bekman <stas@stason.org>
 >Относно: Re: [PATCH] Dynamic linking on Cygwin
 >До: Nick *** <doink123@abv.bg>
 >Изпратено на: Сряда, 2005, Април 27 17:43:22 EEST
 >----------------------------------
 >
 >Nick *** wrote:
 >> Note that this patch doesn't fix the dynamic linking entirely, but does 75% of the
job.
 >> The problem with cygwin is that it behaves like windows (it's a posix layer over
windows after all). 
 >> That's why we need to supply all symbols during linking time just like on win32,
by adding -lapr-0 -laprutil-0 and -lhttpd. On windows, Apache supplies all the three libraries
and it's easy to link, but on cygwin apache doesn't play nice and doesn't supply libhttpd.
 >> My patch adds libapr and libaprutil. Also, I have a workaround for libhttpd, but
currently I'm thinking on how to implement it.
 >
 >Thanks Nick. But please test for me the patch below. I've just changed the 
 >way you've generated the flags to make the dealing with space separators 
 >less painful for the eyes and replaced the hardcoded -lmod_perl with
 >"-l$self->{MP_LIBNAME}". Though I can't test it.
 >[...]

Works great. Also I made some tweaks and improvements.

Index: Changes
===================================================================
--- Changes (revision 164866)
+++ Changes (working copy)
@@ -12,6 +12,15 @@

=item 1.999_23-dev

+improving DSO support on cygwin. The problem with cygwin is that it
+behaves like windows (it's a posix layer over windows after
+all). That's why we need to supply all symbols during linking time
+just like on win32, by adding -lapr-0 -laprutil-0 and -lhttpd. On
+windows, Apache supplies all the three libraries and it's easy to
+link, but on cygwin apache doesn't play nice and doesn't supply
+libhttpd. Nick's patch adds libapr and libaprutil. [Nick ***
+<doink123@abv.bg>]
+
improve the diagnostics when detecting mp2 < 1.999022, tell the user
which files and/or dirs need to be removed [Stas]

Index: lib/Apache2/Build.pm
===================================================================
--- lib/Apache2/Build.pm	(revision 165036)
+++ lib/Apache2/Build.pm	(working copy)
@@ -40,7 +40,7 @@
 use constant REQUIRE_ITHREADS => grep { $^O eq $_ } qw(MSWin32);
 use constant PERL_HAS_ITHREADS =>
     $Config{useithreads} && ($Config{useithreads} eq 'define');
-use constant BUILD_APREXT => WIN32();
+use constant BUILD_APREXT => WIN32() || CYGWIN();

 use ModPerl::Code ();
 use ModPerl::BuildOptions ();
@@ -464,6 +464,10 @@
         $ldopts .= $self->gtop_ldopts;
     }

+    if (CYGWIN && $self->is_dynamic) {
+        $ldopts .= join ' ', '', $self->apru_link_flags;
+    }
+
     $config->{ldflags} = $ldflags; #reset

     # on Irix mod_perl.so needs to see the libperl.so symbols, which
@@ -1050,7 +1054,9 @@

     return @apru_link_flags if @apru_link_flags;

-    for ($self->apr_config_path, $self->apu_config_path) {
+    # first use apu_config_path and then apr_config_path in order to
+    # resolve the symbols right during linking
+    for ($self->apu_config_path, $self->apr_config_path) {
         if (my $link = $_ && -x $_ && qx{$_ --link-ld --libs}) {
             chomp $link;
             if ($self->httpd_is_source_tree) {
@@ -1538,14 +1544,19 @@
     "$self->{cwd}/src/modules/perl/$self->{MP_LIBNAME}.lib";
 }

+sub modperl_libs_cygwin {
+    my $self = shift;
+    "-L$self->{cwd}/src/modules/perl -l$self->{MP_LIBNAME}";
+}
+
 sub modperl_libs {
     my $self = shift;
-    my $libs = \&{"modperl_libs_$^O"};
+    my $libs = \&{"modperl_libs_$^O"};
     return "" unless defined &$libs;
     $libs->($self);
 }

-# returns the directory and name of the aprext lib built under blib/
+# returns the directory and name of the aprext lib built under blib/
 sub mp_apr_blib {
     my $self = shift;
     return unless (my $mp_apr_lib = $self->{MP_APR_LIB});
@@ -1566,6 +1577,19 @@
     return qq{ -L$dir -l$lib };
 }

+sub mp_apr_lib_cygwin {
+    my $self = shift;
+    my ($dir, $lib) = $self->mp_apr_blib();
+    $lib =~ s[^lib(\w+)$Config{lib_ext}$][$1];
+    my $libs = "-L$dir -l$lib";
+
+    # This is ugly, but is the only way to prevent the "undefined symbols" error
+    $libs .= join ' ', '', $self->apru_link_flags;
+    $libs .= ' -L' . join ('/', $self->perl_config('archlibexp'), 'CORE') . ' -lperl';
+    $libs;
+
+}
+
 # linking used for the aprext lib used to build APR/APR::*
 sub mp_apr_lib {
     my $self = shift;
@@ -1801,6 +1825,17 @@
     $flags;
 }

+sub otherldflags_cygwin {
+    my $self = shift;
+    my $flags = $self->otherldflags_default;
+
+    unless ($self->{MP_STATIC_EXTS}) {
+        $flags .= join ' ', $self->apru_link_flags;
+    }
+
+    $flags;
+}
+
 sub typemaps {
     my $self = shift;
     my @typemaps = ();



-----------------------------------------------------------------
http://host.GBG.bg - лидер в Уеб Хостинг решения и регистрация
на Домейн имена

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org


Mime
View raw message