Subject: postgresql74-lib, perl58{,-thread} and -lpthread
To: None <tech-pkg@NetBSD.org>
From: Markus W Kilbinger <kilbi@rad.rwth-aachen.de>
List: tech-pkg
Date: 07/04/2004 13:36:10
Hi!

I ran into the following problems in compiling perl58{,-thread} and
postgresql74-lib (finally for combined usage with other p5-...
packages like p5-posgresql, p5-DBI or/and p5-DBD-postgresql).

I tested/observed the following on netbsd-2-0 and -current machines.

1. postgres74-lib quite unconditionally (on netbsd-2-0 and -current)
   compiles with (/usr/pkgsrc/databases/postgresql74-lib/Makefile)

     CONFIGURE_ARGS+=        --enable-thread-safety

   , but only on i386 uses -lpthread (as a result of
   pthread.buildlink3?) to create the shared libs.

   On sparc64 and macppc the same pkgsrc source does not create
   postgresql74-lib's dependencies on -lpthread (compilation
   'succeedes' here, though).

   (I didn't test other platforms/machines so far...)

2. Compiling directly postgres74-lib dependent pkgs (like
   postgresql74-client) now succeed on i386 and fail on sparc64 and
   macppc (due to missing -lpthread).

3. Compilation of perl58-thread fails on macppc/netbsd-2-0 with:

     [...]
     gcc -o libperl.so --whole-archive -shared  -Wl,-R/usr/pkg/lib -L/usr/pkg/lib perl.o  gv.o toke.o perly.o op.o pad.o regcomp.o dump.o util.o mg.o reentr.o hv.o av.o run.o pp_hot.o sv.o pp.o scope.o pp_ctl.o pp_sys.o doop.o doio.o regexec.o utf8.o taint.o deb.o universal.o xsutils.o globals.o perlio.o perlapi.o numeric.o locale.o pp_pack.o pp_sort.o  -lm -lcrypt -lpthread
     rm -f opmini.c
     cp op.c opmini.c
     `sh  cflags "optimize='-O2'" opmini.o` -DPIC -fPIC -DPERL_EXTERNAL_GLOB opmini.c
     	       CCCMD =  gcc -DPERL_CORE -c -fno-strict-aliasing -I/usr/pkg/include -O2  -Wall
     rm -f opmini.c
     LD_LIBRARY_PATH=/usr/obj/pkg/lang/perl58-thread/work.powerpc/perl-5.8.4 gcc -Wl,-R/usr/pkg/lib  -L/usr/pkg/lib -o miniperl  miniperlmain.o opmini.o -L. -lperl -lm -lcrypt -lpthread
     LD_LIBRARY_PATH=/usr/obj/pkg/lang/perl58-thread/work.powerpc/perl-5.8.4 ./miniperl -w -Ilib -MExporter -e '<?>' || /usr/bin/make minitest
     Attempt to free unreferenced scalar: SV 0x183aa04.
     *** Error code 1 (ignored)
     LD_LIBRARY_PATH=/usr/obj/pkg/lang/perl58-thread/work.powerpc/perl-5.8.4 ./miniperl -Ilib configpm configpm.tmp
     Use of uninitialized value in null operation at configpm line 666.
     Undefined subroutine &main:: called at configpm line 666.
     *** Error code 255

   ... while perl58 compilation/installation succeeds in macppc (->
   pthread problem on macppc/powerpc?).

4. With perl58{,-thread} you might now run into some indirect
   -lpthread related problem if compiling postgres74-lib _and_
   perl58{,-thread} pkg's:

   Though each perl58 pkg (perl58 _and_ perl58-thread) compiles and
   runs (for itself) fine on i386 and sparc64, its pthread dependency
   interfers with that of secondary p5-... pkgs like p5-postgresql (s.
   a.):

   - On i386 you have to use perl58-thread to make p5-postgresql work
     (indirectly with pthread dependent postgres74-lib). perl58 (w/o
     pthread support) fails using p5-postgresql (panic/core dump).

   - On sparc64 and macppc I had to remove 'CONFIGURE_ARGS+=
     --enable-thread-safety' from postgresql74-lib's Makefile to make
     postgresql74-lib link/install in a further usable (pthread-less)
     way.

Global question: Should pkgsrc itself take care of these (indirect)
pthread dependencies (automatically)?

What is the reason for the platform different postgresql74-lib
configure result (w/ -lpthread on i386, w/o -lpthread on sparc64 and
macppc; see 1.)?

Any hints to solve the problems?

send-pr?

Markus.