Skip to content

Conversation

@grhoten
Copy link
Member

@grhoten grhoten commented Nov 5, 2025

The runConfigureICU script should add Link Time Optimization (-flto) to the release flags for ongoing testing on macOS. It can provide substantial performance improvements.

Checklist

  • Required: Issue filed: ICU-23253
  • Required: The PR title must be prefixed with a JIRA Issue number. Example: "ICU-NNNNN Fix xyz"
  • Required: Each commit message must be prefixed with a JIRA Issue number. Example: "ICU-NNNNN Fix xyz"
  • Issue accepted (done by Technical Committee after discussion)
  • Tests included, if applicable
  • API docs and/or User Guide docs changed or added, if applicable
  • Approver: Feel free to merge on my behalf

markusicu
markusicu previously approved these changes Nov 6, 2025
@jira-pull-request-webhook
Copy link

Hooray! The files in the branch are the same across the force-push. 😃

~ Your Friendly Jira-GitHub PR Checker Bot

@grhoten grhoten requested a review from markusicu November 7, 2025 06:44
@grhoten
Copy link
Member Author

grhoten commented Nov 7, 2025

FYI the following warnings appeared when I used Linux/gcc. Most of the warnings appeared at link time.

lto-wrapper: warning: using serial compilation of 23 LTRANS jobs
In member function ‘length’,
    inlined from ‘setTo’ at ../../common/unicode/unistr.h:5015:17,
    inlined from ‘u_getFC_NFKC_Closure_79’ at ../../common/uprops.cpp:1019:28:
../../common/unicode/unistr.h:4274:27: warning: ‘folded1String.fUnion.fFields.fLength’ may be used uninitialized [-Wmaybe-uninitialized]
 4274 |   return hasShortLength() ? getShortLength() : fUnion.fFields.fLength;
      |                           ^
../../common/uprops.cpp: In function ‘u_getFC_NFKC_Closure_79’:
../../common/uprops.cpp:1011:19: note: ‘folded1String’ declared here
 1011 |     UnicodeString folded1String;
      |                   ^
In member function ‘length’,
    inlined from ‘setTo’ at ../../common/unicode/unistr.h:5015:17,
    inlined from ‘u_getFC_NFKC_Closure_79’ at ../../common/uprops.cpp:1022:32:
../../common/unicode/unistr.h:4274:27: warning: ‘folded1String.fUnion.fFields.fLength’ may be used uninitialized [-Wmaybe-uninitialized]
 4274 |   return hasShortLength() ? getShortLength() : fUnion.fFields.fLength;
      |                           ^
../../common/uprops.cpp: In function ‘u_getFC_NFKC_Closure_79’:
../../common/uprops.cpp:1011:19: note: ‘folded1String’ declared here
 1011 |     UnicodeString folded1String;
      |                   ^
../../i18n/astro.cpp: In static member function ‘static icu_79::CalendarAstronomer::MoonAge icu_79::CalendarAstronomer::NEW_MOON()’:
../../i18n/astro.cpp:653:58: note: parameter passing for argument of type ‘icu_79::CalendarAstronomer::MoonAge’ when C++17 is enabled changed to match C++14 in GCC 10.1
  653 | CalendarAstronomer::MoonAge CalendarAstronomer::NEW_MOON() {
      |                                                          ^
../../i18n/chnsecal.cpp: In function ‘int32_t icu_79::{anonymous}::newMoonNear(const icu_79::TimeZone*, double, UBool, UErrorCode&)’:
../../i18n/chnsecal.cpp:661:56: note: parameter passing for argument of type ‘icu_79::CalendarAstronomer::MoonAge’ when C++17 is enabled changed to match C++14 in GCC 10.1
  661 |               .getMoonTime(CalendarAstronomer::NEW_MOON(), after),
      |                            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~
lto-wrapper: warning: using serial compilation of 42 LTRANS jobs
In function ‘NEW_MOON’:
lto1: note: parameter passing for argument of type ‘struct MoonAge’ when C++17 is enabled changed to match C++14 in GCC 10.1
../../i18n/chnsecal.cpp: In function ‘newMoonNear’:
../../i18n/chnsecal.cpp:650:9: note: parameter passing for argument of type ‘struct MoonAge’ when C++17 is enabled changed to match C++14 in GCC 10.1
  650 | int32_t newMoonNear(const TimeZone* timeZone, double days, UBool after, UErrorCode& status) {
      |         ^
../../i18n/decNumber.cpp: In function ‘uprv_decNumberLog10_79’:
../../i18n/decNumber.cpp:1528:14: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=]
 1528 |     w->lsu[1]=1; w->lsu[0]=0;           /* ..  */
      |              ^
../../i18n/decNumber.h:89:19: note: at offset 1 into destination object ‘lsu’ of size 1
   89 |     decNumberUnit lsu[DECNUMUNITS];
      |                   ^
../../i18n/decNumber.cpp:1528:14: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=]
 1528 |     w->lsu[1]=1; w->lsu[0]=0;           /* ..  */
      |              ^
