8
0
mirror of https://github.com/FirebirdSQL/firebird.git synced 2025-01-22 16:43:03 +01:00

Frontported additional patch for #6027 : Installation of Firebird 3.0.3 on SLES 12 SP3 fails with ''Could not find acceptable ICU library".

This commit is contained in:
hvlad 2021-08-10 00:08:35 +03:00
parent 4f75d290eb
commit 0b37b2321b
4 changed files with 140 additions and 4 deletions

View File

@ -982,6 +982,18 @@ case $host in
;;
esac
AC_CHECK_FUNCS(poll)
AC_CHECK_FUNCS(dlinfo)
if test "$ac_cv_func_dlinfo" = "yes"; then
AC_MSG_CHECKING(if dlinfo supports RTLD_DI_LINKMAP)
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#define _GNU_SOURCE
#include <link.h>
#include <dlfcn.h>]], [[struct link_map info; dlinfo(0, RTLD_DI_LINKMAP, &info);]])],[AC_DEFINE(HAVE_RTLD_DI_LINKMAP, [1], [Linkmap info support]) AC_MSG_RESULT(yes)],[AC_MSG_RESULT(no)])
AC_MSG_CHECKING(if dlinfo supports RTLD_DI_ORIGIN)
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#define _GNU_SOURCE
#include <link.h>
#include <dlfcn.h>]], [[char info[256]; dlinfo(0, RTLD_DI_ORIGIN, info);]])],[AC_DEFINE(HAVE_RTLD_DI_ORIGIN, [1], [Origin info support]) AC_MSG_RESULT(yes)],[AC_MSG_RESULT(no)])
fi
dnl Check for time function
AC_SEARCH_LIBS(clock_gettime, rt)

View File

@ -72,6 +72,10 @@ public:
const Firebird::PathName fileName;
#ifdef LINUX
virtual bool getRealPath(Firebird::PathName& realPath) = 0;
#endif
protected:
/// The constructor is protected so normal code can't allocate instances
/// of the class, but the class itself is still able to be subclassed.

View File

@ -38,6 +38,7 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <link.h>
#include <dlfcn.h>
/// This is the POSIX (dlopen) implementation of the mod_loader abstraction.
@ -53,6 +54,8 @@ public:
~DlfcnModule();
void* findSymbol(ISC_STATUS*, const Firebird::string&);
bool getRealPath(Firebird::PathName& realPath);
private:
void* module;
};
@ -202,3 +205,39 @@ void* DlfcnModule::findSymbol(ISC_STATUS* status, const Firebird::string& symNam
return result;
}
bool DlfcnModule::getRealPath(Firebird::PathName& realPath)
{
#ifdef HAVE_DLINFO
char b[PATH_MAX];
#ifdef HAVE_RTLD_DI_ORIGIN
if (dlinfo(module, RTLD_DI_ORIGIN, b) == 0)
{
realPath = b;
realPath += '/';
realPath += fileName;
if (realpath(realPath.c_str(), b))
{
realPath = b;
return true;
}
}
#endif
#ifdef HAVE_RTLD_DI_LINKMAP
struct link_map* lm;
if (dlinfo(module, RTLD_DI_LINKMAP, &lm) == 0)
{
if (realpath(lm->l_name, b))
{
realPath = b;
return true;
}
}
#endif
#endif
return false;
}

View File

