libdrm: fix static build (tests/nouveau)
PATCH v2 1/1 libdrm: fix static build (tests/nouveau)
Some toolchains (e.g. br-arm-cortex-m4-full) provide empty libdl libraries. This fools the dynamic/static detection for tests/nouveau, so explicit check for library type instead.
Fixes [1]:
../tests/nouveau/threaded.c:24:10: fatal error: dlfcn.h: No such file or directory
[1] http://autobuild.buildroot.net/results/d15/d15ed604756cac4e4a87afca61b7a4778f293baf
---
Changes v1 -> v2:
- patch updated
--- ...shared-library-support-detection-for.patch | 52 +++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 package/libdrm/0005-meson-fix-libdl-shared-library-support-detection-for.patch
package/libdrm/0005-meson-fix-libdl-shared-library-support-detection-for.patch new file +52 -0
@@ -0,0 +1,52 @@ +From 8705f6908f5de494dcdb13323b8c15fb9b09acf1 Mon Sep 17 00:00:00 2001 +From: Peter Seiderer <[email protected]> +Date: Sat, 10 Aug 2019 01:06:13 +0200 +Subject: [PATCH] meson: fix libdl/shared library support detection for nouveau + tests + +Some toolchains (e.g. br-arm-cortex-m4-full) provide empty libdl +libraries. This fools the dynamic/static detection for tests/nouveau, +so explicit check for library type instead. + +Fixes: + + ../tests/nouveau/threaded.c:24:10: fatal error: dlfcn.h: No such file or directory + +Signed-off-by: Peter Seiderer <[email protected]> +--- + meson.build | 1 + + tests/meson.build | 5 ++++- + 2 files changed, 5 insertions(+), 1 deletion(-) + +diff --git a/meson.build b/meson.build +index adaaf22..b78d9e5 100644 +--- a/meson.build ++++ b/meson.build +@@ -168,6 +168,7 @@ endif + + # Among others FreeBSD does not have a separate dl library. + if not cc.has_function('dlsym') ++ # fooled in case empty libdl provided, e.g. toolchain br-arm-cortex-m4-full + dep_dl = cc.find_library('dl', required : with_nouveau) + else + dep_dl = [] +diff --git a/tests/meson.build b/tests/meson.build +index 6c8ddd9..f7cb5f0 100644 +--- a/tests/meson.build ++++ b/tests/meson.build +@@ -44,8 +44,11 @@ endif + if with_etnaviv + subdir('etnaviv') + endif ++lib_type = get_option('default_library') + if with_nouveau +- subdir('nouveau') ++ if lib_type != 'static' ++ subdir('nouveau') ++ endif + endif + + drmsl = executable( +-- +2.22.0 +
--
2.22.0
PATCH v2 1/1 libdrm: fix static build (tests/nouveau)
Hello Peter,
Thanks for working on this topic. Some questions/comments below.
Quoted 7 lines · On Sat, 10 Aug 2019 01:19:08 +0200 Peter Seiderer <[email protected]> wrote:
Some toolchains (e.g. br-arm-cortex-m4-full) provide empty libdl libraries. This fools the dynamic/static detection for tests/nouveau, so explicit check for library type instead.
Fixes [1]:
../tests/nouveau/threaded.c:24:10: fatal error:dlfcn.h: No such file or directory
So the error is about not finding a header.
Quoted 4 lines
+ # Among others FreeBSD does not have a separate dl library.
+ if notcc.has_function('dlsym')
++ # fooled in case empty libdl provided, e.g. toolchain br-arm-cortex-m4-full
+dep_dl=cc.find_library('dl', required : with_nouveau)
What about instead checking for the availability of dlfcn.h, in addition to checking the availability of the libdl library ?
Also, how come the cc.has_function('dlsym') checks returns true ? I guess in a static library configuration, this check should return false.
Also, could you drop the references to br-arm-cortex-m4-full, so that the patch can be upstreamed ?
BTW, with uClibc-ng and musl, the libdl library is always empty, regardless of whether it has dynamic library support or not. Here is a uClibc-ng toolchain, with dynamic library support:
-rw-r--r-- 1 thomas thomas 8 1 ao?t 22:23 output/host/usr/arm-buildroot-linux-uclibcgnueabi/sysroot/usr/lib/libdl.a
Indeed, since quite a while, uClibc-ng is all in a single file, libc.so, including symbols that used to be in libdl.so:
$ ./output/host/bin/arm-linux-readelf -s output/host/usr/arm-buildroot-linux-uclibcgnueabi/sysroot/lib/libc.so.1 | grep "FUNC.*dlsym" 884: 00058fe0 468 FUNC GLOBAL DEFAULT 8 dlsym 7356: 00058fe0 468 FUNC GLOBAL DEFAULT 8 dlsym
Best regards,
Thomas
Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin Embedded Linux and Kernel engineering https://bootlin.com
PATCH v2 1/1 libdrm: fix static build (tests/nouveau)
Hello Thomas,
Quoted 11 lines · Thomas Petazzoni
Hello Peter,
Thanks for working on this topic. Some questions/comments below.
Quoted 4 lines · On Sat, 10 Aug 2019 01:19:08 +0200 Peter Seiderer <[email protected]> wrote:
Some toolchains (e.g. br-arm-cortex-m4-full) provide empty libdl libraries. This fools the dynamic/static detection for tests/nouveau, so explicit check for library type instead.
Quoted 5 lines
Quoted 3 lines
Fixes [1]:
../tests/nouveau/threaded.c:24:10: fatal error:dlfcn.h: No such file or directorySo the error is about not finding a header.
Yes, follow up failure from misdetecting dynamic library support...
Quoted 8 lines
Quoted 5 lines
+ # Among others FreeBSD does not have a separate dl library.
+ if notcc.has_function('dlsym')
++ # fooled in case empty libdl provided, e.g. toolchain br-arm-cortex-m4-full
+dep_dl=cc.find_library('dl', required : with_nouveau)What about instead checking for the availability of
dlfcn.h, in addition to checking the availability of the libdl library ?
Yes, this would be the better/perfect solution (but did not yet find the time to impelment it)....
Quoted 3 lines
Also, how come the
cc.has_function('dlsym')checks returns true ? I guess in a static library configuration, this check should return false.
Mind the 'not' in the if statement, if no 'native' cc support for dlsym check for libdl as indication for dynamic library support...
Quoted 3 lines
Also, could you drop the references to br-arm-cortex-m4-full, so that the patch can be upstreamed ?
Yes will do (as soon as I find a suitable timeslot ;-) )...
The librm/meson patch series is re-suggested upsteam, see [1], [2], [3]...
Regards,
Peter
[1] https://lists.freedesktop.org/archives/dri-devel/2019-August/230489.html
[2] https://lists.freedesktop.org/archives/dri-devel/2019-August/230490.html
[3] https://lists.freedesktop.org/archives/dri-devel/2019-August/230491.html
Quoted 17 lines
BTW, with uClibc-ng and musl, the libdl library is always empty, regardless of whether it has dynamic library support or not. Here is a uClibc-ng toolchain, with dynamic library support:
-rw-r--r-- 1 thomas thomas 8 1 ao?t 22:23 output/host/usr/arm-buildroot-linux-uclibcgnueabi/sysroot/usr/lib/libdl.a
Indeed, since quite a while, uClibc-ng is all in a single file, libc.so, including symbols that used to be in libdl.so:
$ ./output/host/bin/arm-linux-readelf -s output/host/usr/arm-buildroot-linux-uclibcgnueabi/sysroot/lib/libc.so.1 | grep "FUNC.*dlsym" 884: 00058fe0 468 FUNC GLOBAL DEFAULT 8 dlsym 7356: 00058fe0 468 FUNC GLOBAL DEFAULT 8 dlsymBest regards,
Thomas