Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 22 Feb 2005 22:08:05 +0100
From:      Felix =?ISO-8859-1?Q?K=FChling?= <fxkuehl@gmx.de>
To:        Mikhail Teterin <Mikhail.Teterin@murex.com>
Cc:        acardenas@bsdperu.org
Subject:   Re: ports/76257: nvidia_driver breaks xorg-clients build
Message-ID:  <1109106485.6323.13.camel@trabant>
In-Reply-To: <200502221710.j1MH9a5v009787@harik.murex.com>
References:  <200502220508.j1M58MAN094098@corbulon.video-collage.com> <1109078622.3320.2.camel@trabant> <200502221710.j1MH9a5v009787@harik.murex.com>

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

--=-F9sq+sEiv6SE5fhEmTl3
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

Am Dienstag, den 22.02.2005, 12:19 -0500 schrieb Mikhail Teterin:
> > It was already changed in my patch. Do you have any better suggestions?
>=20
> Not really...
>=20
> > As I mentioned in an earlier mail, the GLX headers from Xorg don't seem
> > to define the ARB function any more.
>=20
> 6.8.1 still has it. Not sure about 6.8.2. In that case, the following lit=
tle=20
> hunk:
>=20
> 	+#ifndef GLX_VERSION_1_4
> 	+#	define glXGetProcAddress	glXGetProcAddressARB
> 	+#endif
>=20
> seems less intrusive :-) The utility will still not *work* when compiled=20
> against GLX-1.3 headers, but it will *compile*.
>=20
> To allow for -lGL to be interchangible post-build, however, it may be req=
uired=20
> to make a dlopen/dlsym search for the glXGetProcAddress symbol at run-tim=
e.
>=20
> Would you like a patch? It will, unavoidably, system-specific, but should=
 work=20
> on most (all?) systems supported by Xorg. You will also be able to remove=
=20
> this hack in a few years, when all available GLX implementations are=20
> upgraded. Yours,
>=20
> 	-mi

The attached patch (undo my other patch first) implements something like
this without actually loading libGL dynamically. It uses
dlopen(NULL, ...) to get a handle for the main program (including
libGL). I hope this is portable. Does this work for you?

Note that the patch also changes the Imakefile. In xc/programs/xdriinfo
run this to update the Makefile:

        make Makefile
        make depend

Then recompile xdriinfo as usual.


--=20
| Felix K=FChling <fxkuehl@gmx.de>                     http://fxk.de.vu |
| PGP Fingerprint: 6A3C 9566 5B30 DDED 73C3  B152 151C 5CC1 D888 E595 |

--=-F9sq+sEiv6SE5fhEmTl3
Content-Disposition: attachment; filename=xdriinfo_oldglx2.diff
Content-Type: text/x-patch; name=xdriinfo_oldglx2.diff; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

--- ./xdriinfo.c.~1.1.3.1.~	2004-06-16 11:27:39.000000000 +0200
+++ ./xdriinfo.c	2005-02-22 21:58:15.000000000 +0100
@@ -27,10 +27,13 @@
 #include <stdio.h>
 #include <unistd.h>
 #include <string.h>
+#include <dlfcn.h>
 
+typedef void (* glXGetProcAddress_t (const GLubyte *procname)) (void);
 typedef const char * glXGetScreenDriver_t (Display *dpy, int scrNum);
 typedef const char * glXGetDriverConfig_t (const char *driverName);
 
+glXGetProcAddress_t *GetProcAddress;
 glXGetScreenDriver_t *GetScreenDriver;
 glXGetDriverConfig_t *GetDriverConfig;
 
@@ -56,11 +59,33 @@
     enum INFO_FUNC func = LIST;
     char *funcArg = NULL;
     char *dpyName = NULL;
+    void *dlHandle;
 
-    GetScreenDriver = (glXGetScreenDriver_t *)glXGetProcAddress ("glXGetScreenDriver");
-    GetDriverConfig = (glXGetDriverConfig_t *)glXGetProcAddress ("glXGetDriverConfig");
+    /* dlopen (NULL, ...) returns a handle for the main program. */
+    dlHandle = dlopen (NULL, RTLD_NOW | RTLD_GLOBAL);
+    if (dlHandle == NULL) {
+	/* should never happen */
+	fprintf (stderr, "Can't dlopen main program.\n");
+	return 1;
+    }
+    GetProcAddress = (glXGetProcAddress_t *)
+	dlsym (dlHandle, "glXGetProcAddress");
+    if (GetProcAddress == NULL)
+	GetProcAddress = (glXGetProcAddress_t *)
+	    dlsym (dlHandle, "glXGetProcAddressARB");
+    if (GetProcAddress == NULL) {
+	fprintf (stderr, "Couldn't find glXGetProcAddress[ARB].\n");
+	return 1;
+    }
+    dlclose (dlHandle);
+
+    GetScreenDriver = (glXGetScreenDriver_t *)
+	GetProcAddress ((GLubyte*)"glXGetScreenDriver");
+    GetDriverConfig = (glXGetDriverConfig_t *)
+	GetProcAddress ((GLubyte*)"glXGetDriverConfig");
     if (!GetScreenDriver || !GetDriverConfig) {
-	fprintf (stderr, "libGL is too old.\n");
+	fprintf (stderr, "libGL does not support the "
+		 "DRI configuration infrastructure.\n");
 	return 1;
     }
 
--- ./Imakefile.~1.2.~	2004-08-28 15:44:48.000000000 +0200
+++ ./Imakefile	2005-02-22 21:50:48.000000000 +0100
@@ -4,7 +4,7 @@
 
             SRCS = xdriinfo.c
             OBJS = xdriinfo.o
- LOCAL_LIBRARIES = $(GLXLIB) $(XLIB) 
+ LOCAL_LIBRARIES = $(GLXLIB) $(XLIB) -ldl
          DEPLIBS =
 
 AllTarget(ProgramTargetName(xdriinfo))

--=-F9sq+sEiv6SE5fhEmTl3--



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