../../i18n/decNumber.h:89:19: note: at offset 1 into destination object ‘lsu’ of size 1
   89 |     decNumberUnit lsu[DECNUMUNITS];
      |                   ^
../../i18n/decNumber.cpp: In function ‘uprv_decNumberSquareRoot_79’:
../../i18n/decNumber.cpp:2974:31: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=]
 2974 |         t->lsu[0]=9; t->lsu[1]=5; t->lsu[2]=2;
      |                               ^
../../i18n/decNumber.h:89:19: note: at offset 1 into destination object ‘lsu’ of size 1
   89 |     decNumberUnit lsu[DECNUMUNITS];
      |                   ^
../../i18n/decNumber.cpp:2974:44: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=]
 2974 |         t->lsu[0]=9; t->lsu[1]=5; t->lsu[2]=2;
      |                                            ^
../../i18n/decNumber.h:89:19: note: at offset 2 into destination object ‘lsu’ of size 1
   89 |     decNumberUnit lsu[DECNUMUNITS];
      |                   ^
../../i18n/formattedvalue.cpp: In function ‘ufmtval_getString_79’:
lto1: warning: function may return address of local variable [-Wreturn-local-addr]
../../i18n/formattedvalue.cpp:210:19: note: declared here
  210 |     UnicodeString readOnlyAlias = impl->fFormattedValue->toTempString(*ec);
      |                   ^
../../i18n/number_mapper.cpp: In function ‘oldToNew’:
../../i18n/number_mapper.cpp:151:49: warning: ‘currencyUsage’ may be used uninitialized in this function [-Wmaybe-uninitialized]
  151 |         precision = Precision::constructCurrency(currencyUsage);
      |                                                 ^
../../i18n/number_mapper.cpp:78:20: note: ‘currencyUsage’ was declared here
   78 |     UCurrencyUsage currencyUsage;
      |                    ^
In member function ‘handleReplaceBetween’,
    inlined from ‘handleTransliterate’ at ../../i18n/remtrans.cpp:64:30:
../../i18n/utrans.cpp:115:21: warning: ‘empty’ may be used uninitialized [-Wmaybe-uninitialized]
  115 |     (*func->replace)(rep, start, limit, text.getBuffer(), text.length());
      |                     ^
../../i18n/remtrans.cpp: In member function ‘handleTransliterate’:
../../i18n/utrans.cpp:115:21: note: by argument 4 of type ‘const UChar *’ to ‘void <Tf88> (void * *, int32_t, int32_t, const UChar *, int32_t)’
../../i18n/remtrans.cpp:63:19: note: ‘empty’ declared here
   63 |     UnicodeString empty;
      |                   ^
lto-wrapper: warning: using serial compilation of 2 LTRANS jobs
../../../tools/genrb/parse.cpp: In function ‘parseIntVector’:
../../../tools/genrb/parse.cpp:1775:9: warning: ‘stringLength’ may be used uninitialized in this function [-Wmaybe-uninitialized]
 1775 |         if(len==stringLength)
      |         ^
../../../tools/genrb/parse.cpp:1762:17: note: ‘stringLength’ was declared here
 1762 |         int32_t stringLength;
      |                 ^
lto-wrapper: warning: using serial compilation of 128 LTRANS jobs
In function ‘itoa’,
    inlined from ‘TestIteration’ at ../../../test/intltest/restsnew.cpp:404:39:
../../../test/intltest/restest.cpp:108:16: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=]
  108 |         *buf++ = *p;
      |                ^
../../../test/intltest/restest.cpp:108:16: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=]
In function ‘itoa’,
    inlined from ‘TestIteration’ at ../../../test/intltest/restsnew.cpp:412:51:
../../../test/intltest/restest.cpp:108:16: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=]
  108 |         *buf++ = *p;
      |                ^
../../../test/intltest/restest.cpp:108:16: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=]
In function ‘itoa’,
    inlined from ‘TestIteration’ at ../../../test/intltest/restsnew.cpp:413:51:
../../../test/intltest/restest.cpp:108:16: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=]
  108 |         *buf++ = *p;
      |                ^
