Skip to content

Commit bc65e68

Browse files
lewingSteve Pfister
andauthored
[release/6.0] Bump the macOS image to one that isn't EOL yet (#75294)
* Bump the macOS image to one that isn't EOL yet * Backport #68847 and #58485 Co-authored-by: Steve Pfister <[email protected]>
1 parent f2112e3 commit bc65e68

File tree

6 files changed

+132
-21
lines changed

6 files changed

+132
-21
lines changed

eng/pipelines/common/xplat-setup.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ jobs:
121121

122122
# OSX Build Pool (we don't have on-prem OSX BuildPool
123123
${{ if in(parameters.osGroup, 'OSX', 'MacCatalyst', 'iOS', 'iOSSimulator', 'tvOS', 'tvOSSimulator') }}:
124-
vmImage: 'macOS-10.15'
124+
vmImage: 'macOS-11'
125125

126126
# Official Build Windows Pool
127127
${{ if and(eq(parameters.osGroup, 'windows'), ne(variables['System.TeamProject'], 'public')) }}:

src/libraries/Native/Unix/System.Globalization.Native/configure.cmake

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ else()
1919
ucol_setMaxVariable
2020
"unicode/ucol.h"
2121
HAVE_SET_MAX_VARIABLE)
22+
23+
check_symbol_exists(
24+
ucol_clone
25+
"unicode/ucol.h"
26+
HAVE_UCOL_CLONE)
2227

2328
unset(CMAKE_REQUIRED_LIBRARIES)
2429
unset(CMAKE_REQUIRED_INCLUDES)

