Skip to content

Commit 7e5e573

Browse files
authored
Bump the minimum ICU version to 60 (#112713)
* Bump the minimum ICU version to 60 As ICU approaches version 80, we need to consider what to do about our ICU version ranges. Our system currently supports a min version of 50 and a max of "min + 30", so 80. ICU60 is the version that shipped with Ubuntu 18.04, which is the distro that we base our libc version on. For Alpine, the version of ICU in the distro we base our libc on (3.17) ships with ICU 72. I recommend that we bump our min to ICU60, which will by our current rules bump our max to ICU90, which will give us more runway. I'd recommend holding off on merging this until #112671 is merged, as that PR changes our deps packages to better describe scenarios where we actually ship packages today. * Remove old optional definition
1 parent 9e2afd1 commit 7e5e573

File tree

6 files changed

+13
-105
lines changed

6 files changed

+13
-105
lines changed
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#pragma once
22

33
#cmakedefine01 HAVE_UDAT_STANDALONE_SHORTER_WEEKDAYS
4-
#cmakedefine01 HAVE_SET_MAX_VARIABLE
5-
#cmakedefine01 HAVE_UCOL_CLONE
4+
#cmakedefine01 HAVE_UCOL_CLONE

src/native/libs/System.Globalization.Native/configure.cmake

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
if(CLR_CMAKE_TARGET_ANDROID OR CLR_CMAKE_TARGET_APPLE OR CLR_CMAKE_TARGET_BROWSER OR CLR_CMAKE_TARGET_WASI)
2-
set(HAVE_SET_MAX_VARIABLE 1)
32
set(HAVE_UDAT_STANDALONE_SHORTER_WEEKDAYS 1)
43
set(HAVE_UCOL_CLONE 0)
54
else()
@@ -15,12 +14,6 @@ else()
1514
" HAVE_UDAT_STANDALONE_SHORTER_WEEKDAYS)
1615

1716
set(CMAKE_REQUIRED_LIBRARIES ${ICUUC} ${ICUI18N})
18-
19-
check_symbol_exists(
20-
ucol_setMaxVariable
21-
"unicode/ucol.h"
22-
HAVE_SET_MAX_VARIABLE)
23-
2417
check_symbol_exists(
2518
ucol_clone
2619
"unicode/ucol.h"

src/native/libs/System.Globalization.Native/pal_collation.c

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -384,38 +384,10 @@ static UCollator* CloneCollatorWithOptions(const UCollator* pCollator, int32_t o
384384
{
385385
ucol_setAttribute(pClonedCollator, UCOL_ALTERNATE_HANDLING, UCOL_SHIFTED, pErr);
386386

387-
#if !defined(STATIC_ICU)
388-
if (ucol_setMaxVariable_ptr != NULL)
389-
{
390-
// by default, ICU alternate shifted handling only ignores punctuation, but
391-
// IgnoreSymbols needs symbols and currency as well, so change the "variable top"
392-
// to include all symbols and currency
393-
ucol_setMaxVariable(pClonedCollator, UCOL_REORDER_CODE_CURRENCY, pErr);
394-
}
395-
else
396-
{
397-
assert(ucol_setVariableTop_ptr != NULL);
398-
// 0xfdfc is the last currency character before the first digit character
399-
// in http://source.icu-project.org/repos/icu/icu/tags/release-52-1/source/data/unidata/FractionalUCA.txt
400-
const UChar ignoreSymbolsVariableTop[] = { 0xfdfc };
401-
ucol_setVariableTop_ptr(pClonedCollator, ignoreSymbolsVariableTop, 1, pErr);
402-
}
403-
404-
#else // !defined(STATIC_ICU)
405-
406387
// by default, ICU alternate shifted handling only ignores punctuation, but
407388
// IgnoreSymbols needs symbols and currency as well, so change the "variable top"
408389
// to include all symbols and currency
409-
#if HAVE_SET_MAX_VARIABLE
410390
ucol_setMaxVariable(pClonedCollator, UCOL_REORDER_CODE_CURRENCY, pErr);
411-
#else
412-
// 0xfdfc is the last currency character before the first digit character
413-
// in http://source.icu-project.org/repos/icu/icu/tags/release-52-1/source/data/unidata/FractionalUCA.txt
414-
const UChar ignoreSymbolsVariableTop[] = { 0xfdfc };
415-
ucol_setVariableTop(pClonedCollator, ignoreSymbolsVariableTop, 1, pErr);
416-
#endif
417-
418-
#endif //!defined(STATIC_ICU)
419391
}
420392

421393
ucol_setAttribute(pClonedCollator, UCOL_STRENGTH, strength, pErr);

src/native/libs/System.Globalization.Native/pal_icushim.c

Lines changed: 1 addition & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ FOR_ALL_ICU_FUNCTIONS
4545

4646
static void* libicuuc = NULL;
4747
static void* libicui18n = NULL;
48-
ucol_setVariableTop_func ucol_setVariableTop_ptr = NULL;
4948
ucol_safeClone_func ucol_safeClone_ptr = NULL;
5049

5150
#if defined (TARGET_UNIX)
@@ -240,7 +239,7 @@ static int FindICULibs(char* symbolName, char* symbolVersion)
240239
// a year.
241240
// On some platforms (mainly Alpine Linux) we want to make our minimum version
242241
// an earlier version than what we build that we know we support.
243-
#define MinICUVersion 50
242+
#define MinICUVersion 60
244243
#define MaxICUVersion (U_ICU_VERSION_MAJOR_NUM + 30)
245244
#define MinMinorICUVersion 1
246245
#define MaxMinorICUVersion 5
@@ -443,35 +442,6 @@ static void InitializeUColClonePointers(char* symbolVersion)
443442
}
444443
}
445444

446-
static void InitializeVariableMaxAndTopPointers(char* symbolVersion)
447-
{
448-
if (ucol_setMaxVariable_ptr != NULL)
449-
{
450-
return;
451-
}
452-
453-
#if defined(TARGET_OSX) || defined(TARGET_ANDROID)
454-
// OSX and Android always run against ICU version which has ucol_setMaxVariable.
455-
// We shouldn't come here.
456-
(void)symbolVersion;
457-
assert(false);
458-
#elif defined(TARGET_WINDOWS)
459-
char symbolName[SYMBOL_NAME_SIZE];
460-
sprintf_s(symbolName, SYMBOL_NAME_SIZE, "ucol_setVariableTop%s", symbolVersion);
461-
ucol_setVariableTop_ptr = (ucol_setVariableTop_func)GetProcAddress((HMODULE)libicui18n, symbolName);
462-
#else
463-
char symbolName[SYMBOL_NAME_SIZE];
464-
snprintf(symbolName, SYMBOL_NAME_SIZE, "ucol_setVariableTop%s", symbolVersion);
465-
ucol_setVariableTop_ptr = (ucol_setVariableTop_func)dlsym(libicui18n, symbolName);
466-
#endif // defined(TARGET_OSX) || defined(TARGET_ANDROID)
467-
468-
if (ucol_setVariableTop_ptr == NULL)
469-
{
470-
fprintf(stderr, "Cannot get the symbols of ICU APIs ucol_setMaxVariable or ucol_setVariableTop.\n");
471-
abort();
472-
}
473-
}
474-
475445
// GlobalizationNative_LoadICU
476446
// This method get called from the managed side during the globalization initialization.
477447
// This method shouldn't get called at all if we are running in globalization invariant mode
@@ -509,7 +479,6 @@ int32_t GlobalizationNative_LoadICU(void)
509479
FOR_ALL_ICU_FUNCTIONS
510480
ValidateICUDataCanLoad();
511481

512-
InitializeVariableMaxAndTopPointers(symbolVersion);
513482
InitializeUColClonePointers(symbolVersion);
514483

515484
return true;
@@ -566,7 +535,6 @@ void GlobalizationNative_InitICUFunctions(void* icuuc, void* icuin, const char*
566535
FOR_ALL_ICU_FUNCTIONS
567536
ValidateICUDataCanLoad();
568537

569-
InitializeVariableMaxAndTopPointers(symbolVersion);
570538
InitializeUColClonePointers(symbolVersion);
571539
}
572540

src/native/libs/System.Globalization.Native/pal_icushim_internal.h

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@
5353

5454
#include "icu.h"
5555

56-
#define HAVE_SET_MAX_VARIABLE 1
5756
#define UDAT_STANDALONE_SHORTER_WEEKDAYS 1
5857

5958
#endif
@@ -63,34 +62,20 @@
6362
#if !defined(STATIC_ICU)
6463

6564
#if !defined(TARGET_ANDROID)
66-
// (U_ICU_VERSION_MAJOR_NUM < 52)
67-
// The following APIs are not supported in the ICU versions less than 52. We need to define them manually.
68-
// We have to do runtime check before using the pointers to these APIs. That is why these are listed in the FOR_ALL_OPTIONAL_ICU_FUNCTIONS list.
69-
U_CAPI void U_EXPORT2 ucol_setMaxVariable(UCollator* coll, UColReorderCode group, UErrorCode* pErrorCode);
70-
U_CAPI int32_t U_EXPORT2 ucal_getTimeZoneIDForWindowsID(const UChar* winid, int32_t len, const char* region, UChar* id, int32_t idCapacity, UErrorCode* status);
71-
U_CAPI int32_t U_EXPORT2 ucal_getWindowsTimeZoneID(const UChar* id, int32_t len, UChar* winid, int32_t winidCapacity, UErrorCode* status);
72-
7365
// (U_ICU_VERSION_MAJOR_NUM < 71)
7466
// The following API is not supported in the ICU versions less than 71. We need to define it manually.
7567
// We have to do runtime check before using the pointers to this API. That is why these are listed in the FOR_ALL_OPTIONAL_ICU_FUNCTIONS list.
7668
U_CAPI UCollator* U_EXPORT2 ucol_clone(const UCollator* coll, UErrorCode* status);
7769

78-
// ucol_setVariableTop is a deprecated function on the newer ICU versions and ucol_setMaxVariable should be used instead.
79-
// As we can run against ICU versions which do not support ucol_setMaxVariable, we will dynamically try to get the pointer
80-
// to ucol_setVariableTop when we could not get a pointer to ucol_setMaxVariable.
81-
typedef uint32_t (U_EXPORT2 *ucol_setVariableTop_func)(UCollator* coll, const UChar* varTop, int32_t len, UErrorCode* status);
82-
8370
// ucol_safeClone is deprecated in ICU version 71. We have to handle it manually to avoid getting a build break when referencing it in the code.
8471
typedef UCollator* (U_EXPORT2 *ucol_safeClone_func)(const UCollator* coll, void* stackBuffer, int32_t* pBufferSize, UErrorCode* status);
8572

8673
#else // !defined(TARGET_ANDROID)
8774

88-
typedef uint32_t (*ucol_setVariableTop_func)(UCollator* coll, const UChar* varTop, int32_t len, UErrorCode* status);
8975
typedef UCollator* (*ucol_safeClone_func)(const UCollator* coll, void* stackBuffer, int32_t* pBufferSize, UErrorCode* status);
9076

9177
#endif // !defined(TARGET_ANDROID)
9278

93-
extern ucol_setVariableTop_func ucol_setVariableTop_ptr;
9479
extern ucol_safeClone_func ucol_safeClone_ptr;
9580

9681
// List of all functions from the ICU libraries that are used in the System.Globalization.Native.so
@@ -114,6 +99,8 @@ extern ucol_safeClone_func ucol_safeClone_ptr;
11499
PER_FUNCTION_BLOCK(ucal_getLimit, libicui18n, true) \
115100
PER_FUNCTION_BLOCK(ucal_getNow, libicui18n, true) \
116101
PER_FUNCTION_BLOCK(ucal_getTimeZoneDisplayName, libicui18n, true) \
102+
PER_FUNCTION_BLOCK(ucal_getTimeZoneIDForWindowsID, libicui18n, true) \
103+
PER_FUNCTION_BLOCK(ucal_getWindowsTimeZoneID, libicui18n, true) \
117104
PER_FUNCTION_BLOCK(ucal_open, libicui18n, true) \
118105
PER_FUNCTION_BLOCK(ucal_openTimeZoneIDEnumeration, libicui18n, true) \
119106
PER_FUNCTION_BLOCK(ucal_set, libicui18n, true) \
@@ -131,6 +118,7 @@ extern ucol_safeClone_func ucol_safeClone_ptr;
131118
PER_FUNCTION_BLOCK(ucol_openElements, libicui18n, true) \
132119
PER_FUNCTION_BLOCK(ucol_openRules, libicui18n, true) \
133120
PER_FUNCTION_BLOCK(ucol_setAttribute, libicui18n, true) \
121+
PER_FUNCTION_BLOCK(ucol_setMaxVariable, libicui18n, true) \
134122
PER_FUNCTION_BLOCK(ucol_strcoll, libicui18n, true) \
135123
PER_FUNCTION_BLOCK(udat_close, libicui18n, true) \
136124
PER_FUNCTION_BLOCK(udat_countSymbols, libicui18n, true) \
@@ -215,9 +203,6 @@ extern ucol_safeClone_func ucol_safeClone_ptr;
215203
// The following are the list of the ICU APIs which are optional. If these APIs exist in the ICU version we load at runtime, then we'll use it.
216204
// Otherwise, we'll just not provide the functionality to users which needed these APIs.
217205
#define FOR_ALL_OPTIONAL_ICU_FUNCTIONS \
218-
PER_FUNCTION_BLOCK(ucal_getWindowsTimeZoneID, libicui18n, false) \
219-
PER_FUNCTION_BLOCK(ucal_getTimeZoneIDForWindowsID, libicui18n, false) \
220-
PER_FUNCTION_BLOCK(ucol_setMaxVariable, libicui18n, false) \
221206
PER_FUNCTION_BLOCK(ucol_clone, libicui18n, false)
222207

223208
#define FOR_ALL_ICU_FUNCTIONS \
@@ -343,9 +328,6 @@ FOR_ALL_ICU_FUNCTIONS
343328

344329
#else // !defined(STATIC_ICU)
345330

346-
#define ucal_getWindowsTimeZoneID_ptr ucal_getWindowsTimeZoneID
347-
#define ucal_getTimeZoneIDForWindowsID_ptr ucal_getTimeZoneIDForWindowsID
348-
349331
#if defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS)
350332
const char* GlobalizationNative_GetICUDataPathRelativeToAppBundleRoot(const char* path);
351333
const char* GlobalizationNative_GetICUDataPathFallback(void);
@@ -360,7 +342,7 @@ const char* GlobalizationNative_GetICUDataPathFallback(void);
360342
* "Safe" macro, checks for a valid code point.
361343
* Converts code points outside of Basic Multilingual Plane into
362344
* corresponding surrogate pairs if sufficient space in the string.
363-
* High surrogate range: 0xD800 - 0xDBFF
345+
* High surrogate range: 0xD800 - 0xDBFF
364346
* Low surrogate range: 0xDC00 - 0xDFFF
365347
* If the code point is not valid or a trail surrogate does not fit,
366348
* then isError is set to true.

src/native/libs/System.Globalization.Native/pal_timeZoneInfo.c

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,10 @@ int32_t GlobalizationNative_WindowsIdToIanaId(const UChar* windowsId, const char
2525
{
2626
UErrorCode status = U_ZERO_ERROR;
2727

28-
if (ucal_getTimeZoneIDForWindowsID_ptr != NULL)
28+
int32_t ianaIdFilledLength = ucal_getTimeZoneIDForWindowsID(windowsId, -1, region, ianaId, ianaIdLength, &status);
29+
if (U_SUCCESS(status))
2930
{
30-
int32_t ianaIdFilledLength = ucal_getTimeZoneIDForWindowsID(windowsId, -1, region, ianaId, ianaIdLength, &status);
31-
if (U_SUCCESS(status))
32-
{
33-
return ianaIdFilledLength;
34-
}
31+
return ianaIdFilledLength;
3532
}
3633

3734
// Failed
@@ -45,14 +42,11 @@ int32_t GlobalizationNative_IanaIdToWindowsId(const UChar* ianaId, UChar* window
4542
{
4643
UErrorCode status = U_ZERO_ERROR;
4744

48-
if (ucal_getWindowsTimeZoneID_ptr != NULL)
49-
{
50-
int32_t windowsIdFilledLength = ucal_getWindowsTimeZoneID(ianaId, -1, windowsId, windowsIdLength, &status);
45+
int32_t windowsIdFilledLength = ucal_getWindowsTimeZoneID(ianaId, -1, windowsId, windowsIdLength, &status);
5146

52-
if (U_SUCCESS(status))
53-
{
54-
return windowsIdFilledLength;
55-
}
47+
if (U_SUCCESS(status))
48+
{
49+
return windowsIdFilledLength;
5650
}
5751

5852
// Failed

0 commit comments

Comments
 (0)