../../../test/intltest/restest.cpp:108:16: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=]
In function ‘itoa’,
    inlined from ‘TestOtherAPI’ at ../../../test/intltest/restsnew.cpp:618:43:
../../../test/intltest/restest.cpp:108:16: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=]
  108 |         *buf++ = *p;
      |                ^
../../../test/intltest/restest.cpp:108:16: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=]
In function ‘itoa’,
    inlined from ‘TestOtherAPI’ at ../../../test/intltest/restsnew.cpp:629:55:
../../../test/intltest/restest.cpp:108:16: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=]
  108 |         *buf++ = *p;
      |                ^
../../../test/intltest/restest.cpp:108:16: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=]
In function ‘itoa’,
    inlined from ‘TestOtherAPI’ at ../../../test/intltest/restsnew.cpp:630:55:
../../../test/intltest/restest.cpp:108:16: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=]
  108 |         *buf++ = *p;
      |                ^
../../../test/intltest/restest.cpp:108:16: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=]
lto-wrapper: warning: using serial compilation of 23 LTRANS jobs
In function ‘itoa1’,
    inlined from ‘testTag.isra’ at ../../../test/cintltst/creststn.c:1814:37:
../../../test/cintltst/creststn.c:114:12: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=]
  114 |     *buf++ = *p;
      |            ^
../../../test/cintltst/creststn.c:114:12: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=]
In function ‘itoa1’,
    inlined from ‘testTag.isra’ at ../../../test/cintltst/creststn.c:1853:41:
../../../test/cintltst/creststn.c:114:12: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=]
  114 |     *buf++ = *p;
      |            ^
../../../test/cintltst/creststn.c:114:12: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=]
In function ‘itoa1’,
    inlined from ‘testTag.isra’ at ../../../test/cintltst/creststn.c:1904:45:
../../../test/cintltst/creststn.c:114:12: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=]
  114 |     *buf++ = *p;
      |            ^
../../../test/cintltst/creststn.c:114:12: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=]
In function ‘itoa1’,
    inlined from ‘testTag.isra’ at ../../../test/cintltst/creststn.c:1953:37:
../../../test/cintltst/creststn.c:114:12: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=]
  114 |     *buf++ = *p;
      |            ^
../../../test/cintltst/creststn.c:114:12: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=]
In function ‘itoa1’,
    inlined from ‘testTag.isra’ at ../../../test/cintltst/creststn.c:1955:37:
../../../test/cintltst/creststn.c:114:12: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=]
  114 |     *buf++ = *p;
      |            ^
../../../test/cintltst/creststn.c:114:12: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=]
In function ‘itoa1’,
    inlined from ‘testTag.isra’ at ../../../test/cintltst/creststn.c:2013:30:
../../../test/cintltst/creststn.c:114:12: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=]
  114 |     *buf++ = *p;
      |            ^
../../../test/cintltst/creststn.c:114:12: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=]
In function ‘itoa1’,
    inlined from ‘testTag.isra’ at ../../../test/cintltst/creststn.c:2039:45:
../../../test/cintltst/creststn.c:114:12: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=]
  114 |     *buf++ = *p;
      |            ^
../../../test/cintltst/creststn.c:114:12: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=]

@grhoten
Copy link
Member Author

grhoten commented Nov 8, 2025

@markusicu Do you want to approve this as is, or do you want me to address these new gcc warnings in this pull request too? After a quick look, all of the warnings seem fixable.

@grhoten
Copy link
Member Author

grhoten commented Nov 9, 2025

Some of the warnings seemed legitimate. I fixed what I could easily fix. The rest require deeper analysis. Here's what's left.

In member function ‘length’,
    inlined from ‘setTo’ at ../../common/unicode/unistr.h:5015:17,
    inlined from ‘u_getFC_NFKC_Closure_79’ at ../../common/uprops.cpp:1019:28:
../../common/unicode/unistr.h:4274:27: warning: ‘folded1String.fUnion.fFields.fLength’ may be used uninitialized [-Wmaybe-uninitialized]
 4274 |   return hasShortLength() ? getShortLength() : fUnion.fFields.fLength;
      |                           ^
../../common/uprops.cpp: In function ‘u_getFC_NFKC_Closure_79’:
../../common/uprops.cpp:1011:19: note: ‘folded1String’ declared here
 1011 |     UnicodeString folded1String;
      |                   ^
In member function ‘length’,
    inlined from ‘setTo’ at ../../common/unicode/unistr.h:5015:17,
    inlined from ‘u_getFC_NFKC_Closure_79’ at ../../common/uprops.cpp:1022:32:
