Merge pull request #268619 from tweag/lib-descriptions
[NixPkgs.git] / pkgs / development / libraries / libepoxy / libgl-path.patch
blob8f38ee27174b6ab9db36ec0e8f29a55446c691f8
1 diff --git a/src/dispatch_common.c b/src/dispatch_common.c
2 index b3e4f5f..303e8f5 100644
3 --- a/src/dispatch_common.c
4 +++ b/src/dispatch_common.c
5 @@ -310,6 +310,19 @@ get_dlopen_handle(void **handle, const char *lib_name, bool exit_on_fail, bool l
6 flags |= RTLD_NOLOAD;
8 *handle = dlopen(lib_name, flags);
9 +#ifdef LIBGL_PATH
10 + if (!*handle) {
11 + char pathbuf[sizeof(LIBGL_PATH) + 1 + 1024 + 1];
12 + int l = snprintf(pathbuf, sizeof(pathbuf), "%s/%s", LIBGL_PATH, lib_name);
13 + if (l < 0 || l >= sizeof(pathbuf)) {
14 + // This really shouldn't happen
15 + fprintf(stderr, "Error prefixing library pathname\n");
16 + exit(1);
17 + }
18 + *handle = dlopen(pathbuf, flags);
19 + }
20 +#endif
22 if (!*handle) {
23 if (exit_on_fail) {
24 fprintf(stderr, "Couldn't open %s: %s\n", lib_name, dlerror());