You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
System.Globalization.Native: configure checks ignore CMAKE_ICU_DIR's headers on Unix targets other than wasm #135571
When CMAKE_ICU_DIR is passed for a Unix target other than Android, Apple, Browser and WASI, the two configure checks in System.Globalization.Native/configure.cmake compile without ${CMAKE_ICU_DIR}/include. Without system ICU headers both fail, config.h gets 0 for both, and the build still succeeds. With system ICU headers installed, the checks read those instead.
The bug is latent upstream. Only eng/native.wasm.targets passes CMAKE_ICU_DIR, for wasm, and wasm takes the hard-coded branch at the top of configure.cmake. Other Unix targets hit the bug only with -cmakeargs -DCMAKE_ICU_DIR=<dir> passed by hand.
With CMAKE_ICU_DIR defined, CMakeLists.txt skips find_path(UCURR_H ...), so UCURR_H is empty here:
pal_collation.c:340:27: error: 'ucol_safeClone_78' is deprecated [-Werror,-Wdeprecated-declarations]
Regression?
No: CMAKE_ICU_DIR first appears in CMakeLists.txt in 0fc8978 (#82393), and configure.cmake has never named it.
Known Workarounds
System ICU headers: the checks then describe that ICU, not the static one.
Configuration
Ubuntu 24.04.4 LTS, x64, clang 18.1.3, CMake 3.28.3, static ICU 78.3, without and with libicu-dev 74.2; ./build.sh libs.native -c Release. Not tried on other OSes.
Other information
Proposed fix: append ${CMAKE_ICU_DIR}/include to CMAKE_REQUIRED_INCLUDES in configure.cmake when CMAKE_ICU_DIR is defined. With it the reproduction prints both values as 1, the -WerrorLOCAL_BUILD builds without warnings, and a normal build produces a byte-identical libSystem.Globalization.Native.so.
Options not taken:
Treat CMAKE_ICU_DIR as wasm-only: nothing in the repo says so, and CMakeLists.txt:86-88 applies it to every target but Apple mobile.
Move include_directories(${CMAKE_ICU_DIR}/include) above include(configure.cmake): CMake ignores the INCLUDE_DIRECTORIES directory property in these checks; only CMAKE_REQUIRED_INCLUDES counts.
Set UCURR_H to ${CMAKE_ICU_DIR}/include in CMakeLists.txt: would also work, but gives the find_path result a second meaning, away from the checks.
I have a fix ready and will open a PR for it shortly. Could this be assigned to me?
Note
AI-generated, written at my direction and reviewed by me before posting.
Measured on dotnet/runtime d148189 with the Configuration above: the reproduction block, with and without the fix; the same build with libicu-dev installed, reading the checks' compile lines in CMakeConfigureLog.yaml; the LOCAL_BUILD commands; ./build.sh libs.native -c Release with and without the fix, comparing sha256sum of the .so.
Description
When
CMAKE_ICU_DIRis passed for a Unix target other than Android, Apple, Browser and WASI, the two configure checks inSystem.Globalization.Native/configure.cmakecompile without${CMAKE_ICU_DIR}/include. Without system ICU headers both fail,config.hgets 0 for both, and the build still succeeds. With system ICU headers installed, the checks read those instead.The bug is latent upstream. Only
eng/native.wasm.targetspassesCMAKE_ICU_DIR, for wasm, and wasm takes the hard-coded branch at the top ofconfigure.cmake. Other Unix targets hit the bug only with-cmakeargs -DCMAKE_ICU_DIR=<dir>passed by hand.With
CMAKE_ICU_DIRdefined,CMakeLists.txtskipsfind_path(UCURR_H ...), soUCURR_His empty here:configure.cmake:14-15${CMAKE_ICU_DIR}/includeis added only afterinclude(configure.cmake)(CMakeLists.txt:59):CMakeLists.txt:86-87Reproduction Steps
On linux-x64 with no ICU development headers installed, from the root of a clone at d148189:
Expected behavior
ICU 78.3 has both
UDAT_STANDALONE_SHORTER_WEEKDAYSanducol_clone:Actual behavior
artifacts/obj/native/net11.0-linux-Release-x64/CMakeFiles/CMakeConfigureLog.yaml(paths shortened):With
HAVE_UDAT_STANDALONE_SHORTER_WEEKDAYS 0, super-short day names use the narrow ones:pal_calendarData.c:517-521HAVE_UCOL_CLONEis read only underSTATIC_ICU, which theLOCAL_BUILDconfiguration ofsrc/native/libs/build-local.shdefines:pal_collation.c:337-341Configured that way with
CMAKE_ICU_DIRadded by hand, both values are 0 again, and with-DCMAKE_C_FLAGS=-Werrorthe build fails:Regression?
No:
CMAKE_ICU_DIRfirst appears inCMakeLists.txtin 0fc8978 (#82393), andconfigure.cmakehas never named it.Known Workarounds
System ICU headers: the checks then describe that ICU, not the static one.
Configuration
Ubuntu 24.04.4 LTS, x64, clang 18.1.3, CMake 3.28.3, static ICU 78.3, without and with
libicu-dev74.2;./build.sh libs.native -c Release. Not tried on other OSes.Other information
Proposed fix: append
${CMAKE_ICU_DIR}/includetoCMAKE_REQUIRED_INCLUDESinconfigure.cmakewhenCMAKE_ICU_DIRis defined. With it the reproduction prints both values as 1, the-WerrorLOCAL_BUILDbuilds without warnings, and a normal build produces a byte-identicallibSystem.Globalization.Native.so.Options not taken:
CMAKE_ICU_DIRas wasm-only: nothing in the repo says so, andCMakeLists.txt:86-88applies it to every target but Apple mobile.include_directories(${CMAKE_ICU_DIR}/include)aboveinclude(configure.cmake): CMake ignores theINCLUDE_DIRECTORIESdirectory property in these checks; onlyCMAKE_REQUIRED_INCLUDEScounts.UCURR_Hto${CMAKE_ICU_DIR}/includeinCMakeLists.txt: would also work, but gives thefind_pathresult a second meaning, away from the checks.I have a fix ready and will open a PR for it shortly. Could this be assigned to me?
Note
AI-generated, written at my direction and reviewed by me before posting.
Measured on dotnet/runtime d148189 with the Configuration above: the reproduction block, with and without the fix; the same build with
libicu-devinstalled, reading the checks' compile lines inCMakeConfigureLog.yaml; theLOCAL_BUILDcommands;./build.sh libs.native -c Releasewith and without the fix, comparingsha256sumof the.so.