src/libraries/Native/Unix/System.Globalization.Native/pal_collation.c

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,24 @@ static UCollator* CloneCollatorWithOptions(const UCollator* pCollator, int32_t o
321321

322322
if (customRuleLength == 0)
323323
{
324+
#if !defined(STATIC_ICU)
325+
if (ucol_clone_ptr != NULL)
326+
{
327+
pClonedCollator = ucol_clone(pCollator, pErr);
328+
}
329+
else
330+
{
331+
pClonedCollator = ucol_safeClone_ptr(pCollator, NULL, NULL, pErr);
332+
}
333+
#else // !defined(STATIC_ICU)
334+
335+
#if HAVE_UCOL_CLONE
336+
pClonedCollator = ucol_clone(pCollator, pErr);
337+
#else
324338
pClonedCollator = ucol_safeClone(pCollator, NULL, NULL, pErr);
339+
#endif // HAVE_UCOL_CLONE
340+
341+
#endif // !defined(STATIC_ICU)
325342
}
326343
else
327344
{
@@ -365,6 +382,24 @@ static UCollator* CloneCollatorWithOptions(const UCollator* pCollator, int32_t o
365382
{
366383
ucol_setAttribute(pClonedCollator, UCOL_ALTERNATE_HANDLING, UCOL_SHIFTED, pErr);
367384

385+
#if !defined(STATIC_ICU)
386+
if (ucol_setMaxVariable_ptr != NULL)
387+
{
388+
// by default, ICU alternate shifted handling only ignores punctuation, but
389+
// IgnoreSymbols needs symbols and currency as well, so change the "variable top"
390+
// to include all symbols and currency
391+
ucol_setMaxVariable(pClonedCollator, UCOL_REORDER_CODE_CURRENCY, pErr);
392+
}
393+
else
394+
{
395+
assert(ucol_setVariableTop_ptr != NULL);
396+
// 0xfdfc is the last currency character before the first digit character
397+
// in http://source.icu-project.org/repos/icu/icu/tags/release-52-1/source/data/unidata/FractionalUCA.txt
398+
const UChar ignoreSymbolsVariableTop[] = { 0xfdfc };
399+
ucol_setVariableTop_ptr(pClonedCollator, ignoreSymbolsVariableTop, 1, pErr);
400+
}
401+
402+
#else // !defined(STATIC_ICU)
368403
// by default, ICU alternate shifted handling only ignores punctuation, but
369404
// IgnoreSymbols needs symbols and currency as well, so change the "variable top"
370405
// to include all symbols and currency
@@ -376,6 +411,8 @@ static UCollator* CloneCollatorWithOptions(const UCollator* pCollator, int32_t o
376411
const UChar ignoreSymbolsVariableTop[] = { 0xfdfc };
377412
ucol_setVariableTop(pClonedCollator, ignoreSymbolsVariableTop, 1, pErr);
378413
#endif
414+
415+
#endif //!defined(STATIC_ICU)
379416
}
380417

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

src/libraries/Native/Unix/System.Globalization.Native/pal_icushim.c

Lines changed: 60 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ FOR_ALL_ICU_FUNCTIONS
2929
#define SYMBOL_NAME_SIZE (128 + SYMBOL_CUSTOM_SUFFIX_SIZE)
3030
#define MaxICUVersionStringWithSuffixLength (MaxICUVersionStringLength + SYMBOL_CUSTOM_SUFFIX_SIZE)
3131

32-
3332
#if defined(TARGET_WINDOWS) || defined(TARGET_OSX) || defined(TARGET_ANDROID)
3433

3534
#define MaxICUVersionStringLength 33
@@ -38,6 +37,8 @@ FOR_ALL_ICU_FUNCTIONS
3837

3938
static void* libicuuc = NULL;
4039
static void* libicui18n = NULL;
40+
ucol_setVariableTop_func ucol_setVariableTop_ptr = NULL;
41+
ucol_safeClone_func ucol_safeClone_ptr = NULL;
4142

4243
#if defined (TARGET_UNIX)
4344

@@ -380,6 +381,58 @@ static void ValidateICUDataCanLoad()
380381
}
381382
}
382383

384+
static void InitializeUColClonePointers(char* symbolVersion)
385+
{
386+
if (ucol_clone_ptr != NULL)
387+
{
388+
return;
389+
}
390+
391+
#if defined(TARGET_WINDOWS)
392+
char symbolName[SYMBOL_NAME_SIZE];
393+
sprintf_s(symbolName, SYMBOL_NAME_SIZE, "ucol_safeClone%s", symbolVersion);
394+
ucol_safeClone_ptr = (ucol_safeClone_func)GetProcAddress((HMODULE)libicui18n, symbolName);
395+
#else
396+
char symbolName[SYMBOL_NAME_SIZE];
397+
sprintf(symbolName, "ucol_safeClone%s", symbolVersion);
398+
ucol_safeClone_ptr = (ucol_safeClone_func)dlsym(libicui18n, symbolName);
399+
#endif // defined(TARGET_WINDOWS)
400+
401+
if (ucol_safeClone_ptr == NULL)
402+
{
403+
fprintf(stderr, "Cannot get the symbols of ICU APIs ucol_safeClone or ucol_clone.\n");
404+
abort();
405+
}
406+
}
407+
408+
static void InitializeVariableMaxAndTopPointers(char* symbolVersion)
409+
{
410+
if (ucol_setMaxVariable_ptr != NULL)
411+
{
412+
return;
413+
}
414+
415+
#if defined(TARGET_OSX) || defined(TARGET_ANDROID)
416+
// OSX and Android always run against ICU version which has ucol_setMaxVariable.
417+
// We shouldn't come here.
418+
assert(false);
419+
#elif defined(TARGET_WINDOWS)
420+
char symbolName[SYMBOL_NAME_SIZE];
421+
sprintf_s(symbolName, SYMBOL_NAME_SIZE, "ucol_setVariableTop%s", symbolVersion);
422+
ucol_setVariableTop_ptr = (ucol_setVariableTop_func)GetProcAddress((HMODULE)libicui18n, symbolName);
423+
#else
424+
char symbolName[SYMBOL_NAME_SIZE];
425+
sprintf(symbolName, "ucol_setVariableTop%s", symbolVersion);
426+
ucol_setVariableTop_ptr = (ucol_setVariableTop_func)dlsym(libicui18n, symbolName);
427+
#endif // defined(TARGET_OSX) || defined(TARGET_ANDROID)
428+
429+
if (ucol_setVariableTop_ptr == NULL)
430+
{
431+
fprintf(stderr, "Cannot get the symbols of ICU APIs ucol_setMaxVariable or ucol_setVariableTop.\n");
432+
abort();
433+
}
434+
}
435+
383436
// GlobalizationNative_LoadICU
384437
// This method get called from the managed side during the globalization initialization.
385438
// This method shouldn't get called at all if we are running in globalization invariant mode
@@ -413,6 +466,10 @@ int32_t GlobalizationNative_LoadICU()
413466

414467
FOR_ALL_ICU_FUNCTIONS
415468
ValidateICUDataCanLoad();
469+
470+
InitializeVariableMaxAndTopPointers(symbolVersion);
471+
InitializeUColClonePointers(symbolVersion);
472+
416473
return true;
417474
}
418475

@@ -466,6 +523,8 @@ void GlobalizationNative_InitICUFunctions(void* icuuc, void* icuin, const char*
466523

467524
FOR_ALL_ICU_FUNCTIONS
468525
ValidateICUDataCanLoad();
526+
527+
InitializeVariableMaxAndTopPointers(symbolVersion);
469528
}
470529

471530
#undef PER_FUNCTION_BLOCK

src/libraries/Native/Unix/System.Globalization.Native/pal_icushim_internal.h

Lines changed: 28 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,32 @@
5858
// (U_ICU_VERSION_MAJOR_NUM < 52)
5959
// The following APIs are not supported in the ICU versions less than 52. We need to define them manually.
6060
// 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.
61+
U_CAPI void U_EXPORT2 ucol_setMaxVariable(UCollator* coll, UColReorderCode group, UErrorCode* pErrorCode);
6162
U_CAPI int32_t U_EXPORT2 ucal_getTimeZoneIDForWindowsID(const UChar* winid, int32_t len, const char* region, UChar* id, int32_t idCapacity, UErrorCode* status);
6263
U_CAPI int32_t U_EXPORT2 ucal_getWindowsTimeZoneID(const UChar* id, int32_t len, UChar* winid, int32_t winidCapacity, UErrorCode* status);
63-
#endif
64+
65+
// (U_ICU_VERSION_MAJOR_NUM < 71)
66+
// The following API is not supported in the ICU versions less than 71. We need to define it manually.
67+
// 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.
68+
U_CAPI UCollator* U_EXPORT2 ucol_clone(const UCollator* coll, UErrorCode* status);
69+
70+
// ucol_setVariableTop is a deprecated function on the newer ICU versions and ucol_setMaxVariable should be used instead.
71+
// As can run against ICU versions which not supported ucol_setMaxVariable, we'll dynamically try to get the pointer to ucol_setVariableTop
72+
// when we couldn't get a pointer to ucol_setMaxVariable.
73+
typedef uint32_t (U_EXPORT2 *ucol_setVariableTop_func)(UCollator* coll, const UChar* varTop, int32_t len, UErrorCode* status);
74+
75+
// 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.
76+
typedef UCollator* (U_EXPORT2 *ucol_safeClone_func)(const UCollator* coll, void* stackBuffer, int32_t* pBufferSize, UErrorCode* status);
77+
78+
#else // !defined(TARGET_ANDROID)
79+
80+
typedef uint32_t (*ucol_setVariableTop_func)(UCollator* coll, const UChar* varTop, int32_t len, UErrorCode* status);
81+
typedef UCollator* (*ucol_safeClone_func)(const UCollator* coll, void* stackBuffer, int32_t* pBufferSize, UErrorCode* status);
82+
83+
#endif // !defined(TARGET_ANDROID)
84+
85+
extern ucol_setVariableTop_func ucol_setVariableTop_ptr;
86+
extern ucol_safeClone_func ucol_safeClone_ptr;
6487

6588
// List of all functions from the ICU libraries that are used in the System.Globalization.Native.so
6689
#define FOR_ALL_UNCONDITIONAL_ICU_FUNCTIONS \
@@ -99,7 +122,6 @@ U_CAPI int32_t U_EXPORT2 ucal_getWindowsTimeZoneID(const UChar* id, int32_t len,
99122
PER_FUNCTION_BLOCK(ucol_open, libicui18n, true) \
100123
PER_FUNCTION_BLOCK(ucol_openElements, libicui18n, true) \
101124
PER_FUNCTION_BLOCK(ucol_openRules, libicui18n, true) \
102-
PER_FUNCTION_BLOCK(ucol_safeClone, libicui18n, true) \
103125
PER_FUNCTION_BLOCK(ucol_setAttribute, libicui18n, true) \
104126
PER_FUNCTION_BLOCK(ucol_strcoll, libicui18n, true) \
105127
PER_FUNCTION_BLOCK(udat_close, libicui18n, true) \
@@ -164,15 +186,6 @@ U_CAPI int32_t U_EXPORT2 ucal_getWindowsTimeZoneID(const UChar* id, int32_t len,
164186
PER_FUNCTION_BLOCK(usearch_setPattern, libicui18n, true) \
165187
PER_FUNCTION_BLOCK(usearch_setText, libicui18n, true)
166188

167-
#if HAVE_SET_MAX_VARIABLE
168-
#define FOR_ALL_SET_VARIABLE_ICU_FUNCTIONS \
169-
PER_FUNCTION_BLOCK(ucol_setMaxVariable, libicui18n, true)
170-
#else
171-
172-
#define FOR_ALL_SET_VARIABLE_ICU_FUNCTIONS \
173-
PER_FUNCTION_BLOCK(ucol_setVariableTop, libicui18n, true)
174-
#endif
175-
176189
#if defined(TARGET_WINDOWS)
177190
#define FOR_ALL_OS_CONDITIONAL_ICU_FUNCTIONS \
178191
PER_FUNCTION_BLOCK(ucurr_forLocale, libicuuc, true) \
@@ -195,11 +208,12 @@ U_CAPI int32_t U_EXPORT2 ucal_getWindowsTimeZoneID(const UChar* id, int32_t len,
195208
// Otherwise, we'll just not provide the functionality to users which needed these APIs.
196209
#define FOR_ALL_OPTIONAL_ICU_FUNCTIONS \
197210
PER_FUNCTION_BLOCK(ucal_getWindowsTimeZoneID, libicui18n, false) \
198-
PER_FUNCTION_BLOCK(ucal_getTimeZoneIDForWindowsID, libicui18n, false)
211+
PER_FUNCTION_BLOCK(ucal_getTimeZoneIDForWindowsID, libicui18n, false) \
212+
PER_FUNCTION_BLOCK(ucol_setMaxVariable, libicui18n, false) \
213+
PER_FUNCTION_BLOCK(ucol_clone, libicui18n, false)
199214

200215
#define FOR_ALL_ICU_FUNCTIONS \
201216
FOR_ALL_UNCONDITIONAL_ICU_FUNCTIONS \
202-
FOR_ALL_SET_VARIABLE_ICU_FUNCTIONS \
203217
FOR_ALL_OPTIONAL_ICU_FUNCTIONS \
204218
FOR_ALL_OS_CONDITIONAL_ICU_FUNCTIONS
205219

@@ -235,6 +249,7 @@ FOR_ALL_ICU_FUNCTIONS
235249
#define ucal_openTimeZoneIDEnumeration(...) ucal_openTimeZoneIDEnumeration_ptr(__VA_ARGS__)
236250
#define ucal_set(...) ucal_set_ptr(__VA_ARGS__)
237251
#define ucal_setMillis(...) ucal_setMillis_ptr(__VA_ARGS__)
252+
#define ucol_clone(...) ucol_clone_ptr(__VA_ARGS__)
238253
#define ucol_close(...) ucol_close_ptr(__VA_ARGS__)
239254
#define ucol_closeElements(...) ucol_closeElements_ptr(__VA_ARGS__)
240255
#define ucol_getOffset(...) ucol_getOffset_ptr(__VA_ARGS__)
@@ -247,13 +262,8 @@ FOR_ALL_ICU_FUNCTIONS
247262
#define ucol_open(...) ucol_open_ptr(__VA_ARGS__)
248263
#define ucol_openElements(...) ucol_openElements_ptr(__VA_ARGS__)
249264
#define ucol_openRules(...) ucol_openRules_ptr(__VA_ARGS__)
250-
#define ucol_safeClone(...) ucol_safeClone_ptr(__VA_ARGS__)
251265
#define ucol_setAttribute(...) ucol_setAttribute_ptr(__VA_ARGS__)
252-
#if HAVE_SET_MAX_VARIABLE
253266
#define ucol_setMaxVariable(...) ucol_setMaxVariable_ptr(__VA_ARGS__)
254-
#else
255-
#define ucol_setVariableTop(...) ucol_setVariableTop_ptr(__VA_ARGS__)
256-
#endif
257267
#define ucol_strcoll(...) ucol_strcoll_ptr(__VA_ARGS__)
258268
#define ucurr_forLocale(...) ucurr_forLocale_ptr(__VA_ARGS__)
259269
#define ucurr_getName(...) ucurr_getName_ptr(__VA_ARGS__)

src/libraries/Native/Unix/System.Globalization.Native/pal_icushim_internal_android.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,7 @@ int32_t ucol_previous(UCollationElements * elems, UErrorCode * status);
470470
UCollator * ucol_open(const char * loc, UErrorCode * status);
471471
UCollationElements * ucol_openElements(const UCollator * coll, const UChar * text, int32_t textLength, UErrorCode * status);
472472
UCollator * ucol_openRules(const UChar * rules, int32_t rulesLength, UColAttributeValue normalizationMode, UCollationStrength strength, UParseError * parseError, UErrorCode * status);
473-
UCollator * ucol_safeClone(const UCollator * coll, void * stackBuffer, int32_t * pBufferSize, UErrorCode * status);
473+
UCollator * ucol_clone(const UCollator * coll, UErrorCode * status);
474474
void ucol_setAttribute(UCollator * coll, UColAttribute attr, UColAttributeValue value, UErrorCode * status);
475475
UCollationResult ucol_strcoll(const UCollator * coll, const UChar * source, int32_t sourceLength, const UChar * target, int32_t targetLength);
476476
int32_t ucurr_forLocale(const char * locale, UChar * buff, int32_t buffCapacity, UErrorCode * ec);

0 commit comments

Comments
 (0)