From octave-maintainers-request at bevo dot che dot wisc dot edu Thu Jun 28 11:24:50 2001 Subject: gcc-3.0 dynamic loading broken, preliminary patch for feedback From: Mumit Khan To: octave-maintainers at bevo dot che dot wisc dot edu cc: Mumit Khan Date: Thu, 28 Jun 2001 11:24:47 -0500 (CDT) Those of who're trying out Octave CVS with gcc-3.0, you'll notice that dynamic loading is broken, something that I had completely missed. Thanks to Christoph Spiel for pointing out the obvious. I have a preliminary patch that does the right thing depending on GNU C++ ABI (v2 aka old, or v3 aka new, and supposedly forever stable), but I need to write up a autoconf macro for this, and take care of a few other gritty details such as checking for underscore prefix etc. I'm including a temporary patch, but please don't depend on this. This is not meant to go into CVS as is. I'm looking for feedback at this point on how to do this correctly. I have thought about including the GNU C++ demangling code, but that's a bit more work than I'd like to do at this point. You must define a macro GXX_ABI_V3 to enable the new code. To avoid rebuilding everything, you can do the following: $ cd /src $ make CXX='c++ -DGXX_ABI_V3' liboctinterp.so which should build a version that will work. ** ONLY TESTED ON GNU/Linux ** 2001-06-28 Mumit Khan * dynamic-ld.cc (sstream.h): Conditionally include. (octave_dynamic_loader::mangle_name): Handle GNU C++ V3 ABI. Index: dynamic-ld.cc =================================================================== RCS file: /cvs/octave/src/dynamic-ld.cc,v retrieving revision 1.64 diff -u -3 -p -r1.64 dynamic-ld.cc --- dynamic-ld.cc 2000/04/04 06:16:23 1.64 +++ dynamic-ld.cc 2001/06/28 15:38:29 at @ -38,6 +38,10 @@ Software Foundation, 59 Temple Place - S #include "utils.h" #include "variables.h" +#if defined(GXX_ABI_V3) +#include +#endif + // TRUE means we print a warning if reloading a .oct file forces other // functions to be cleared. static bool Vwarn_reload_forces_clear; at @ -311,6 +315,13 @@ octave_dynamic_loader::remove (const std std::string octave_dynamic_loader::mangle_name (const std::string& name) { +#if defined(GXX_ABI_V3) + std::ostringstream mangled_name; + unsigned len = name.length (); + mangled_name << "_Z" << (len + 2) << "FS"; + mangled_name << name << "RK12octave_shlib" << std::ends; + std::string retval = mangled_name.str (); +#else /* ! GCXX_ABI_V3 */ #if defined (CXX_PREPENDS_UNDERSCORE) std::string retval ("_FS"); #else at @ -318,6 +329,7 @@ octave_dynamic_loader::mangle_name (cons #endif retval.append (name); retval.append ("__FRC12octave_shlib"); +#endif /* ! GCXX_ABI_V3 */ return retval; }