Sorry for the slow reply. I cannot reproduce the problem here on Windows. Your example module loads up fine with all the "use APR" lines uncommented.
The build system (and the means by which APR::* should be loadable without mod_perl.so being loaded) is different on Windows, but I did notice this: ap_strchr seems to only be used in xs\Apache2\Module\Apache2__Module.h but when I run Module.c through the preprocessor I find that ap_strchr gets changed to strchr, and the latter is simply imported from the C run-time library. I guess that's down to this code in httpd.h: #ifdef AP_DEBUG #undef strchr # define strchr(s, c) ap_strchr(s,c) #undef strrchr # define strrchr(s, c) ap_strrchr(s,c) #undef strstr # define strstr(s, c) ap_strstr(s,c) #else /** use this instead of strchr */ # define ap_strchr(s, c) strchr(s, c) /** use this instead of strchr */ # define ap_strchr_c(s, c) strchr(s, c) /** use this instead of strrchr */ # define ap_strrchr(s, c) strrchr(s, c) /** use this instead of strrchr */ # define ap_strrchr_c(s, c) strrchr(s, c) /** use this instead of strrstr*/ # define ap_strstr(s, c) strstr(s, c) /** use this instead of strrstr*/ # define ap_strstr_c(s, c) strstr(s, c) #endif so presumably I do not have AP_DEBUG defined for my build (even though it was a debug build). It looks like AP_DEBUG should not be defined, even in maintainer mode, according to an old Changes entry: remove -DAP_HAVE_DESIGNATED_INITIALIZER and -DAP_DEBUG from MP_MAINTAINER mode to avoid collisions [Joe Orton] but do you somehow have AP_DEBUG defined somewhere, which causes the replacement of ap_strchr with strchr to not happen for you? On 27 March 2015 at 09:14, Jie Gao <j....@sydney.edu.au> wrote: > Hi All > > I had some more time looking into this, and here's some info I can provide. > > -------------------------------------------------------------------------- > > # readelf -a > /usr/local/lib/perl5/site_perl/5.20.2/x86_64-linux-thread-multi/auto/APR/APR.so > ELF Header: > Magic: 7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00 > Class: ELF64 > Data: 2's complement, little endian > Version: 1 (current) > OS/ABI: UNIX - System V > ABI Version: 0 > Type: DYN (Shared object file) > Machine: Advanced Micro Devices X86-64 > Version: 0x1 > Entry point address: 0x1cb0 > Start of program headers: 64 (bytes into file) > Start of section headers: 15480 (bytes into file) > Flags: 0x0 > Size of this header: 64 (bytes) > Size of program headers: 56 (bytes) > Number of program headers: 6 > Size of section headers: 64 (bytes) > Number of section headers: 29 > Section header string table index: 26 > > Section Headers: > [Nr] Name Type Address Offset > Size EntSize Flags Link Info Align > [ 0] NULL 0000000000000000 00000000 > 0000000000000000 0000000000000000 0 0 0 > > [ Lines removed for clarity ] > > Dynamic section at offset 0x36f8 contains 27 entries: > Tag Type Name/Value > 0x0000000000000001 (NEEDED) Shared library: [libaprutil-1.so.0] > 0x0000000000000001 (NEEDED) Shared library: [libexpat.so.1] > 0x0000000000000001 (NEEDED) Shared library: [libapr-1.so.0] > 0x0000000000000001 (NEEDED) Shared library: [librt.so.1] > 0x0000000000000001 (NEEDED) Shared library: [libcrypt.so.1] > 0x0000000000000001 (NEEDED) Shared library: [libpthread.so.0] > 0x0000000000000001 (NEEDED) Shared library: [libc.so.6] > 0x000000000000000f (RPATH) Library rpath: > [/usr/local/httpd-2.4.12/lib:/lib/../lib64] > > [ Lines removed for clarity ] > > Relocation section '.rela.plt' at offset 0x1300 contains 61 entries: > Offset Info Type Sym. Value Sym. Name + > Addend > 000000203930 000200000007 R_X86_64_JUMP_SLO 0000000000000000 Perl_mg_get + 0 > 000000203938 000300000007 R_X86_64_JUMP_SLO 0000000000000000 Perl_sv_setiv + > 0 > 000000203940 000400000007 R_X86_64_JUMP_SLO 0000000000000000 Perl_sv_bless + > 0 > 000000203948 000500000007 R_X86_64_JUMP_SLO 0000000000000000 apr_strerror + 0 > 000000203950 000600000007 R_X86_64_JUMP_SLO 0000000000000000 Perl_require_pv > + 0 > 000000203958 000700000007 R_X86_64_JUMP_SLO 0000000000000000 Perl_warn + 0 > 000000203960 000800000007 R_X86_64_JUMP_SLO 0000000000000000 PerlIO_printf + > 0 > 000000203968 000900000007 R_X86_64_JUMP_SLO 0000000000000000 ap_strchr + 0 > > [ Lines removed for clarity ] > > Symbol table '.dynsym' contains 86 entries: > Num: Value Size Type Bind Vis Ndx Name > 0: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND > 1: 00000000000018b8 0 SECTION LOCAL DEFAULT 9 > 2: 0000000000000000 0 NOTYPE GLOBAL DEFAULT UND Perl_mg_get > 3: 0000000000000000 0 NOTYPE GLOBAL DEFAULT UND Perl_sv_setiv > 4: 0000000000000000 0 NOTYPE GLOBAL DEFAULT UND Perl_sv_bless > 5: 0000000000000000 0 FUNC GLOBAL DEFAULT UND apr_strerror > 6: 0000000000000000 0 NOTYPE GLOBAL DEFAULT UND Perl_require_pv > 7: 0000000000000000 0 NOTYPE GLOBAL DEFAULT UND Perl_warn > 8: 0000000000000000 0 NOTYPE GLOBAL DEFAULT UND PerlIO_printf > 9: 0000000000000000 0 NOTYPE GLOBAL DEFAULT UND ap_strchr > > > [ Lines removed for clarity ] > > Symbol table '.symtab' contains 143 entries: > Num: Value Size Type Bind Vis Ndx Name > 0: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND > 1: 0000000000000190 0 SECTION LOCAL DEFAULT 1 > > [ Lines removed for clarity ] > > 69: 0000000000000000 0 NOTYPE GLOBAL DEFAULT UND ap_strchr > > > [ Lines removed for clarity ] > > -------------------------------------------------------------------------- > > It seems that ap_strchr is not defined anywhere outside httpd, and not in > any of the shared libs. This seems to create the problem when building > a module with mod_perl or outside the mod_perl source. > > I find a somewhat related change by Stas in the past in the Changes file: > > bug reports generating code: [Stas] > - add (apr|apu)-config linking info > - show the full path to the config file used to get the data for the > report > > The APR and APR::* family of modules can now be used without having > to load mod_perl.so. On *nix, this is done by compiling the needed > functions from the appropriate sources used to build mod_perl.so > into APR.so, and then arranging for APR::* to 'use APR ()'. On Win32, > a static library of needed functions is built, and APR/APR::* > then link into this library [Stas, Joe Schaefer, Randy Kobes] > > > I hope this helps resolve this issue in any way. > > > > > > Regards, > > Jie > > * Jie Gao <j....@sydney.edu.au> wrote: > >> Date: Sun, 1 Mar 2015 17:30:45 +1100 >> From: Jie Gao <j....@sydney.edu.au> >> To: "modperl@perl.apache.org" <modperl@perl.apache.org>, mod_perl Dev >> <d...@perl.apache.org> >> Subject: Trunk: APR.so won't load >> User-Agent: Mutt/1.5.21 (2010-09-15) >> >> I have got the source code from the trunk, "make test" mostly passed except >> for >> a threading issue, but I installed it anyway. >> >> Tried to load a test module, but it fails with the following error: >> >> # Error: Can't load >> '/usr/local/lib/perl5/site_perl/5.20.2/x86_64-linux-thread-multi/auto/APR/APR.so' >> for module APR: >> /usr/local/lib/perl5/site_perl/5.20.2/x86_64-linux-thread-multi/auto/APR/APR.so: >> undefined symbol: ap_strchr at >> /usr/local/lib/perl5/5.20.2/x86_64-linux-thread-multi/DynaLoader.pm line 193. >> # at >> /usr/local/lib/perl5/site_perl/5.20.2/x86_64-linux-thread-multi/APR/Table.pm >> line 23. >> >> The following test module loads OK, but fails if I uncomment any of the "use >> APR::*" lines: >> >> #------------------------------------------------------------------------- >> >> package mytest::mytestmodule; >> >> use 5.010001; >> use strict; >> use warnings; >> use Carp; >> $SIG{__DIE__} = \&Carp::confess; >> >> use mod_perl2; >> use Apache2::Connection(); >> use Apache2::RequestRec(); >> use Apache2::SubRequest(); >> use Apache2::Access(); >> use Apache2::RequestUtil(); >> use Apache2::Response(); >> use Apache2::Log(); >> use Apache2::Util(); >> use Apache2::Const ("-compile", qw(:common :methods :satisfy :auth >> MODE_READBYTES)); >> use Apache2::URI(); >> use Apache2::Filter (); >> #use APR::Const ("-compile", qw(:common SUCCESS BLOCK_READ)); >> use IO::Socket qw(SOCK_STREAM); >> use Data::Dumper; >> use AnyDBM_File (); >> #use APR::Brigade (); >> #use APR::Bucket (); >> #use APR::Base64 (); >> #use APR::Table (); >> #use APR::URI (); >> use URI::Escape::XS qw/uri_escape uri_unescape/; >> #use Apache2::MPM(); >> >> our $VERSION = '1.0.1'; >> >> 1; >> __END__ >> >> #------------------------------------------------------------------------- >> >> -------------8<---------- Start Bug Report ------------8<---------- >> 1. Problem Description: >> >> [DESCRIBE THE PROBLEM HERE] >> >> 2. Used Components and their Configuration: >> >> *** mod_perl version 2.000009 >> >> *** using /usr/local/src/mod_perl-2.0/lib/Apache2/BuildConfig.pm >> >> *** Makefile.PL options: >> MP_APR_CONFIG => /usr/local/httpd-2.4.12/bin/apr-1-config >> MP_APR_LIB => aprext >> MP_APXS => /usr/local/httpd-2.4.12/bin/apxs >> MP_COMPAT_1X => 1 >> MP_GENERATE_XS => 1 >> MP_LIBNAME => mod_perl >> MP_USE_DSO => 1 >> >> >> *** /usr/local/httpd-2.4.12/bin/httpd -V >> Server version: Apache/2.4.12 (Unix) >> Server built: Feb 27 2015 20:05:23 >> Server's Module Magic Number: 20120211:41 >> Server loaded: APR 1.5.1, APR-UTIL 1.5.4 >> Compiled using: APR 1.5.1, APR-UTIL 1.5.4 >> Architecture: 64-bit >> Server MPM: worker >> threaded: yes (fixed thread count) >> forked: yes (variable process count) >> Server compiled with.... >> -D APR_HAS_SENDFILE >> -D APR_HAS_MMAP >> -D APR_HAVE_IPV6 (IPv4-mapped addresses enabled) >> -D APR_USE_SYSVSEM_SERIALIZE >> -D APR_USE_PTHREAD_SERIALIZE >> -D SINGLE_LISTEN_UNSERIALIZED_ACCEPT >> -D APR_HAS_OTHER_CHILD >> -D AP_HAVE_RELIABLE_PIPED_LOGS >> -D DYNAMIC_MODULE_LIMIT=256 >> -D HTTPD_ROOT="/usr/local/httpd-2.4.12" >> -D SUEXEC_BIN="/usr/local/httpd-2.4.12/bin/suexec" >> >> >> *** /usr/bin/ldd /usr/local/httpd-2.4.12/bin/httpd >> linux-vdso.so.1 => (0x00007fffcefff000) >> libpcre.so.0 => /lib64/libpcre.so.0 (0x000000327f400000) >> libaprutil-1.so.0 => /usr/local/httpd-2.4.12/lib/libaprutil-1.so.0 >> (0x00007f3ba864c000) >> libexpat.so.1 => /lib64/libexpat.so.1 (0x0000003281c00000) >> libapr-1.so.0 => /usr/local/httpd-2.4.12/lib/libapr-1.so.0 >> (0x00007f3ba8417000) >> librt.so.1 => /lib64/librt.so.1 (0x000000327dc00000) >> libcrypt.so.1 => /lib64/libcrypt.so.1 (0x00000036c2400000) >> libpthread.so.0 => /lib64/libpthread.so.0 (0x000000327d400000) >> libc.so.6 => /lib64/libc.so.6 (0x000000327d000000) >> /lib64/ld-linux-x86-64.so.2 (0x000000327cc00000) >> libfreebl3.so => /lib64/libfreebl3.so (0x00000036c2800000) >> libdl.so.2 => /lib64/libdl.so.2 (0x000000327d800000) >> >> >> *** (apr|apu)-config linking info >> >> -L/usr/local/httpd-2.4.12/lib -laprutil-1 -lexpat >> -L/usr/local/httpd-2.4.12/lib -lapr-1 -lrt -lcrypt -lpthread >> >> >> >> *** /usr/local/bin/perl -V >> Summary of my perl5 (revision 5 version 20 subversion 2) configuration: >> >> Platform: >> osname=linux, osvers=2.6.32-504.8.1.el6.x86_64, >> archname=x86_64-linux-thread-multi >> uname='linux xxx.xxx.xxx.xx 2.6.32-504.8.1.el6.x86_64 #1 smp fri dec 19 >> 12:09:25 est 2014 x86_64 x86_64 x86_64 gnulinux ' >> config_args='-Dusethreads -Dprefix=/usr/local -des -A ccflags=-fPIC' >> hint=recommended, useposix=true, d_sigaction=define >> useithreads=define, usemultiplicity=define >> use64bitint=define, use64bitall=define, uselongdouble=undef >> usemymalloc=n, bincompat5005=undef >> Compiler: >> cc='cc', ccflags ='-D_REENTRANT -D_GNU_SOURCE -fPIC -fwrapv >> -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include >> -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64', >> optimize='-O2', >> cppflags='-D_REENTRANT -D_GNU_SOURCE -fPIC -fwrapv -fno-strict-aliasing >> -pipe -fstack-protector -I/usr/local/include' >> ccversion='', gccversion='4.4.7 20120313 (Red Hat 4.4.7-11)', >> gccosandvers='' >> intsize=4, longsize=8, ptrsize=8, doublesize=8, byteorder=12345678 >> d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16 >> ivtype='long', ivsize=8, nvtype='double', nvsize=8, Off_t='off_t', >> lseeksize=8 >> alignbytes=8, prototype=define >> Linker and Libraries: >> ld='cc', ldflags =' -fstack-protector -L/usr/local/lib' >> libpth=/usr/local/lib /usr/lib /lib/../lib64 /usr/lib/../lib64 /lib >> /lib64 /usr/lib64 /usr/local/lib64 >> libs=-lnsl -lgdbm -ldb -ldl -lm -lcrypt -lutil -lpthread -lc >> perllibs=-lnsl -ldl -lm -lcrypt -lutil -lpthread -lc >> libc=libc-2.12.so, so=so, useshrplib=false, libperl=libperl.a >> gnulibc_version='2.12' >> Dynamic Linking: >> dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E' >> cccdlflags='-fPIC', lddlflags='-shared -O2 -L/usr/local/lib >> -fstack-protector' >> >> >> Characteristics of this binary (from libperl): >> Compile-time options: HAS_TIMES MULTIPLICITY PERLIO_LAYERS >> PERL_DONT_CREATE_GVSV >> PERL_HASH_FUNC_ONE_AT_A_TIME_HARD >> PERL_IMPLICIT_CONTEXT PERL_MALLOC_WRAP >> PERL_NEW_COPY_ON_WRITE PERL_PRESERVE_IVUV >> USE_64_BIT_ALL USE_64_BIT_INT USE_ITHREADS >> USE_LARGE_FILES USE_LOCALE USE_LOCALE_COLLATE >> USE_LOCALE_CTYPE USE_LOCALE_NUMERIC USE_PERLIO >> USE_PERL_ATOF USE_REENTRANT_API >> Built under linux >> Compiled at Feb 25 2015 15:58:55 >> %ENV: >> PERL_LWP_USE_HTTP_10="1" >> @INC: >> /usr/local/lib/perl5/site_perl/5.20.2/x86_64-linux-thread-multi >> /usr/local/lib/perl5/site_perl/5.20.2 >> /usr/local/lib/perl5/5.20.2/x86_64-linux-thread-multi >> /usr/local/lib/perl5/5.20.2 >> /usr/local/lib/perl5/site_perl/5.18.2 >> /usr/local/lib/perl5/site_perl/5.18.0 >> /usr/local/lib/perl5/site_perl >> . >> >> *** Packages of interest status: >> >> Apache2 : - >> Apache2::Request : - >> CGI : 3.65 >> ExtUtils::MakeMaker: 6.98 >> LWP : 5.837 >> mod_perl : - >> mod_perl2 : 2.000009 >> >> >> 3. This is the core dump trace: (if you get a core dump): >> >> [CORE TRACE COMES HERE] >> >> This report was generated by bin/mp2bug on Sun Mar 1 06:21:21 2015 GMT. >> >> -------------8<---------- End Bug Report --------------8<---------- >> >> # ls -al /usr/local/httpd-2.4.12/lib/ >> total 4108 >> drwxr-xr-x. 4 root root 4096 Feb 27 20:07 . >> drwxr-xr-x. 15 root root 4096 Feb 27 20:07 .. >> -rw-r--r--. 1 root root 9262 Feb 27 20:07 apr.exp >> drwxr-xr-x. 2 root root 4096 Feb 27 20:07 apr-util-1 >> -rw-r--r--. 1 root root 5272 Feb 27 20:07 aprutil.exp >> -rw-r--r--. 1 root root 1685642 Feb 27 20:07 libapr-1.a >> -rwxr-xr-x. 1 root root 969 Feb 27 20:07 libapr-1.la >> lrwxrwxrwx. 1 root root 17 Feb 27 20:07 libapr-1.so -> >> libapr-1.so.0.5.1 >> lrwxrwxrwx. 1 root root 17 Feb 27 20:07 libapr-1.so.0 -> >> libapr-1.so.0.5.1 >> -rwxr-xr-x. 1 root root 858051 Feb 27 20:07 libapr-1.so.0.5.1 >> -rw-r--r--. 1 root root 1022024 Feb 27 20:07 libaprutil-1.a >> -rwxr-xr-x. 1 root root 1045 Feb 27 20:07 libaprutil-1.la >> lrwxrwxrwx. 1 root root 21 Feb 27 20:07 libaprutil-1.so -> >> libaprutil-1.so.0.5.4 >> lrwxrwxrwx. 1 root root 21 Feb 27 20:07 libaprutil-1.so.0 -> >> libaprutil-1.so.0.5.4 >> -rwxr-xr-x. 1 root root 589222 Feb 27 20:07 libaprutil-1.so.0.5.4 >> drwxr-xr-x. 2 root root 4096 Feb 27 20:07 pkgconfig >> >> >> >> >> >> >> Regards, >> >> >> Jie. >> >> >>