@ -194,7 +194,7 @@ void BaseICU::initialize(ModuleLoader::Module* module)
namespace Jrd {
static ModuleLoader::Module* formatAndLoad(const char* templateName,
int majorVersion, int minorVersion);
int& majorVersion, int& minorVersion);
// encapsulate ICU collations libraries
@ -312,7 +312,7 @@ private:
ImplementConversionICU(int aMajorVersion, int aMinorVersion)
: BaseICU(aMajorVersion, aMinorVersion)
{
module = formatAndLoad(ucTemplate, aMajorVersion, aMinorVersion);
module = formatAndLoad(ucTemplate, this->majorVersion, this->minorVersion);
if (!module)
return;
@ -343,6 +343,15 @@ private:
if (!inModule)
return;
if (aMajorVersion != this->majorVersion || aMinorVersion != this->minorVersion)
{
string err;
err.printf("Wrong version of IN icu module: loaded %d.%d, expected %d.%d",
aMajorVersion, aMinorVersion, this->majorVersion, this->minorVersion);
(Arg::Gds(isc_random) << Arg::Str(err)).raise();
}
getEntryPoint("ucal_getTZDataVersion", inModule, ucalGetTZDataVersion);
getEntryPoint("ucal_getDefaultTimeZone", inModule, ucalGetDefaultTimeZone);
getEntryPoint("ucal_open", inModule, ucalOpen);
@ -413,9 +422,47 @@ static const char* const COLL_30_VERSION = "41.128.4.4"; // ICU 3.0 collator ver
static GlobalPtr<UnicodeUtil::ICUModules> icuModules;
static bool extractVersionFromPath(const PathName& realPath, int& major, int& minor)
{
major = 0;
minor = 0;
int mult = 1;
const FB_SIZE_T len = realPath.length();
const char* buf = realPath.begin();
bool dot = false;
for (const char* p = buf + len - 1; p >= buf; p--)
{
if (*p >= '0' && *p < '9')
{
major += (*p - '0') * mult;
mult *= 10;
}
else if (*p == '.' && !dot)
{
dot = true;
minor = major;
major = 0;
mult = 1;
}
else
{
break;
}
}
if (minor && !major)
{
major = minor;
minor = 0;
}
return major != 0;
}
static ModuleLoader::Module* formatAndLoad(const char* templateName,
int majorVersion, int minorVersion)
int& majorVersion, int& minorVersion)
{
#ifdef ANDROID
static ModuleLoader::Module* dat = ModuleLoader::loadModule(NULL,
@ -432,7 +479,28 @@ static ModuleLoader::Module* formatAndLoad(const char* templateName,
{
PathName filename;
filename.printf(templateName, "");
filename.rtrim(".");
//gds__log("ICU: link %s", filename.c_str());
module = ModuleLoader::fixAndLoadModule(NULL, filename);
#ifdef LINUX
// try to resolve symlinks and extract version numbers from suffix
PathName realPath;
if (module && module->getRealPath(realPath))
{
//gds__log("ICU: module name %s, real path %s", module->fileName.c_str(), realPath.c_str());
int major, minor;
if (extractVersionFromPath(realPath, major, minor))
{
//gds__log("ICU: extracted version %d.%d", major, minor);
majorVersion = major;
minorVersion = minor;
}
}
#endif
}
else
{
@ -1134,7 +1202,7 @@ UnicodeUtil::ICU* UnicodeUtil::loadICU(const string& icuVersion, const string& c
icu = FB_NEW_POOL(*getDefaultMemoryPool()) ICU(majorVersion, minorVersion);
icu->ucModule = formatAndLoad(ucTemplate, majorVersion, minorVersion);
icu->ucModule = formatAndLoad(ucTemplate, icu->majorVersion, icu->minorVersion);
if (!icu->ucModule)
{
gds__log("failed to load UC icu module version %s", configVersion.c_str());
@ -1150,6 +1218,14 @@ UnicodeUtil::ICU* UnicodeUtil::loadICU(const string& icuVersion, const string& c
continue;
}
if (icu->majorVersion != majorVersion || icu->minorVersion != minorVersion)
{
gds__log("Wrong version of IN icu module: loaded %d.%d, expected %d.%d",
majorVersion, minorVersion, icu->majorVersion, icu->minorVersion);
delete icu;
continue;
}
try
{
icu->initialize(icu->ucModule);
@ -1265,7 +1341,12 @@ UnicodeUtil::ConversionICU& UnicodeUtil::getConversionICU()
for (int major = 79; major >= 3;)
{
#ifdef WIN_NT
int minor = 0;
#else
int minor = 9;
#endif
if (major == 4)
minor = 8;
else if (major <= 4)