diff mbox

guile-dbi: Use libltdl and prefer GUILE_DBD_PATH.

Message ID 878tush5wx.fsf_-_@member.fsf.org
State New
Headers show

Commit Message

=?utf-8?B?5a6L5paH5q2m?= Sept. 16, 2016, 3:36 a.m. UTC

To reall, curentlly, guile-dbi use dlopen to load its backends.
So, for Guix we have to set LD_LIBRARY_PATH, which is not desired.

> [...]
> (me:)
>> I think it will be great to introduce a new search path (eg: GUILE_DBD_PATH)
>> in addition to LD_LIBRARY_PATH.  Find the absolute so filepath in it
>> ourself, then pass to dlopen.  
> (ludo:)
> Why not, but then it would be redundant with LD_LIBRARY_PATH and
> LTDL_LIBRARY_PATH, which would further complicate the search rules.

Yeah, but I just learn that libltdl has a convenient function to do

So, here are patches for using libltdl and a new search path:
Hope they are obvious :-)
diff mbox


From 1a2fc824fa81324ceb2a310104ea26d0ecd0be4e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=AE=8B=E6=96=87=E6=AD=A6?= <iyzsong@gmail.com>
Date: Fri, 16 Sep 2016 11:13:29 +0800
Subject: [PATCH 3/3] Update documentation for the usage of libltdl.

* doc/guile-dbi.texi: Adjust to the usage of libltdl.
 guile-dbi/doc/guile-dbi.texi | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/guile-dbi/doc/guile-dbi.texi b/guile-dbi/doc/guile-dbi.texi
index 4b0015f..02821c0 100644
--- a/guile-dbi/doc/guile-dbi.texi
+++ b/guile-dbi/doc/guile-dbi.texi
@@ -312,7 +312,7 @@  typedef struct g_db_handle
   SCM constr;
   SCM status;  /* pair: car = error numeric code, cdr = status message */
   SCM closed;  /* boolean, TRUE if closed otherwise FALSE */
-  void* handle;
+  lt_dlhandle handle;
   void* db_info;
   int in_free; /* boolean, used to avoid alloc during garbage collection */
 @} gdbi_db_handle_t;
@@ -327,7 +327,7 @@  backend to the dbi interface library. Its car is returns a status code number,
 cdr is a status return message.
 @item @code{closed} boolean, @code{#t} if the connection is closed, and
 @code{#f} otherwise.
-@item @code{handle} is a void pointer used to point to dynamically
+@item @code{handle} is a lt_dlhandle used to point to dynamically
 loaded back-end library, filled by dbi-open @code{__gdbi_dbd_wrap}.
 Set to ``NULL'' at connection close.
 @item @code{db_info} is a void pointer used by the backends as a data
@@ -364,18 +364,21 @@  Used to expose guile-dbi symbols so, scheme can call them.
 @node How plugins are loaded, How to write plugins, Internal functions, Internals and Database Drivers
 @section How plugins are loaded
-Everything starts at @code{s_make_db_handle}. This function uses dlopen
-to load a shared library named ``libguile-dbd-bcknd.so''. bcknd is the
-first param of dbi-open.
+Everything starts at @code{s_make_db_handle}. This function uses
+libltdl to load a shared library named ``libguile-dbd-bcknd'' with the
+extension of ``.la'', ``.so'', etc. It's searched in the value of
+environment variable @code{GUILE_DBD_PATH} first, then libltdl's
+search patch and system library search path. bcknd is the first param
+of dbi-open.
 If the shared library is successfully loaded, the dbh's field ``handle''
-is filled with the pointer returned by ``dlopen'' and dbh->status is
+is filled with the pointer returned by ``lt_dlopen'' and dbh->status is
 set.  Otherwise the status is set to an error code in the car location,
 while cdr is filled with an error message returned by @code{strerror}.
-Once ``dlopen'' is ok, @code{__gdbi_dbd_wrap} is used to call the backend
+Once ``lt_dlopen'' is ok, @code{__gdbi_dbd_wrap} is used to call the backend
 plugin connect function passing it the connection string. If this
 step also succeeds, then the db should be connected.
 @sp 1