[Mesa-dev] [PATCH mesa/mesa] Check for dladdr(), rather than assuming we have it if we have RTLD_DEFAULT
Jon TURNEY
jon.turney at dronecode.org.uk
Thu Apr 17 03:41:51 PDT 2014
On 09/04/2014 14:53, Jonathan Gray wrote:
> On Sun, Apr 06, 2014 at 03:30:43PM +0100, Jon TURNEY wrote:
>> Unfortunately, Cygwin defines RTLD_DEFAULT (for glibc compatibility), but can't
>> provide dladdr(), so add a check for dladdr()
>>
>> ---
>> configure.ac | 6 ++++++
>> src/mesa/drivers/dri/common/megadriver_stub.c | 7 +++----
>> 2 files changed, 9 insertions(+), 4 deletions(-)
>>
>> diff --git a/configure.ac b/configure.ac
>> index 878b24a..bbbed79 100644
>> --- a/configure.ac
>> +++ b/configure.ac
>> @@ -480,6 +480,12 @@ AC_CHECK_FUNC([dlopen], [DEFINES="$DEFINES -DHAVE_DLOPEN"],
>> [DEFINES="$DEFINES -DHAVE_DLOPEN"; DLOPEN_LIBS="-ldl"])])
>> AC_SUBST([DLOPEN_LIBS])
>>
>> +dnl Check if that library also has dladdr
>> +SAVE_LDFLAGS="$LDFLAGS"
>
> The case here is wrong and won't work as intended unless changed to save_LDFLAGS.
Good catch.
> Otherwise the patch seems fine, though it will break the scons build till
> those files are updated?
Updated patch attached with what I think are the appropriate scons runes added
(and sent to the right mailing list this time! :-) ).
-------------- next part --------------
>From e0cd88529e0851aa7b3da59c8c74a3954ff93e7c Mon Sep 17 00:00:00 2001
From: Jon TURNEY <jon.turney at dronecode.org.uk>
Date: Sat, 5 Apr 2014 17:11:45 +0100
Subject: [PATCH] Check for dladdr(), rather than assuming we have it if we
have RTLD_DEFAULT
Unfortunately, Cygwin defines RTLD_DEFAULT (for glibc compatibility), but can't
provide dladdr(), so add a check for dladdr()
Since I don't think scons is ever used to build for Cygwin, just set HAVE_DLADDR
in SConscript, assuming that if we have RTLD_DEFAULT, we have dladdr().
Cc: Jonathan Gray <jsg at jsg.id.au>
Signed-off-by: Jon TURNEY <jon.turney at dronecode.org.uk>
Reviewed-by: Eric Anholt <eric at anholt.net>
---
configure.ac | 6 ++++++
src/mesa/drivers/dri/common/SConscript | 1 +
src/mesa/drivers/dri/common/megadriver_stub.c | 7 +++----
3 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/configure.ac b/configure.ac
index 5c01038..17cc2d1 100644
--- a/configure.ac
+++ b/configure.ac
@@ -480,6 +480,12 @@ AC_CHECK_FUNC([dlopen], [DEFINES="$DEFINES -DHAVE_DLOPEN"],
[DEFINES="$DEFINES -DHAVE_DLOPEN"; DLOPEN_LIBS="-ldl"])])
AC_SUBST([DLOPEN_LIBS])
+dnl Check if that library also has dladdr
+save_LDFLAGS="$LDFLAGS"
+LDFLAGS="$LDFLAGS $DLOPEN_LIBS"
+AC_CHECK_FUNCS([dladdr])
+LDFLAGS="$save_LDFLAGS"
+
case "$host_os" in
darwin*|mingw*)
;;
diff --git a/src/mesa/drivers/dri/common/SConscript b/src/mesa/drivers/dri/common/SConscript
index 8b15532..41f6356 100644
--- a/src/mesa/drivers/dri/common/SConscript
+++ b/src/mesa/drivers/dri/common/SConscript
@@ -30,6 +30,7 @@ drienv.Replace(CPPPATH = [
driswenv = drienv.Clone()
driswenv.Append(CPPDEFINES = [
'__NOT_HAVE_DRM_H',
+ 'HAVE_DLADDR',
])
drienv.PkgUseModules('DRM')
diff --git a/src/mesa/drivers/dri/common/megadriver_stub.c b/src/mesa/drivers/dri/common/megadriver_stub.c
index 7b6d134..d085080 100644
--- a/src/mesa/drivers/dri/common/megadriver_stub.c
+++ b/src/mesa/drivers/dri/common/megadriver_stub.c
@@ -28,10 +28,9 @@
/* We need GNU extensions to dlfcn.h in order to provide backward
* compatibility for the older DRI driver loader mechanism. (dladdr,
- * Dl_info, and RTLD_DEFAULT are only defined when _GNU_SOURCE is
- * defined.)
+ * Dl_info, and RTLD_DEFAULT)
*/
-#ifdef RTLD_DEFAULT
+#if defined(RTLD_DEFAULT) && defined(HAVE_DLADDR)
#define MEGADRIVER_STUB_MAX_EXTENSIONS 10
#define LIB_PATH_SUFFIX "_dri.so"
@@ -148,7 +147,7 @@ megadriver_stub_init(void)
}
}
-#endif /* RTLD_DEFAULT */
+#endif /* RTLD_DEFAULT && HAVE_DLADDR */
static const
__DRIconfig **stub_error_init_screen(__DRIscreen *psp)
--
1.8.5.5
More information about the mesa-dev
mailing list