From 3e17a5b047124c46ee45dbd1848127c67e0d62f3 Mon Sep 17 00:00:00 2001 From: Luca Barbieri Date: Mon, 15 Mar 2010 18:36:27 +0100 Subject: dri: test whether the built drivers have unresolved symbols 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 and Michel Daenzer for helping with this. Signed-off-by: Luca Barbieri Acked-by: Brian Paul --- src/mesa/drivers/dri/common/dri_test.c | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 src/mesa/drivers/dri/common/dri_test.c (limited to 'src/mesa/drivers/dri/common/dri_test.c') 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 0000000000..cf59b2b737 --- /dev/null +++ b/src/mesa/drivers/dri/common/dri_test.c @@ -0,0 +1,10 @@ +/* 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; + return (int)(unsigned long)p; +} -- cgit v1.2.3 From 7e246e6aa63979d53731a591f4caee3651c1d96b Mon Sep 17 00:00:00 2001 From: Luca Barbieri Date: Tue, 23 Mar 2010 21:10:07 +0100 Subject: 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(-) (limited to '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 8c16094688..6d9b81aa24 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 cd800e5e01..f19cc039b2 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 cf59b2b737..f55ec6d52b 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; -- cgit v1.2.3 From 5f229547a525554ded621f4f245e22c9090e9205 Mon Sep 17 00:00:00 2001 From: Luca Barbieri Date: Tue, 23 Mar 2010 22:57:25 +0100 Subject: dri: add _glthread_GetID to dri_test.c dummy glapi --- src/mesa/drivers/dri/common/dri_test.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/mesa/drivers/dri/common/dri_test.c') diff --git a/src/mesa/drivers/dri/common/dri_test.c b/src/mesa/drivers/dri/common/dri_test.c index f55ec6d52b..6013c02ac5 100644 --- a/src/mesa/drivers/dri/common/dri_test.c +++ b/src/mesa/drivers/dri/common/dri_test.c @@ -71,6 +71,12 @@ _glapi_get_dispatch_table_size(void) return 0; } +PUBLIC unsigned long +_glthread_GetID(void) +{ + return 0; +} + int main(int argc, char** argv) { void* p = __driDriverExtensions; -- cgit v1.2.3 From 3790199e041236ab8db1effaba2922e10b8b81ac Mon Sep 17 00:00:00 2001 From: Luca Barbieri Date: Tue, 23 Mar 2010 22:59:44 +0100 Subject: dri: fix dri_test.c for non-TLS build _glapi_Context and _glapi_Dispatch have different constness between TLS and non-TLS builds. --- src/mesa/drivers/dri/common/dri_test.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src/mesa/drivers/dri/common/dri_test.c') diff --git a/src/mesa/drivers/dri/common/dri_test.c b/src/mesa/drivers/dri/common/dri_test.c index 6013c02ac5..793f0c37d7 100644 --- a/src/mesa/drivers/dri/common/dri_test.c +++ b/src/mesa/drivers/dri/common/dri_test.c @@ -17,11 +17,16 @@ PUBLIC __thread struct _glapi_table * _glapi_tls_Dispatch PUBLIC __thread void * _glapi_tls_Context __attribute__((tls_model("initial-exec"))); -#endif - PUBLIC const struct _glapi_table *_glapi_Dispatch; PUBLIC const void *_glapi_Context; +#else + +PUBLIC struct _glapi_table *_glapi_Dispatch; +PUBLIC void *_glapi_Context; + +#endif + PUBLIC void _glapi_check_multithread(void) {} -- cgit v1.2.3