Mesa (master): dri: make unresolved symbol test link work even without a libGL.so

Luca Barbieri lb at kemper.freedesktop.org
Tue Mar 23 20:32:39 UTC 2010


Module: Mesa
Branch: master
Commit: 7e246e6aa63979d53731a591f4caee3651c1d96b
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=7e246e6aa63979d53731a591f4caee3651c1d96b

Author: Luca Barbieri <luca at luca-barbieri.com>
Date:   Tue Mar 23 21:10:07 2010 +0100

dri: make unresolved symbol test link work even without a libGL.so

Currently the test link uses -lGL to define the glapi symbols.

This makes it impossible to build DRI drivers on systems without
Mesa installed and without building the libGL from the Mesa tree
first.

Some automated build systems trigger this problem.

This commit removes -lGL and instead adds a dummy implementation of
glapi to dri_test.c

This, along with Kristian's commit, should fix all known regressions
due to the addition of unresolved symbol checking.

---

 src/gallium/winsys/drm/Makefile.template |    2 +-
 src/mesa/drivers/dri/Makefile.template   |    2 +-
 src/mesa/drivers/dri/common/dri_test.c   |   68 ++++++++++++++++++++++++++++++
 3 files changed, 70 insertions(+), 2 deletions(-)

diff --git a/src/gallium/winsys/drm/Makefile.template b/src/gallium/winsys/drm/Makefile.template
index 8c16094..6d9b81a 100644
--- a/src/gallium/winsys/drm/Makefile.template
+++ b/src/gallium/winsys/drm/Makefile.template
@@ -69,7 +69,7 @@ $(LIBNAME): $(OBJECTS) $(MESA_MODULES) $(PIPE_DRIVERS) Makefile \
 		$(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 $(DRI_LIB_DEPS) -L$(TOP)/lib -lGL
+	$(CC) -o $@.test $(TOP)/src/mesa/drivers/dri/common/dri_test.o $@.tmp $(DRI_LIB_DEPS)
 	@rm -f $@.test
 	mv -f $@.tmp $@
 
diff --git a/src/mesa/drivers/dri/Makefile.template b/src/mesa/drivers/dri/Makefile.template
index cd800e5..f19cc03 100644
--- a/src/mesa/drivers/dri/Makefile.template
+++ b/src/mesa/drivers/dri/Makefile.template
@@ -54,7 +54,7 @@ $(LIBNAME): $(OBJECTS) $(MESA_MODULES) $(EXTRA_MODULES) Makefile \
 		$(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 $(DRI_LIB_DEPS) -L$(TOP)/lib -lGL
+	$(CC) -o $@.test $(TOP)/src/mesa/drivers/dri/common/dri_test.o $@.tmp $(DRI_LIB_DEPS)
 	@rm -f $@.test
 	mv -f $@.tmp $@
 
diff --git a/src/mesa/drivers/dri/common/dri_test.c b/src/mesa/drivers/dri/common/dri_test.c
index cf59b2b..f55ec6d 100644
--- a/src/mesa/drivers/dri/common/dri_test.c
+++ b/src/mesa/drivers/dri/common/dri_test.c
@@ -1,8 +1,76 @@
+#include "main/glheader.h"
+#include "main/compiler.h"
+#include "glapi/glapi.h"
+
 /* 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[];
 
+/* provide glapi symbols */
+
+#if defined(GLX_USE_TLS)
+
+PUBLIC __thread struct _glapi_table * _glapi_tls_Dispatch
+    __attribute__((tls_model("initial-exec")));
+
+PUBLIC __thread void * _glapi_tls_Context
+    __attribute__((tls_model("initial-exec")));
+
+#endif
+
+PUBLIC const struct _glapi_table *_glapi_Dispatch;
+PUBLIC const void *_glapi_Context;
+
+PUBLIC void
+_glapi_check_multithread(void)
+{}
+
+PUBLIC void
+_glapi_set_context(void *context)
+{}
+
+PUBLIC void *
+_glapi_get_context(void)
+{
+	return 0;
+}
+
+PUBLIC void
+_glapi_set_dispatch(struct _glapi_table *dispatch)
+{}
+
+PUBLIC struct _glapi_table *
+_glapi_get_dispatch(void)
+{
+	return 0;
+}
+
+PUBLIC int
+_glapi_add_dispatch( const char * const * function_names,
+		     const char * parameter_signature )
+{
+	return 0;
+}
+
+PUBLIC GLint
+_glapi_get_proc_offset(const char *funcName)
+{
+	return 0;
+}
+
+PUBLIC _glapi_proc
+_glapi_get_proc_address(const char *funcName)
+{
+	return 0;
+}
+
+PUBLIC GLuint
+_glapi_get_dispatch_table_size(void)
+{
+	return 0;
+}
+
 int main(int argc, char** argv)
 {
    void* p = __driDriverExtensions;




More information about the mesa-commit mailing list