summaryrefslogtreecommitdiff
path: root/src/corefx
diff options
context:
space:
mode:
authorJan Vorlicek <janvorli@microsoft.com>2017-03-07 12:03:08 +0100
committerGitHub <noreply@github.com>2017-03-07 12:03:08 +0100
commit6c60ce7d4b1c438ecd034fdc5456697c5805e850 (patch)
treed713509844fc60e2329b7fb53e3e382e4267cafd /src/corefx
parentfd62b32850e9f6be88c6ece155b447b1ff167908 (diff)
downloadcoreclr-6c60ce7d4b1c438ecd034fdc5456697c5805e850.tar.gz
coreclr-6c60ce7d4b1c438ecd034fdc5456697c5805e850.tar.bz2
coreclr-6c60ce7d4b1c438ecd034fdc5456697c5805e850.zip
Enhance ICU version scan (#9993)
The scanning that tries to find locally installed ICU version was not considering the case when only ICU library files with major version component were present (like libicuuc.so.52). This is a rare case that I've seen so far only when people built and installed ICU manually. But it is worth to add checks for such case as a fallback, which is what this change does. I have also added checks for minorVersion and subVersion being -1 when trying to detect the symbol versioning used. While the pre-existing code would still work fine, it would unnecessarily try nonsensical version.
Diffstat (limited to 'src/corefx')
-rw-r--r--src/corefx/System.Globalization.Native/icushim.cpp24
1 files changed, 21 insertions, 3 deletions
diff --git a/src/corefx/System.Globalization.Native/icushim.cpp b/src/corefx/System.Globalization.Native/icushim.cpp
index 63f111b8b1..1c2187b488 100644
--- a/src/corefx/System.Globalization.Native/icushim.cpp
+++ b/src/corefx/System.Globalization.Native/icushim.cpp
@@ -111,6 +111,22 @@ bool FindLibUsingOverride(int* majorVer, int* minorVer, int* subVer)
}
// Select the highest supported version of ICU present on the local machine
+// Search for library files with names including the major version.
+bool FindLibWithMajorVersion(int* majorVer)
+{
+ for (int i = MaxICUVersion; i >= MinICUVersion; i--)
+ {
+ if (OpenICULibraries(i, -1, -1))
+ {
+ *majorVer = i;
+ return true;
+ }
+ }
+
+ return false;
+}
+
+// Select the highest supported version of ICU present on the local machine
// Search for library files with names including the major and minor version.
bool FindLibWithMajorMinorVersion(int* majorVer, int* minorVer)
{
@@ -164,7 +180,9 @@ void InitializeICUShim()
if (!FindLibUsingOverride(&majorVer, &minorVer, &subVer) &&
!FindLibWithMajorMinorVersion(&majorVer, &minorVer) &&
- !FindLibWithMajorMinorSubVersion(&majorVer, &minorVer, &subVer))
+ !FindLibWithMajorMinorSubVersion(&majorVer, &minorVer, &subVer) &&
+ // This is a fallback for the rare case when there are only lib files with major version
+ !FindLibWithMajorVersion(&majorVer))
{
// No usable ICU version found
fprintf(stderr, "No usable version of the ICU libraries was found\n");
@@ -181,12 +199,12 @@ void InitializeICUShim()
// Now try just the _majorVer added
sprintf(symbolVersion, "_%d", majorVer);
sprintf(symbolName, "u_strlen%s", symbolVersion);
- if (dlsym(libicuuc, symbolName) == nullptr)
+ if ((dlsym(libicuuc, symbolName) == nullptr) && (minorVer != -1))
{
// Now try the _majorVer_minorVer added
sprintf(symbolVersion, "_%d_%d", majorVer, minorVer);
sprintf(symbolName, "u_strlen%s", symbolVersion);
- if (dlsym(libicuuc, symbolName) == nullptr)
+ if ((dlsym(libicuuc, symbolName) == nullptr) && (subVer != -1))
{
// Finally, try the _majorVer_minorVer_subVer added
sprintf(symbolVersion, "_%d_%d_%d", majorVer, minorVer, subVer);