clang++ caught bug - we need to first call lt_dlinit. Also add better error output based on returns from dladvise functions and simplify compile flag

This commit is contained in:
Dane Springmeyer 2010-11-19 23:02:58 +00:00
parent a5f582f77e
commit b71c75bdeb
3 changed files with 41 additions and 16 deletions

View file

@ -61,12 +61,16 @@ def call(cmd, silent=False):
elif not silent: elif not silent:
color_print(1,'Problem encounted with SCons scripts, please post bug report to: http://trac.mapnik.org\nError was: %s' % stderr) color_print(1,'Problem encounted with SCons scripts, please post bug report to: http://trac.mapnik.org\nError was: %s' % stderr)
def get_libtool_version(): def get_libtool_major_version():
"""libtool >= 2.1b support lt_dlopenadvise and the previous
release appears to be 1.9f (based on NEWS) so checking for
>= 2 seems adequate.
"""
cmd = 'libtool' cmd = 'libtool'
if platform.uname()[0] == "Darwin": if platform.uname()[0] == "Darwin":
cmd = 'glibtool' cmd = 'glibtool'
fallback_version = 2
version = None version = None
fallback_version = 2
pattern = r'(.*[^\S])(\d{1}\.\d+\.?\d?)(.*[^\S])' pattern = r'(.*[^\S])(\d{1}\.\d+\.?\d?)(.*[^\S])'
ret = os.popen('%s --version' % cmd).read() ret = os.popen('%s --version' % cmd).read()
match = re.match(pattern,ret) match = re.match(pattern,ret)
@ -394,7 +398,7 @@ pickle_store = [# Scons internal variables
'HAS_CAIRO', 'HAS_CAIRO',
'HAS_PYCAIRO', 'HAS_PYCAIRO',
'HAS_LIBXML2', 'HAS_LIBXML2',
'LIBTOOL_MAJOR_VERSION' 'LIBTOOL_SUPPORTS_ADVISE'
] ]
# Add all other user configurable options to pickle pickle_store # Add all other user configurable options to pickle pickle_store
@ -791,7 +795,7 @@ if not preconfigured:
env['PLATFORM'] = platform.uname()[0] env['PLATFORM'] = platform.uname()[0]
color_print(4,"Configuring on %s in *%s*..." % (env['PLATFORM'],mode)) color_print(4,"Configuring on %s in *%s*..." % (env['PLATFORM'],mode))
env['LIBTOOL_MAJOR_VERSION'] = get_libtool_version() env['LIBTOOL_SUPPORTS_ADVISE'] = get_libtool_major_version() >= 2
env['MISSING_DEPS'] = [] env['MISSING_DEPS'] = []
env['SKIPPED_DEPS'] = [] env['SKIPPED_DEPS'] = []

View file

@ -141,10 +141,13 @@ source = Split(
) )
# add the datasource_cache.cpp with custom LIBTOOL flag # add the datasource_cache.cpp with custom LIBTOOL flag if needed
env3 = lib_env.Clone() if env['LIBTOOL_SUPPORTS_ADVISE']:
env3.Append(CXXFLAGS='-DLIBTOOL_MAJOR_VERSION=%s' % env['LIBTOOL_MAJOR_VERSION']) env3 = lib_env.Clone()
source.insert(0,env3.SharedObject('datasource_cache.cpp')) env3.Append(CXXFLAGS='-DLIBTOOL_SUPPORTS_ADVISE')
source.insert(0,env3.SharedObject('datasource_cache.cpp'))
else:
source.insert(0,'datasource_cache.cpp')
if env['JPEG']: if env['JPEG']:
source += Split( source += Split(

View file

@ -154,17 +154,35 @@ void datasource_cache::register_datasources(const std::string& str)
{ {
try try
{ {
// clear errors #ifdef LIBTOOL_SUPPORTS_ADVISE
lt_dlerror(); // with ltdl >=2.2 we can actually pass RTDL_GLOBAL to dlopen via the
#if LIBTOOL_MAJOR_VERSION >= 2
// with ltdl >=2 we can actually pass RTDL_GLOBAL to dlopen via the
// ltdl advise trick which is required on linux unless plugins are directly // ltdl advise trick which is required on linux unless plugins are directly
// linked to libmapnik (and deps) at build time. The only other approach is to // linked to libmapnik (and deps) at build time. The only other approach is to
// set the dlopen flags in the calling process (like in the python bindings) // set the dlopen flags in the calling process (like in the python bindings)
// clear errors
lt_dlerror();
lt_dlhandle module = 0;
lt_dladvise advise; lt_dladvise advise;
lt_dladvise_init(&advise); int ret;
lt_dladvise_global(&advise);
lt_dlhandle module = lt_dlopenadvise(itr->string().c_str(), advise); ret = lt_dlinit();
if (ret != 0) {
std::clog << "Datasource loader: could not intialize dynamic loading: " << lt_dlerror() << "\n";
}
ret = lt_dladvise_init(&advise);
if (ret != 0) {
std::clog << "Datasource loader: could not intialize dynamic loading: " << lt_dlerror() << "\n";
}
ret = lt_dladvise_global(&advise);
if (ret != 0) {
std::clog << "Datasource loader: could not intialize dynamic loading of global symbols: " << lt_dlerror() << "\n";
}
module = lt_dlopenadvise (itr->string().c_str(), advise);
lt_dladvise_destroy(&advise); lt_dladvise_destroy(&advise);
#else #else
lt_dlhandle module = lt_dlopen(itr->string().c_str()); lt_dlhandle module = lt_dlopen(itr->string().c_str());
@ -176,7 +194,7 @@ void datasource_cache::register_datasources(const std::string& str)
if (ds_name && insert(ds_name(),module)) if (ds_name && insert(ds_name(),module))
{ {
#ifdef MAPNIK_DEBUG #ifdef MAPNIK_DEBUG
std::clog << "registered datasource : " << ds_name() << std::endl; std::clog << "Datasource loader: registered: " << ds_name() << std::endl;
#endif #endif
registered_=true; registered_=true;
} }