Subject: Re: buildlink2 problems with new libogg and libvorbis packages
To: None <tech-pkg@netbsd.org>
From: Greg A. Woods <woods@weird.com>
List: tech-pkg
Date: 10/04/2002 22:37:58
[ On Friday, October 4, 2002 at 14:15:24 (-0700), Johnny C. Lam wrote: ]
> Subject: Re: buildlink2 problems with new libogg and libvorbis packages
>
> On Fri, Oct 04, 2002 at 02:31:34PM -0400, Greg A. Woods wrote:
> > I was attempting to upgrade vorbis-tools and all the libraries it uses,
> > and suddenly found that audio/libvorbis wouldn't build.  It seemed as
> > though the configure sript was insisting on finding a libpthread, so I
> > made the following change:
> 
> No, pthreads isn't used by libvorbis despite that fact that the configure
> script probes for it.  I think this is some other problem cropping up.
> Could you please remove that pth line that you added, build it again,
> and share the following information: LOCALBASE, CC (if set in /etc/mk.conf)
> and the contents of ${BUILDLINK_DIR}/.wrapper.log?

OK, first I realized I should be including mk/pthread.buildlink2.mk, and
that worked too, but you're right it's not necessary.

The problem really is that -Wl,-R${PREFIX}/lib isn't passed in LDFLAGS
to configure, and so since I don't have /usr/pkg/lib in /etc/ld.so.conf
the test actually fails to run, thus the "libogg.4so not found".

I fixed this with the following patch:

Index: Makefile
===================================================================
RCS file: /cvs/master/m-NetBSD/main/pkgsrc/audio/libvorbis/Makefile,v
retrieving revision 1.21
diff -c -c -r1.21 Makefile
*** Makefile	2 Oct 2002 19:45:55 -0000	1.21
--- Makefile	5 Oct 2002 02:13:28 -0000
***************
*** 14,19 ****
--- 14,21 ----
  USE_LIBTOOL=		YES
  LIBTOOL_OVERRIDE=	${WRKSRC}/libtool
  
+ LDFLAGS+=		-Wl,-R${PREFIX}/lib
+ 
  PLIST_SUBST+=		DISTNAME=${DISTNAME}
  
  .include "../../audio/libogg/buildlink2.mk"


Here's the (wrapped) compilation line from work/.buildlink/.wrapper.log
after the above fix for the conftest that previously failed:

/usr/bin/cc -o conftest -O20 -D__NO_MATH_INLINES -fsigned-char
	-I/var/package-obj/audio/libvorbis/work/.buildlink/include -O2 -g -pipe
	-I/var/package-obj/audio/libvorbis/work/.buildlink/include
	-DUSE_MEMORY_H
	-I/var/package-obj/audio/libvorbis/work/.buildlink/include
	-I/var/package-obj/audio/libvorbis/work/.buildlink/include
	-L/var/package-obj/audio/libvorbis/work/.buildlink/lib
	-Wl,-R/usr/pkg/lib
	-L/var/package-obj/audio/libvorbis/work/.buildlink/lib
	-Wl,-R/usr/pkg/lib conftest.c -lm
	-L/var/package-obj/audio/libvorbis/work/.buildlink/lib -logg


Without the above patch there's no "-Wl,-R" in that line at all, even
though with the patch there are two identical instances:

/usr/bin/cc -o conftest -O20 -D__NO_MATH_INLINES -fsigned-char
	-I/var/package-obj/audio/libvorbis/work/.buildlink/include -O2 -g -pipe
	-I/var/package-obj/audio/libvorbis/work/.buildlink/include
	-DUSE_MEMORY_H
	-I/var/package-obj/audio/libvorbis/work/.buildlink/include
	-I/var/package-obj/audio/libvorbis/work/.buildlink/include
	-L/var/package-obj/audio/libvorbis/work/.buildlink/lib
	-L/var/package-obj/audio/libvorbis/work/.buildlink/lib conftest.c -lm
	-L/var/package-obj/audio/libvorbis/work/.buildlink/lib -logg

Oddly I've had to make similar hacks to several other packages in order
to get the "build-host" programs they build to use during subsequent
build (or configure, as in the above) steps to work.  Eg.  also in
editors/emacs-21 it can't find X11 libraries when it tries to run tadmin
in the build tree.

It obviously cannot work without telling ld.so where to find libogg.so,
just as the error message from ./configure suggests:

	checking for Ogg... no
	*** Could not run Ogg test program, checking why...
	*** The test program compiled, but did not run. This usually means
	*** that the run-time linker is not finding Ogg or finding the wrong
	*** version of Ogg. If it is not finding Ogg, you'll need to set your
	*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point
	*** to the installed location  Also, make sure you have run ldconfig if that
	*** is required on your system
	***
	*** If you have an old version installed, it is best to remove it, although
	*** you may also be able to get things to work by modifying LD_LIBRARY_PATH
	configure: error: must have Ogg installed!
	*** Error code 1
	
	Stop.
	make: stopped in /work/woods/m-NetBSD-pkgsrc/audio/libvorbis
	*** Error code 1

I'm about 99% certain that none of my other local patches are
interfering, though perhaps it's some secondary effect that's not
immediately obvious to my eyes.  If someone could tell me how this is
suupposed to work (i.e. where exactly does buildlink2 supply the
appropriate -Wl,-R flag(s) so that intermediate built targets that use
non-standard libraries can work "in situ", then maybe I could trace back
to where the problems begin in my environment.

-- 
								Greg A. Woods

+1 416 218-0098;            <g.a.woods@ieee.org>;           <woods@robohack.ca>
Planix, Inc. <woods@planix.com>; VE3TCP; Secrets of the Weird <woods@weird.com>