This is a different approach to solving this problem that the patch
I previously posted, and unlike that, should not cause any problems.

Right now undefined symbols in DRI drivers will still allow the
build to succeed.

As a result, people modifying drivers they cannot test risk creating
unloadable drivers with no easy way of automatically avoiding it.

For instance, the modifications to nv50 for context transfers caused
such an issue recently.

Unfortunately, just adding -Wl,--no-undefined doesn't work, because
the DRI drivers depend on glapi symbols, but do not depend on
libGL.so.1

Adding -lGL is not the correct solution since DRI drivers are not loaded
just by libGL, but also by X and possibly by other clients.

So, this patch simply tries to build an executable linked to the DRI
driver and to libGL.
If the DRI driver contains any undefined symbols not satisfied by its
dependencies or by libGL, this will fail.

This solution does not alter the built drivers, and does not significantly
slow down the build process.

All classic DRI drivers as well as all the Gallium drivers with configure
options compiled successfully with this change.

Thanks to Xavier Chantry <chantry.xav...@gmail.com> and
Michel Daenzer <mic...@daenzer.net> for helping with this.
---
 src/gallium/winsys/drm/Makefile.template |    7 +++++--
 src/mesa/drivers/dri/Makefile.template   |    7 +++++--
 src/mesa/drivers/dri/common/dri_test.c   |   11 +++++++++++
 3 files changed, 21 insertions(+), 4 deletions(-)
 create mode 100644 src/mesa/drivers/dri/common/dri_test.c

diff --git a/src/gallium/winsys/drm/Makefile.template 
b/src/gallium/winsys/drm/Makefile.template
index f4cc0de..9f984f1 100644
--- a/src/gallium/winsys/drm/Makefile.template
+++ b/src/gallium/winsys/drm/Makefile.template
@@ -64,11 +64,14 @@ SHARED_INCLUDES = \
 default: depend symlinks $(TOP)/$(LIB_DIR)/gallium/$(LIBNAME)
 
 $(LIBNAME): $(OBJECTS) $(MESA_MODULES) $(PIPE_DRIVERS) Makefile \
-               $(TOP)/src/mesa/drivers/dri/Makefile.template
-       $(MKLIB) -o $@ -noprefix -linker '$(CC)' -ldflags '$(LDFLAGS)' \
+               $(TOP)/src/mesa/drivers/dri/Makefile.template 
$(TOP)/src/mesa/drivers/dri/common/dri_test.o
+       $(MKLIB) -o $...@.tmp -noprefix -linker '$(CC)' -ldflags '$(LDFLAGS)' \
                $(OBJECTS) $(PIPE_DRIVERS) \
                 -Wl,--start-group $(MESA_MODULES) -Wl,--end-group \
                  $(DRI_LIB_DEPS) $(DRIVER_EXTRAS)
+       $(CC) -o $...@.test $(TOP)/src/mesa/drivers/dri/common/dri_test.o 
$...@.tmp -L$(TOP)/lib -lGL
+       @rm -f $...@.test
+       mv $...@.tmp $@
 
 $(TOP)/$(LIB_DIR)/gallium:
        mkdir -p $@
diff --git a/src/mesa/drivers/dri/Makefile.template 
b/src/mesa/drivers/dri/Makefile.template
index a0c25d2..2b7634b 100644
--- a/src/mesa/drivers/dri/Makefile.template
+++ b/src/mesa/drivers/dri/Makefile.template
@@ -51,9 +51,12 @@ lib: symlinks subdirs depend
        @$(MAKE) $(LIBNAME) $(TOP)/$(LIB_DIR)/$(LIBNAME)
 
 $(LIBNAME): $(OBJECTS) $(MESA_MODULES) $(EXTRA_MODULES) Makefile \
-               $(TOP)/src/mesa/drivers/dri/Makefile.template
-       $(MKLIB) -o $@ -noprefix -linker '$(CC)' -ldflags '$(LDFLAGS)' \
+               $(TOP)/src/mesa/drivers/dri/Makefile.template 
$(TOP)/src/mesa/drivers/dri/common/dri_test.o
+       $(MKLIB) -o $...@.tmp -noprefix -linker '$(CC)' -ldflags '$(LDFLAGS)' \
                $(OBJECTS) $(MESA_MODULES) $(EXTRA_MODULES) $(DRI_LIB_DEPS)
+       $(CC) -o $...@.test $(TOP)/src/mesa/drivers/dri/common/dri_test.o 
$...@.tmp -L$(TOP)/lib -lGL
+       @rm -f $...@.test
+       mv $...@.tmp $@
 
 
 $(TOP)/$(LIB_DIR)/$(LIBNAME): $(LIBNAME)
diff --git a/src/mesa/drivers/dri/common/dri_test.c 
b/src/mesa/drivers/dri/common/dri_test.c
new file mode 100644
index 0000000..3f3dd35
--- /dev/null
+++ b/src/mesa/drivers/dri/common/dri_test.c
@@ -0,0 +1,11 @@
+/* This is just supposed to make sure we get a reference to
+   the driver entry symbol that the compiler doesn't optimize away */
+
+extern char __driDriverExtensions[];
+
+int main(int argc, char** argv)
+{
+   void* p = __driDriverExtensions;
+   /* avoid possible pointer size mismatch warnings */
+   return *(int*)&p;
+}
-- 
1.6.3.3


------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Mesa3d-dev mailing list
Mesa3d-dev@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mesa3d-dev

Reply via email to