[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [xml] makefile for libxml2 wrong with threads



On Wed, Jun 26, 2002 at 03:10:24PM +0100, Gary Pennington - Solaris Kernel Technology wrote:
> There is a problem in the libxml2 build environment if you are building the
> library with support for threads.
> 
> If you examine the makefile, the target which generates the library, i.e. the
> libxml2.la target, (through libtool) should have $(THREAD_CFLAGS) and
> $(THREAD_LIBS) added to it.
> 
> I guess that they should be actually added to a subsidiary target, maybe
> libxml2_la_LDFLAGS or LIBS. I don't know...
> 
> If you don't have these flags, then the library isn't properly linked with the
> required thread libraries and this can cause problems for applications which
> then aren't explicitly linked with libpthread themselves.
> 
> (This is a particular problem for single threaded applications which are using
> a libxml2.so which was built with threading enabled. This class of application
> will cause libxml2.so to dump core.)
> 
> So, although I can hack a makefile to make it right, I'm not at all familiar
> in the use of autoconf and friends, so I can't work out what actually needs
> to be done to get the build environment corrected.
> 
> Is there anyone out there who can sort this out and submit a patch to the
> list to the appropriate file which implements the change I've described
> above?
> 
> Gary

Well, I didn't see any answers to this - so I've taken a stab at the required
patch myself.

I believe that it's Makefile.am which needs to changes as follows:

bash-2.03# diff -c Makefile.am ~garypen/orig/libxml2-2.4.22/Makefile.am*** Makefile.am	Fri May 24 03:35:13 2002
--- /home/garypen/LIB_XML_BUILD/libxml2-2.4.22/Makefile.am	Mon Jul  1 15:06:29 2002
***************
*** 13,19 ****
  bin_SCRIPTS=xml2-config
  
  lib_LTLIBRARIES = libxml2.la
! libxml2_la_LIBADD = @Z_LIBS@ $(ICONV_LIBS) -lm
  
  libxml2_la_LDFLAGS = -version-info @LIBXML_VERSION_INFO@
  
--- 13,19 ----
  bin_SCRIPTS=xml2-config
  
  lib_LTLIBRARIES = libxml2.la
! libxml2_la_LIBADD = @THREAD_LIBS@ @Z_LIBS@ $(ICONV_LIBS) -lm
  
  libxml2_la_LDFLAGS = -version-info @LIBXML_VERSION_INFO@
  
This change correctly introduces -lpthread onto the link line in the makefile
for the libxml2.so target.

I've tested the patch using --with-threads, in which case I get the appropriate
linkage for libxml2.so to -lpthread, and without it, in which case -lpthread
is correctly ommited from the link step.

Gary

Attachment: pgpJBIeyYAZP2.pgp
Description: PGP signature



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]