../../common/unicode/unistr.h:4274:27: warning: ‘folded1String.fUnion.fFields.fLength’ may be used uninitialized [-Wmaybe-uninitialized]
 4274 |   return hasShortLength() ? getShortLength() : fUnion.fFields.fLength;
      |                           ^
../../common/uprops.cpp: In function ‘u_getFC_NFKC_Closure_79’:
../../common/uprops.cpp:1011:19: note: ‘folded1String’ declared here
 1011 |     UnicodeString folded1String;
      |                   ^
../../i18n/formattedvalue.cpp: In function ‘ufmtval_getString_79’:
lto1: warning: function may return address of local variable [-Wreturn-local-addr]
../../i18n/formattedvalue.cpp:210:19: note: declared here
  210 |     UnicodeString readOnlyAlias = impl->fFormattedValue->toTempString(*ec);
      |                   ^
In member function ‘handleReplaceBetween’,
    inlined from ‘handleTransliterate’ at ../../i18n/remtrans.cpp:64:30:
../../i18n/utrans.cpp:115:21: warning: ‘empty’ may be used uninitialized [-Wmaybe-uninitialized]
  115 |     (*func->replace)(rep, start, limit, text.getBuffer(), text.length());
      |                     ^
../../i18n/remtrans.cpp: In member function ‘handleTransliterate’:
../../i18n/utrans.cpp:115:21: note: by argument 4 of type ‘const UChar *’ to ‘void <Tf88> (void * *, int32_t, int32_t, const UChar *, int32_t)’
../../i18n/remtrans.cpp:63:19: note: ‘empty’ declared here
   63 |     UnicodeString empty;
      |                   ^
../../i18n/decNumber.cpp: In function ‘uprv_decNumberLog10_79’:
../../i18n/decNumber.cpp:1528:14: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=]
 1528 |     w->lsu[1]=1; w->lsu[0]=0;           /* ..  */
      |              ^
../../i18n/decNumber.h:89:19: note: at offset 1 into destination object ‘lsu’ of size 1
   89 |     decNumberUnit lsu[DECNUMUNITS];
      |                   ^
../../i18n/decNumber.cpp:1528:14: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=]
 1528 |     w->lsu[1]=1; w->lsu[0]=0;           /* ..  */
      |              ^
../../i18n/decNumber.h:89:19: note: at offset 1 into destination object ‘lsu’ of size 1
   89 |     decNumberUnit lsu[DECNUMUNITS];
      |                   ^
../../i18n/decNumber.cpp: In function ‘uprv_decNumberSquareRoot_79’:
../../i18n/decNumber.cpp:2974:31: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=]
 2974 |         t->lsu[0]=9; t->lsu[1]=5; t->lsu[2]=2;
      |                               ^
../../i18n/decNumber.h:89:19: note: at offset 1 into destination object ‘lsu’ of size 1
   89 |     decNumberUnit lsu[DECNUMUNITS];
      |                   ^
../../i18n/decNumber.cpp:2974:44: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=]
 2974 |         t->lsu[0]=9; t->lsu[1]=5; t->lsu[2]=2;
      |                                            ^
../../i18n/decNumber.h:89:19: note: at offset 2 into destination object ‘lsu’ of size 1
   89 |     decNumberUnit lsu[DECNUMUNITS];
      |                   ^
../../../tools/genrb/parse.cpp: In function ‘parseIntVector’:
../../../tools/genrb/parse.cpp:1775:9: warning: ‘stringLength’ may be used uninitialized in this function [-Wmaybe-uninitialized]
 1775 |         if(len==stringLength)
      |         ^
../../../tools/genrb/parse.cpp:1762:17: note: ‘stringLength’ was declared here
 1762 |         int32_t stringLength;
      |                 ^

@grhoten
Copy link
Member Author

grhoten commented Nov 18, 2025

Regarding one of the warnings, the warning on uprops.cpp:1022 seems to be an unreachable line, and it seems to be a bad line if it were reachable. That line should actually be setting the *pErrorCode and returning instead.

@markusicu
Copy link
Member

Is the warnings discussion actually for the other PR about static initialization?

@grhoten
Copy link
Member Author

grhoten commented Nov 22, 2025

The warnings commentary is due to this option being used. These are new warnings from g++ that I observed. It's doing a deeper analysis of the code that cross function boundaries.

@jira-pull-request-webhook
Copy link

Hooray! The files in the branch are the same across the force-push. 😃

~ Your Friendly Jira-GitHub PR Checker Bot

@grhoten grhoten merged commit 2a888f7 into unicode-org:main Nov 22, 2025
97 checks passed
@grhoten grhoten deleted the optimization branch November 26, 2025 07:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants