|
1 Correctly load guile extensions from /usr/lib or /usr/lib/[amd64,sparcv9] |
|
2 depending upon whether we are running the 32-bit or 64-bit version of guile. |
|
3 |
|
4 Changes taken from the guile version 2.X source code and wedged back into |
|
5 the legacy guile version 1.8.X that we have in Userland/Solaris. |
|
6 |
|
7 --- guile-1.8.6/libguile/Makefile.in.orig 2016-06-03 14:20:49.001764609 -0700 |
|
8 +++ guile-1.8.6/libguile/Makefile.in 2016-06-03 14:29:55.294211108 -0700 |
|
9 @@ -2020,6 +2020,8 @@ |
|
10 @echo '#define SCM_PKGDATA_DIR "$(pkgdatadir)"' >> libpath.tmp |
|
11 @echo '#define SCM_LIBRARY_DIR "$(pkgdatadir)/$(GUILE_EFFECTIVE_VERSION)"'>>libpath.tmp |
|
12 @echo '#define SCM_SITE_DIR "$(pkgdatadir)/site"' >> libpath.tmp |
|
13 + @echo '#define SCM_LIB_DIR "$(libdir)"' >> libpath.tmp |
|
14 + @echo '#define SCM_EXTENSIONS_DIR "$(pkglibdir)/$(GUILE_EFFECTIVE_VERSION)/extensions"' >> libpath.tmp |
|
15 @echo '#define SCM_BUILD_INFO { \' >> libpath.tmp |
|
16 @echo ' { "srcdir", "'"`cd @srcdir@; pwd`"'" }, \' >> libpath.tmp |
|
17 @echo ' { "top_srcdir", "@top_srcdir_absolute@" }, \' >> libpath.tmp |
|
18 --- guile-1.8.6/libguile/dynl.c.orig 2016-06-03 14:11:35.474790875 -0700 |
|
19 +++ guile-1.8.6/libguile/dynl.c 2016-06-03 14:11:15.816688183 -0700 |
|
20 @@ -47,6 +47,7 @@ |
|
21 #include <string.h> |
|
22 |
|
23 #include "libguile/_scm.h" |
|
24 +#include "libguile/libpath.h" |
|
25 #include "libguile/dynl.h" |
|
26 #include "libguile/smob.h" |
|
27 #include "libguile/keywords.h" |
|
28 @@ -70,12 +71,76 @@ |
|
29 */ |
|
30 /* njrev: not threadsafe, protection needed as described above */ |
|
31 |
|
32 +/* LT_PATH_SEP-separated extension library search path, searched last */ |
|
33 +static char *system_extensions_path; |
|
34 + |
|
35 static void * |
|
36 sysdep_dynl_link (const char *fname, const char *subr) |
|
37 { |
|
38 lt_dlhandle handle; |
|
39 - handle = lt_dlopenext (fname); |
|
40 - if (NULL == handle) |
|
41 + if (fname == NULL) |
|
42 + /* Return a handle for the program as a whole. */ |
|
43 + handle = lt_dlopen (NULL); |
|
44 + else |
|
45 + { |
|
46 + handle = lt_dlopenext (fname); |
|
47 + |
|
48 + if (handle == NULL |
|
49 +#ifdef LT_DIRSEP_CHAR |
|
50 + && strchr (fname, LT_DIRSEP_CHAR) == NULL |
|
51 +#endif |
|
52 + && strchr (fname, '/') == NULL) |
|
53 + { |
|
54 + /* FNAME contains no directory separators and was not in the |
|
55 + usual library search paths, so now we search for it in |
|
56 + SYSTEM_EXTENSIONS_PATH. */ |
|
57 + char *fname_attempt |
|
58 + = scm_gc_malloc (strlen (system_extensions_path) |
|
59 + + strlen (fname) + 2, |
|
60 + "dynl fname_attempt"); |
|
61 + char *path; /* remaining path to search */ |
|
62 + char *end; /* end of current path component */ |
|
63 + char *s; |
|
64 + |
|
65 + /* Iterate over the components of SYSTEM_EXTENSIONS_PATH */ |
|
66 + for (path = system_extensions_path; |
|
67 + *path != '\0'; |
|
68 + path = (*end == '\0') ? end : (end + 1)) |
|
69 + { |
|
70 + /* Find end of path component */ |
|
71 + end = strchr (path, LT_PATHSEP_CHAR); |
|
72 + if (end == NULL) |
|
73 + end = strchr (path, '\0'); |
|
74 + |
|
75 + /* Skip empty path components */ |
|
76 + if (path == end) |
|
77 + continue; |
|
78 + |
|
79 + /* Construct FNAME_ATTEMPT, starting with path component */ |
|
80 + s = fname_attempt; |
|
81 + memcpy (s, path, end - path); |
|
82 + s += end - path; |
|
83 + |
|
84 + /* Append directory separator, but avoid duplicates */ |
|
85 + if (s[-1] != '/' |
|
86 +#ifdef LT_DIRSEP_CHAR |
|
87 + && s[-1] != LT_DIRSEP_CHAR |
|
88 +#endif |
|
89 + ) |
|
90 + *s++ = '/'; |
|
91 + |
|
92 + /* Finally, append FNAME (including null terminator) */ |
|
93 + strcpy (s, fname); |
|
94 + |
|
95 + /* Try to load it, and terminate the search if successful */ |
|
96 + handle = lt_dlopenext (fname_attempt); |
|
97 + if (handle != NULL) |
|
98 + break; |
|
99 + } |
|
100 + } |
|
101 + } |
|
102 + |
|
103 + if (handle == NULL) |
|
104 { |
|
105 SCM fn; |
|
106 SCM msg; |
|
107 @@ -112,7 +177,37 @@ |
|
108 static void |
|
109 sysdep_dynl_init () |
|
110 { |
|
111 + char *env; |
|
112 + |
|
113 lt_dlinit (); |
|
114 + |
|
115 + /* Initialize 'system_extensions_path' from |
|
116 + $GUILE_SYSTEM_EXTENSIONS_PATH, or if that's not set: |
|
117 + <SCM_LIB_DIR> <LT_PATHSEP_CHAR> <SCM_EXTENSIONS_DIR>. |
|
118 + |
|
119 + 'lt_dladdsearchdir' can't be used because it is searched before |
|
120 + the system-dependent search path, which is the one 'libtool |
|
121 + --mode=execute -dlopen' fiddles with (info "(libtool) Libltdl |
|
122 + Interface"). See |
|
123 + <http://lists.gnu.org/archive/html/guile-devel/2010-11/msg00095.html>. |
|
124 + |
|
125 + The environment variables $LTDL_LIBRARY_PATH and $LD_LIBRARY_PATH |
|
126 + can't be used because they would be propagated to subprocesses |
|
127 + which may cause problems for other programs. See |
|
128 + <http://lists.gnu.org/archive/html/guile-devel/2012-09/msg00037.html> */ |
|
129 + |
|
130 + env = getenv ("GUILE_SYSTEM_EXTENSIONS_PATH"); |
|
131 + if (env) |
|
132 + system_extensions_path = env; |
|
133 + else |
|
134 + { |
|
135 + system_extensions_path |
|
136 + = scm_gc_malloc (strlen (SCM_LIB_DIR) |
|
137 + + strlen (SCM_EXTENSIONS_DIR) + 2, |
|
138 + "system_extensions_path"); |
|
139 + sprintf (system_extensions_path, "%s%c%s", |
|
140 + SCM_LIB_DIR, LT_PATHSEP_CHAR, SCM_EXTENSIONS_DIR); |
|
141 + } |
|
142 } |
|
143 |
|
144 scm_t_bits scm_tc16_dynamic_obj; |