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:
parent
a5f582f77e
commit
b71c75bdeb
3 changed files with 41 additions and 16 deletions
12
SConstruct
12
SConstruct
|
@ -61,12 +61,16 @@ def call(cmd, silent=False):
|
|||
elif not silent:
|
||||
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'
|
||||
if platform.uname()[0] == "Darwin":
|
||||
cmd = 'glibtool'
|
||||
fallback_version = 2
|
||||
version = None
|
||||
fallback_version = 2
|
||||
pattern = r'(.*[^\S])(\d{1}\.\d+\.?\d?)(.*[^\S])'
|
||||
ret = os.popen('%s --version' % cmd).read()
|
||||
match = re.match(pattern,ret)
|
||||
|
@ -394,7 +398,7 @@ pickle_store = [# Scons internal variables
|
|||
'HAS_CAIRO',
|
||||
'HAS_PYCAIRO',
|
||||
'HAS_LIBXML2',
|
||||
'LIBTOOL_MAJOR_VERSION'
|
||||
'LIBTOOL_SUPPORTS_ADVISE'
|
||||
]
|
||||
|
||||
# Add all other user configurable options to pickle pickle_store
|
||||
|
@ -791,7 +795,7 @@ if not preconfigured:
|
|||
env['PLATFORM'] = platform.uname()[0]
|
||||
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['SKIPPED_DEPS'] = []
|
||||
|
|
|
@ -141,10 +141,13 @@ source = Split(
|
|||
)
|
||||
|
||||
|
||||
# add the datasource_cache.cpp with custom LIBTOOL flag
|
||||
env3 = lib_env.Clone()
|
||||
env3.Append(CXXFLAGS='-DLIBTOOL_MAJOR_VERSION=%s' % env['LIBTOOL_MAJOR_VERSION'])
|
||||
source.insert(0,env3.SharedObject('datasource_cache.cpp'))
|
||||
# add the datasource_cache.cpp with custom LIBTOOL flag if needed
|
||||
if env['LIBTOOL_SUPPORTS_ADVISE']:
|
||||
env3 = lib_env.Clone()
|
||||
env3.Append(CXXFLAGS='-DLIBTOOL_SUPPORTS_ADVISE')
|
||||
source.insert(0,env3.SharedObject('datasource_cache.cpp'))
|
||||
else:
|
||||
source.insert(0,'datasource_cache.cpp')
|
||||
|
||||
if env['JPEG']:
|
||||
source += Split(
|
||||
|
|
|
@ -154,17 +154,35 @@ void datasource_cache::register_datasources(const std::string& str)
|
|||
{
|
||||
try
|
||||
{
|
||||
// clear errors
|
||||
lt_dlerror();
|
||||
#if LIBTOOL_MAJOR_VERSION >= 2
|
||||
// with ltdl >=2 we can actually pass RTDL_GLOBAL to dlopen via the
|
||||
#ifdef LIBTOOL_SUPPORTS_ADVISE
|
||||
// with ltdl >=2.2 we can actually pass RTDL_GLOBAL to dlopen via the
|
||||
// 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
|
||||
// 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_init(&advise);
|
||||
lt_dladvise_global(&advise);
|
||||
lt_dlhandle module = lt_dlopenadvise(itr->string().c_str(), advise);
|
||||
int ret;
|
||||
|
||||
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);
|
||||
#else
|
||||
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))
|
||||
{
|
||||
#ifdef MAPNIK_DEBUG
|
||||
std::clog << "registered datasource : " << ds_name() << std::endl;
|
||||
std::clog << "Datasource loader: registered: " << ds_name() << std::endl;
|
||||
#endif
|
||||
registered_=true;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue