octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Problem with an oct file that won't load


From: John W. Eaton
Subject: Re: Problem with an oct file that won't load
Date: Thu, 23 Oct 2008 13:03:42 -0400

On 23-Oct-2008, John W. Eaton wrote:

| On 23-Oct-2008, John Swensen wrote:
| 
| | While that is true that it shouldn't have -L, I still get the exact  
| | same error after removing the -L.
| 
| I think if you want more information about the error, you'll need to
| modify Octave so that it calls the appropriate routines to get better
| information about the failure.  After doing a little searching, it
| seems that the way to do this is to call NSLinkEditError if
| NSLinkModule returns handle == 0 (and the option
| NSLINKMODULE_OPTION_RETURN_ON_ERROR is set).  But I don't know where
| to find full documentation about how to use these examples, and since
| I don't have an OS X system, I would rather leave this task up to
| someone else.
| 
| BTW, when searching for clues, I also found that OS X apparently has a
| dlopen interface now, so perhaps we should just be using that if it is
| available?  That doesn't necessarily solve your problem, but it could
| allow us to eventually simplify the Octave sources by eliminating the
| direct use of the NSLinkModule interface.

I'll also add that on a system that uses dlopen, you can do something
like

   LD_BIND_NOW="yes" octave

and then Octave will give better diagnostics for .oct files that
reference undefined symbols.  Or it should, though the quality of
diagnostics is probably system dependent.  At the very least it should
not exit immediately when the undefined symbol is referenced, because
the LD_BIND_NOW option should cause dlopen to return a failure code if
there are unresolved symbols.  Since this seems like better default
behavior, I checked in the following change.

jwe

# HG changeset patch
# User John W. Eaton <address@hidden>
# Date 1224781246 14400
# Node ID 095b3e4d64e99065bba14a14fcf849cc68a14fff
# Parent  5a2e45facabe173e147283bbd2cca0864349e4e0
oct-shlib.cc: use RTLD_NOW option for dlopen

diff --git a/liboctave/ChangeLog b/liboctave/ChangeLog
--- a/liboctave/ChangeLog
+++ b/liboctave/ChangeLog
@@ -1,3 +1,8 @@
+2008-10-23  John W. Eaton  <address@hidden>
+
+       * oct-shlib.cc (octave_dlopen_shlib::open): Use RTLD_NOW instead
+       of RTLD_LAZY.
+
 2008-10-12  Jaroslav Hajek <address@hidden>
 
        * CSparse.cc (ComplexMatrix::expm): Improve inverse preconditioning
diff --git a/liboctave/oct-shlib.cc b/liboctave/oct-shlib.cc
--- a/liboctave/oct-shlib.cc
+++ b/liboctave/oct-shlib.cc
@@ -243,8 +243,12 @@
 
       int flags = 0;
 
-#if defined (RTLD_LAZY)
-      flags |= RTLD_LAZY;
+      // Use RTLD_NOW to resolve all symbols before dlopen returns.
+      // By using this option, dlopen will detect errors and Octave
+      // won't exit if there are unresolved symbols in the file we are
+      // loading, and we may even get a useful diagnostic.
+#if defined (RTLD_NOW)
+      flags |= RTLD_NOW;
 #endif
 
 #if defined (RTLD_GLOBAL)

reply via email to

[Prev in Thread] Current Thread [Next in Thread]