Subject: RPATH and XFree86-libs package
To: None <tech-pkg@netbsd.org>
From: Jeremy C. Reed <reed@reedmedia.net>
List: tech-pkg
Date: 05/26/2004 15:55:29
On some (maybe all) platforms, the XFree86-libs install has some libraries
that can't find their needed shared objects. For example:

$ ldd /usr/X11R6/lib/libXext.so.6
        libX11.so.6 => not found

reed@puget:/usr/pkgsrc/x11$ !ldd
ldd /usr/X11R6/lib/libXmu.so
        libXt.so.6 => not found
        libSM.so.6 => not found
        libICE.so.6 => not found
        libXext.so.6 => not found


I was able to work-around this problem under Linux with by adding to the
files/host.def:

#define SharedLibraryLoadFlags -shared -Wl,@RPATH_FLAG@$(USRLIBDIRPATH)

And in the Makefile.common post-extract sed replacement add:
-e "s|@RPATH_FLAG@|${RPATH_FLAG}|g" \


Then it was fine:

reed@puget:/usr/pkgsrc/x11/XFree86-libs$ ldd /usr/X11R6/lib/libXmu.so
        libXt.so.6 => /usr/X11R6/lib/libXt.so.6 (0x40018000)
        libSM.so.6 => /usr/X11R6/lib/libSM.so.6 (0x40071000)
        libICE.so.6 => /usr/X11R6/lib/libICE.so.6 (0x4007b000)
        libXext.so.6 => /usr/X11R6/lib/libXext.so.6 (0x40097000)
        libX11.so.6 => /usr/X11R6/lib/libX11.so.6 (0x400a8000)
        libc.so.6 => /usr/lib/libc.so.6 (0x40192000)
        libdl.so.2 => /usr/lib/libdl.so.2 (0x402a3000)
        /usr/lib/ld-linux.so.2 => /usr/lib/ld-linux.so.2 (0x80000000)

Looking at xc/config/cf/FreeBSD.cf, I see:

#ifndef LibraryRpathLoadFlags
# if UseRpath
#  if UseElfFormat
#   define LibraryRpathLoadFlags        -rpath $(USRLIBDIRPATH)
#  else
#   define LibraryRpathLoadFlags        -R $(USRLIBDIRPATH)
...

and then:

#ifndef SharedLibraryLoadFlags
# if UseElfFormat
#  define SharedLibraryLoadFlags        -shared LibraryRpathLoadFlags

But the Linux setup use EXTRA_LOAD_FLAGS as set by ExtraLoadFlags which is
defined with RpathLoadFlags which is -Wl,-rpath,$(USRLIBDIRPATH) when
UseRpath is YES. (If I understand this.)

I tried defining:
#define UseRpath YES
#define RpathLoadFlags -Wl,-rpath,$(USRLIBDIRPATH)

But that didn't work for me. (It was not used.)

Does anyone have any comments on the SharedLibraryLoadFlags above?

Will that be okay for other platforms?

Can anyone test? (I can provide patch if desired.)

 Jeremy C. Reed

 	  	 	 technical support & remote administration
	  	 	 http://www.pugetsoundtechnology.com/