[mp1] Linking confusion
Hi folks, I'm trying to recompile Perl and Apache/mod_perl on a Debian Sarge system using the following versions: Perl 5.8.6 Apache 1.3.33 mod_perl 1.29 I am compiling mod_perl statically (using Apachetoolbox) with the following options: APACHE_PREFIX=/usr/local/apache APACHE_SRC=/usr/local/src/Apachetoolbox-1.5.72/apache_1.3.33/src SSL_BASE= APACI_ARGS='--enable-module=rewrite' DO_HTTPD=1 USE_APACI=1 EVERYTHING=1 During compilation of mod_perl, I was seeing undefined reference errors which are nicely described on the install page[1]. The prescription suggests rebuilding Perl with dynamic linking; apparently the version that's shipped with Debian is not dynamically linked(?). Sounds fine, but I'm not a C programmer so am not sure exactly what this means. >From what I could find reading the INSTALL document that comes with the Perl source, I need to recompile with the -Duseshrplib compile-time option. My understanding is that this option will build a libperl.so file. Is this correct? Am I taking the right action to build a dynamic Perl? With that option, I am able to compile Apache with mod_perl. Now though, when starting the newly compiled server, I'm receiving relocation errors which appear to be due to multiple versions of libperl.so/libperl.a (not sure which). While browsing the net for possible solutions, I came across the troubleshooting document[2]. It seems to say that if 'perl -V:useshrplib' returns true, then Perl is statically linked. Is this correct? It seems opposite of what I'd expect from reading the INSTALL document. I'm pretty much at wits end as to why I'm receiving relocation errors. The best I can figure is some kind of binary incompatibility between the version of Perl that I've compiled and previously compiled libraries. I've tried reinstalling some of the XS modules such as DBI which seems to clear up these errors. Any other suggestions or pointers, esp. in light of the differences between dynamic and static linking and libperl.so/libperl.a, would be much appreciated. Thanks, William [1] http://perl.apache.org/docs/1.0/guide/install.html#Undefined_reference_to__PL_perl_destruct_level_ [2] http://perl.apache.org/docs/1.0/guide/troubleshooting.html#_relocation_errors__or__undefined_symbol_ -- Knowmad Services Inc. http://www.knowmad.com -- Report problems: http://perl.apache.org/bugs/ Mail list info: http://perl.apache.org/maillist/modperl.html List etiquette: http://perl.apache.org/maillist/email-etiquette.html
Re: [mp1] Linking confusion
William McKee wrote: Hi folks, I'm trying to recompile Perl and Apache/mod_perl on a Debian Sarge system using the following versions: Perl 5.8.6 Apache 1.3.33 mod_perl 1.29 I am compiling mod_perl statically (using Apachetoolbox) with the following options: APACHE_PREFIX=/usr/local/apache APACHE_SRC=/usr/local/src/Apachetoolbox-1.5.72/apache_1.3.33/src SSL_BASE= APACI_ARGS='--enable-module=rewrite' DO_HTTPD=1 USE_APACI=1 EVERYTHING=1 During compilation of mod_perl, I was seeing undefined reference errors which are nicely described on the install page[1]. The prescription suggests rebuilding Perl with dynamic linking; apparently the version that's shipped with Debian is not dynamically linked(?). Sounds fine, but I'm not a C programmer so am not sure exactly what this means. Now that you know what does it take, please send a patch that extends [1] to explain how to do that. From what I could find reading the INSTALL document that comes with the Perl source, I need to recompile with the -Duseshrplib compile-time option. My understanding is that this option will build a libperl.so file. Is this correct? Am I taking the right action to build a dynamic Perl? That's correct. With that option, I am able to compile Apache with mod_perl. Now though, when starting the newly compiled server, I'm receiving relocation errors which appear to be due to multiple versions of libperl.so/libperl.a (not sure which). While browsing the net for possible solutions, I came across the troubleshooting document[2]. It seems to say that if 'perl -V:useshrplib' returns true, then Perl is statically linked. Is this correct? It seems opposite of what I'd expect from reading the INSTALL document. Right, it's a docbug, fixed in svn. I'm pretty much at wits end as to why I'm receiving relocation errors. The best I can figure is some kind of binary incompatibility between the version of Perl that I've compiled and previously compiled libraries. I've tried reinstalling some of the XS modules such as DBI which seems to clear up these errors. Any other suggestions or pointers, esp. in light of the differences between dynamic and static linking and libperl.so/libperl.a, would be much appreciated. As [2] explains you have more than one libperl.so and the wrong one gets loaded. libperl.so should *not* be in /usr/lib or any other globally seen loader path if you want to have more than one perl on the same system. Unfortunately some distros don't get it and install libperl.(so|a) into /usr/lib :( [1] http://perl.apache.org/docs/1.0/guide/install.html#Undefined_reference_to__PL_perl_destruct_level_ [2] http://perl.apache.org/docs/1.0/guide/troubleshooting.html#_relocation_errors__or__undefined_symbol_ -- __ 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 -- Report problems: http://perl.apache.org/bugs/ Mail list info: http://perl.apache.org/maillist/modperl.html List etiquette: http://perl.apache.org/maillist/email-etiquette.html
Re: [mp1] Linking confusion
On Thu, Dec 30, 2004 at 05:57:07PM -0500, Stas Bekman wrote: > As [2] explains you have more than one libperl.so and the wrong one gets > loaded. libperl.so should *not* be in /usr/lib or any other globally seen > loader path if you want to have more than one perl on the same system. > Unfortunately some distros don't get it and install libperl.(so|a) into > /usr/lib :( I'm guessing that this goes for any libperl.so, e.g. libperl.so.5.6 or libperl.so.5.8. If so then it would explain the weird behavior that I've been getting when compiling mod_perl. Thanks, William -- Knowmad Services Inc. http://www.knowmad.com -- Report problems: http://perl.apache.org/bugs/ Mail list info: http://perl.apache.org/maillist/modperl.html List etiquette: http://perl.apache.org/maillist/email-etiquette.html
Re: [mp1] Linking confusion
William McKee wrote: On Thu, Dec 30, 2004 at 05:57:07PM -0500, Stas Bekman wrote: As [2] explains you have more than one libperl.so and the wrong one gets loaded. libperl.so should *not* be in /usr/lib or any other globally seen loader path if you want to have more than one perl on the same system. Unfortunately some distros don't get it and install libperl.(so|a) into /usr/lib :( I'm guessing that this goes for any libperl.so, e.g. libperl.so.5.6 or libperl.so.5.8. If so then it would explain the weird behavior that I've been getting when compiling mod_perl. Normally in addition to libperl.so.5.8 there will be a symlink to libperl.so. Applications normally link against .so and not .so.x.y, so an upgrade of that library will be possible w/o requiring the compilation of the former. -- __ 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 -- Report problems: http://perl.apache.org/bugs/ Mail list info: http://perl.apache.org/maillist/modperl.html List etiquette: http://perl.apache.org/maillist/email-etiquette.html
Re: [mp1] Linking confusion
On Thu, Dec 30, 2004 at 07:00:36PM -0500, Stas Bekman wrote: > >I'm guessing that this goes for any libperl.so, e.g. libperl.so.5.6 or > >libperl.so.5.8. If so then it would explain the weird behavior that I've > >been getting when compiling mod_perl. > > Normally in addition to libperl.so.5.8 there will be a symlink to > libperl.so. Applications normally link against .so and not .so.x.y, so an > upgrade of that library will be possible w/o requiring the compilation of > the former. Hmm, that's what I thought too and was creating a symlink from /usr/lib/libperl.so to the newly created one. I was still getting strange behavior though so moved them all out of /usr/lib. Seems a bit better now. Thanks, William -- Knowmad Services Inc. http://www.knowmad.com -- Report problems: http://perl.apache.org/bugs/ Mail list info: http://perl.apache.org/maillist/modperl.html List etiquette: http://perl.apache.org/maillist/email-etiquette.html
Re: [mp1] Linking confusion
William McKee wrote: On Thu, Dec 30, 2004 at 07:00:36PM -0500, Stas Bekman wrote: I'm guessing that this goes for any libperl.so, e.g. libperl.so.5.6 or libperl.so.5.8. If so then it would explain the weird behavior that I've been getting when compiling mod_perl. Normally in addition to libperl.so.5.8 there will be a symlink to libperl.so. Applications normally link against .so and not .so.x.y, so an upgrade of that library will be possible w/o requiring the compilation of the former. Hmm, that's what I thought too and was creating a symlink from /usr/lib/libperl.so to the newly created one. I was still getting strange behavior though so moved them all out of /usr/lib. Seems a bit better now. If the application links against a specific libperl.so.x.y that would explain that behavior. -- __ 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 -- Report problems: http://perl.apache.org/bugs/ Mail list info: http://perl.apache.org/maillist/modperl.html List etiquette: http://perl.apache.org/maillist/email-etiquette.html
Re: [mp1] Linking confusion
On Thu, Dec 30, 2004 at 07:32:19PM -0500, Stas Bekman wrote: > >Hmm, that's what I thought too and was creating a symlink from > >/usr/lib/libperl.so to the newly created one. I was still getting > >strange behavior though so moved them all out of /usr/lib. Seems a bit > >better now. > > If the application links against a specific libperl.so.x.y that would > explain that behavior. And ldd is the best tool to use to check the links (at least on Unix)? William -- Knowmad Services Inc. http://www.knowmad.com -- Report problems: http://perl.apache.org/bugs/ Mail list info: http://perl.apache.org/maillist/modperl.html List etiquette: http://perl.apache.org/maillist/email-etiquette.html
Re: [mp1] Linking confusion
On Thu, Dec 30, 2004 at 05:57:07PM -0500, Stas Bekman wrote: > >During compilation of mod_perl, I was seeing undefined reference errors > >which are nicely described on the install page[1]. The prescription > >suggests rebuilding Perl with dynamic linking; apparently the version > >that's shipped with Debian is not dynamically linked(?). Sounds fine, > >but I'm not a C programmer so am not sure exactly what this means. > > Now that you know what does it take, please send a patch that extends [1] > to explain how to do that. I've started working on a patch for the install doc[1] but have come across a couple of questions that I'm sure someone on the list could answer for me. 1) The docs refer to building a "dynamically linked Perl." Shouldn't the Perl be lowercase since we're talking about the interpreter, not the language? 2) In the same sentence, it says that a dynamically linked perl will have a libperl.a. Isn't that a libperl.so? Could someone describe the differences between libperl.a and libperl.so? I see that it exists in the apache source directory which makes me think it is used when building modperl. If I'm building mp statically linked, I shouldn't need libperl.a after I've installed, right? Is this the library that has been more appropriately named modperl.a in MP2? Cheers! William [1] http://perl.apache.org/docs/1.0/guide/install.html#Undefined_reference_to__PL_perl_destruct_level_ -- Knowmad Services Inc. http://www.knowmad.com -- Report problems: http://perl.apache.org/bugs/ Mail list info: http://perl.apache.org/maillist/modperl.html List etiquette: http://perl.apache.org/maillist/email-etiquette.html
Re: [mp1] Linking confusion
William McKee wrote: On Thu, Dec 30, 2004 at 05:57:07PM -0500, Stas Bekman wrote: During compilation of mod_perl, I was seeing undefined reference errors which are nicely described on the install page[1]. The prescription suggests rebuilding Perl with dynamic linking; apparently the version that's shipped with Debian is not dynamically linked(?). Sounds fine, but I'm not a C programmer so am not sure exactly what this means. Now that you know what does it take, please send a patch that extends [1] to explain how to do that. I've started working on a patch for the install doc[1] but have come across a couple of questions that I'm sure someone on the list could answer for me. 1) The docs refer to building a "dynamically linked Perl." Shouldn't the Perl be lowercase since we're talking about the interpreter, not the language? +1 2) In the same sentence, it says that a dynamically linked perl will have a libperl.a. Isn't that a libperl.so? You are correct. Could someone describe the differences between libperl.a and libperl.so? libfoo.a is an archive used at linking time - it's completely included in the final application that linked it. libperl.so is a shared library. At the linking time the application only knows which library it wants. Only at the loading time (runtime) that library will be loaded. One of the benefits of using a shared library, is that only it's loaded by one application, any other application using the same library will not need load it, it'll be shared (a service provided by the kernel). In the case of static libfoo.a, it'll be loaded as many times as there are applications that included it, thus consuming more memory. Of course this is not the only benefit of using shared libs. I see that it exists in the apache source directory which makes me think it is used when building modperl. If I'm building mp statically linked, I shouldn't need libperl.a after I've installed, right? Is this the library that has been more appropriately named modperl.a in MP2? Yes, that's the result of the unfortunate naming scheme in Apache 1.3. So you have libperl.(so|a) which is perl, and you have libperl.(so|a) which is modperl. You are certainly looking at the modperl version of libperl.a if you find it in the apache directory. perl's libperl.(so|a) lives under something like 5.8.6/i686-linux/CORE/ And yes, mp2's lib is mod_perl.(so|a). [1] http://perl.apache.org/docs/1.0/guide/install.html#Undefined_reference_to__PL_perl_destruct_level_ -- __ 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 -- Report problems: http://perl.apache.org/bugs/ Mail list info: http://perl.apache.org/maillist/modperl.html List etiquette: http://perl.apache.org/maillist/email-etiquette.html
Re: [mp1] Linking confusion
Thanks for the clear explanation of *.a and *.so files, Stas. I'm starting to grok how it works together. I've attached the diff to the install docs to this message which incorporates some of your notes about .so and .a files. I found this information hard to find while browsing Google, Perlmonks and the modperl docs. I hope that you will include them in some form. Thanks, William -- Knowmad Services Inc. http://www.knowmad.com --- /tmp/install.pod.orig 2004-12-31 10:04:39.0 -0500 +++ /tmp/install.pod.wlm2004-12-31 11:58:30.0 -0500 @@ -681,9 +681,38 @@ mod_perl.o(.text+0x13b): undefined reference to `Perl_av_undef' [more errors snipped] -This happens when you have Perl built statically linked, with no -shared I. Build a dynamically linked Perl (with -I) and the problem will disappear. +This happens when you have perl built statically linked, with no +shared I library. Build a dynamically linked perl (with +I) and the problem will disappear. See the "Building a shared Perl +library" section from the I file that comes with Perl sources. Also +see L<"Chapter 15.4 - Perl Build +Options"|http://modperlbook.org/html/ch15_04.html> from I. + +=head4 Further notes on libperl.(a|so) + +Library files such as I are archives that are used at linking time - +these files are completely included in the final application that linked it. + +I is a shared library. At the linking time the application only +knows which library it wants. Only at the loading time (runtime) that +library will be loaded. + +One of the benefits of using a shared library, is that it's loaded only once, +any application using the same library will not need load it, it'll be shared +(a service provided by the kernel). In the case of static I, it'll be +loaded as many times as there are applications that included it, thus consuming +more memory. Of course this is not the only benefit of using shared libs. + +In mod_perl1, the library file is unfortunately named libperl.(so|a). So you +have libperl.(so|a) which is perl, and you have libperl.(so|a) which is +modperl. You are certainly looking at the modperl version of libperl.a if you +find it in the apache directory. perl's libperl.(so|a) lives under something +like 5.8.6/i686-linux/CORE/. + +Some distributions (notably Debian) have chosen to put libperl.so into the +library path (e.g., /usr/lib) which will cause linking problems when compiling +mod_perl. You should delete or move aside the libperl.so while building +mod_perl or else will likely encounter further errors. =head2 mod_perl Building (make) -- Report problems: http://perl.apache.org/bugs/ Mail list info: http://perl.apache.org/maillist/modperl.html List etiquette: http://perl.apache.org/maillist/email-etiquette.html
Re: [mp1] Linking confusion
William McKee wrote: Thanks for the clear explanation of *.a and *.so files, Stas. I'm starting to grok how it works together. I've attached the diff to the install docs to this message which incorporates some of your notes about .so and .a files. I found this information hard to find while browsing Google, Perlmonks and the modperl docs. I hope that you will include them in some form. Thanks William, I've committed that with a few tweaks. Especially the last para. Please check that it still makes sense. -- __ 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 -- Report problems: http://perl.apache.org/bugs/ Mail list info: http://perl.apache.org/maillist/modperl.html List etiquette: http://perl.apache.org/maillist/email-etiquette.html
Re: [mp1] Linking confusion
On Fri, Dec 31, 2004 at 02:02:59PM -0500, Stas Bekman wrote: > Thanks William, I've committed that with a few tweaks. Especially the last > para. Please check that it still makes sense. Looks fine except for a couple of typos (dangling quote mark and mispelled 'should'). Also, now that I'm a bit more knowledgeable about the subject matter, I was able to find this reference[1] in your docs which I've added to the attached patch. William [1] http://perl.apache.org/docs/1.0/guide/install.html#libperl_so_and_libperl_a -- Knowmad Services Inc. http://www.knowmad.com --- /tmp/install.pod.orig 2004-12-31 15:07:11.0 -0500 +++ /tmp/install.pod.wlm2004-12-31 15:04:56.0 -0500 @@ -688,7 +688,7 @@ that comes with Perl source. =for html Also see http://modperlbook.org/html/ch15_04.html";>"Chapter 15.4 - Perl +href="http://modperlbook.org/html/ch15_04.html";>Chapter 15.4 - Perl Build Options" from http://modperlbook.org/";>Practical mod_perl. @@ -721,16 +721,13 @@ Some distributions (notably Debian) have chosen to put F and F into the global library loader path (e.g., F) which will cause linking problems when compiling mod_perl -(if compiling against static perl), in which case you should move aside +(if compiling against static perl), in which case you hould move aside the F while building mod_perl or else will likely encounter further errors. If building against the dynamic perl's F, you may have similar problems but at startup time. It's the best to get rid of perl that installs its libs into F (or similar) and reinstall a new perl, which puts its library under the perl tree. -=for html Also see http://perl.apache.org/docs/1.0/guide/install.html#libperl_so_and_libperl_a";>libperl.so -and libperl.a. -- Report problems: http://perl.apache.org/bugs/ Mail list info: http://perl.apache.org/maillist/modperl.html List etiquette: http://perl.apache.org/maillist/email-etiquette.html
Re: [mp1] Linking confusion
William McKee wrote: On Fri, Dec 31, 2004 at 02:02:59PM -0500, Stas Bekman wrote: Thanks William, I've committed that with a few tweaks. Especially the last para. Please check that it still makes sense. Looks fine except for a couple of typos (dangling quote mark and mispelled 'should'). Also, now that I'm a bit more knowledgeable about the subject matter, I was able to find this reference[1] in your docs which I've added to the attached patch. Thanks William, committed. For the future please note that internal links are done like so: Also see L. I've adjusted that. also your patch was reverted :) -- __ 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 -- Report problems: http://perl.apache.org/bugs/ Mail list info: http://perl.apache.org/maillist/modperl.html List etiquette: http://perl.apache.org/maillist/email-etiquette.html
Re: [mp1] Linking confusion
On Thu, 30 Dec 2004, William McKee wrote: > Hi folks, > > I'm trying to recompile Perl and Apache/mod_perl on a Debian Sarge > system using the following versions: > > Perl 5.8.6 > Apache 1.3.33 > mod_perl 1.29 > > I am compiling mod_perl statically (using Apachetoolbox) with the > following options: > > APACHE_PREFIX=/usr/local/apache > APACHE_SRC=/usr/local/src/Apachetoolbox-1.5.72/apache_1.3.33/src > SSL_BASE= > APACI_ARGS='--enable-module=rewrite' > DO_HTTPD=1 > USE_APACI=1 > EVERYTHING=1 > Try... in apache directory make distclean ./configure --with-layout=Apache then in mod perl source directory Run: perl Makefile.PL \ APACHE_SRC=/usr/src/apache/src \ DO_HTTPD=1 \ USE_APACI=1 \ PREP_HTTPD=1 \ EVERYTHING=1 \ make make test # broken ?? make install back in apache directory ./configure --with-layout=Apache \ --activate-module=src/modules/perl/libperl.a make make install > During compilation of mod_perl, I was seeing undefined reference errors > which are nicely described on the install page[1]. The prescription > suggests rebuilding Perl with dynamic linking; apparently the version > that's shipped with Debian is not dynamically linked(?). Sounds fine, > but I'm not a C programmer so am not sure exactly what this means. > > >From what I could find reading the INSTALL document that comes with the > Perl source, I need to recompile with the -Duseshrplib compile-time > option. My understanding is that this option will build a libperl.so > file. Is this correct? Am I taking the right action to build a dynamic > Perl? > > With that option, I am able to compile Apache with mod_perl. Now though, > when starting the newly compiled server, I'm receiving relocation errors > which appear to be due to multiple versions of libperl.so/libperl.a (not > sure which). > > While browsing the net for possible solutions, I came across the > troubleshooting document[2]. It seems to say that if 'perl > -V:useshrplib' returns true, then Perl is statically linked. Is this > correct? It seems opposite of what I'd expect from reading the INSTALL > document. > > I'm pretty much at wits end as to why I'm receiving relocation errors. > The best I can figure is some kind of binary incompatibility between the > version of Perl that I've compiled and previously compiled libraries. > I've tried reinstalling some of the XS modules such as DBI which seems > to clear up these errors. > > Any other suggestions or pointers, esp. in light of the differences > between dynamic and static linking and libperl.so/libperl.a, would be > much appreciated. > > > Thanks, > William > > [1] > http://perl.apache.org/docs/1.0/guide/install.html#Undefined_reference_to__PL_perl_destruct_level_ > [2] > http://perl.apache.org/docs/1.0/guide/troubleshooting.html#_relocation_errors__or__undefined_symbol_ > > -- > Knowmad Services Inc. > http://www.knowmad.com > > -- > Report problems: http://perl.apache.org/bugs/ > Mail list info: http://perl.apache.org/maillist/modperl.html > List etiquette: http://perl.apache.org/maillist/email-etiquette.html > -- Report problems: http://perl.apache.org/bugs/ Mail list info: http://perl.apache.org/maillist/modperl.html List etiquette: http://perl.apache.org/maillist/email-etiquette.html