Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 21 Aug 1999 13:44:27 -0400 (EDT)
From:      aa8vb@ipass.net
To:        FreeBSD-gnats-submit@freebsd.org
Subject:   ports/13295: Mesa-3.0 needs patch to fix ELF dependent '.so' loading
Message-ID:  <199908211744.NAA19571@stealth.ipass.net.>

next in thread | raw e-mail | index | archive | help

>Number:         13295
>Category:       ports
>Synopsis:       Mesa-3.0 needs patch to fix ELF dependent '.so' loading
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-ports
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sat Aug 21 10:50:02 PDT 1999
>Closed-Date:
>Last-Modified:
>Originator:     Randall Hopper
>Release:        FreeBSD 3.2-RELEASE i386
>Organization:
self
>Environment:

	Stock 3.2-RELEASE.  Mesa-3.0 built from ports.

>Description:

	Dynamic loading of libMesaGL.so into an interpreter such as Python
        does not work because libMesaGL.so.14 does not store libXext and 
        libX11 as dependent ("NEEDED") .so's in the dynamic section.

        A Python port I'm about to submit needs .so loading to function 
        correctly, which is why I dug into this.  (Getting ready for
        XFree86 4.0, DRI, and HW-accel 3D -- whoohoo!)

        In short, here's the problem:

          > cd /usr/X11R6/lib

          > objdump -T libMesaGL.so.14 | grep XFreePixmap
            00000000      DF *UND*  0000005c XFreePixmap

          > objdump -x libMesaGL.so.14 | egrep 'NEEDED|RPATH'
          >

        As you can see, it depends on libX11, but has no NEEDED reference
        to libX11.  However libXt, which also depends on libX11, has its
        libX11 relationship stored correctly:

          > objdump -x libXt.so.6 | egrep 'NEEDED|RPATH'
            NEEDED      libX11.so.6
            NEEDED      libSM.so.6
            NEEDED      libICE.so.6
            RPATH       /usr/X11R6/lib


>How-To-Repeat:

	In specific, build/install Mesa from ports and run the above
	command.  You'll get the same results.

	Alternatively, build the PyOpenGL port (which I'm fixing to submit)
	and then run "import OpenGL.GL" inside the interpreter.  You'll see
	it fail to dynamically load libMesaGL.so because XFreePixmap is
	undefined, and libMesaGL.so doesn't register libX11.so as a
	dependency.


>Fix:
	
	Please replace the Mesa-3.0 "mklib.freebsd" patch (patch/patch-ac)
        with the attached patch.  It incorporates the existing changes with
        the few lines needed to link Xext and X11 when building
        libMesaGL.so.  Note that mklib.irix6-n32 contains analogous logic
        for the same reason.

# This is a shell archive.  Save it in a file, remove anything before
# this line, and then unpack it by entering "sh file".  Note, it may
# create directories; files and directories will be owned by you and
# have default permissions.
#
# This archive contains:
#
#	patch-ac
#
echo x - patch-ac
sed 's/^X//' >patch-ac << 'END-of-patch-ac'
X--- mklib.freebsd.orig	Tue Oct 21 19:34:34 1997
X+++ mklib.freebsd	Sat Aug 21 13:15:31 1999
X@@ -34,7 +34,11 @@
X 
X #--platform------------------------------------------------------------
X 
X-VERSION=$MAJOR.$MINOR
X+if [ "${PORTOBJFORMAT}" = "elf" ]; then
X+    VERSION=$MAJOR
X+else
X+    VERSION=$MAJOR.$MINOR
X+fi
X 
X BASENAME=`echo ${LIBRARY} | sed "s/\.a//g"`
X SHLIB=${BASENAME}.so.${VERSION}
X@@ -44,6 +48,28 @@
X 
X ar cq ${STLIB} ${OBJECTS}
X ranlib ${STLIB}
X-ld -Bshareable -o ${SHLIB} ${OBJECTS}
X 
X-mv ${SHLIB} ../lib
X+
X+if [ "${PORTOBJFORMAT}" = "elf" ]; then
X+
X+    # This is a bit of a kludge, but... (see mklib.irix6-n32)
X+    if test ${BASENAME} = "libMesaGL" ; then
X+        # Add Xext & X11 to MesaGL.so's NEEDED .so list.
X+        # If MesaGL is dloaded, the dependent .so's must be dloaded as well.  
X+        # Dependent .so info is necessary when Mesa is loaded dynamically 
X+        # by extensible interpreters (e.g. Python) where the interpreter 
X+        # can't/shouldn't know all the dependent libraries that an 
X+        # interpreter extension module may need to link with.  Shared libs 
X+        # should be built to indicate what they need via NEEDED and RPATH. 
X+        # For example, see:     objdump -x libXt.so.6 | egrep 'NEEDED|RPATH'
X+	OBJECTS="${OBJECTS} -L${X11BASE}/lib -rpath ${X11BASE}/lib"
X+	OBJECTS="${OBJECTS} -lXext -lX11 -lm"
X+    fi
X+
X+    ld -shared -soname ${SHLIB} -o ${SHLIB} ${OBJECTS}
X+    ln -sf ${SHLIB} ${BASENAME}.so
X+    mv ${SHLIB} ${BASENAME}.so ../lib
X+else
X+    ld -Bshareable -o ${SHLIB} ${OBJECTS}
X+    mv ${SHLIB} ../lib
X+fi
END-of-patch-ac
exit




>Release-Note:
>Audit-Trail:
>Unformatted:


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-ports" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199908211744.NAA19571>