From 4c5b0e3a5d8b2ae3055e84038c3aa04ed2a56511 Mon Sep 17 00:00:00 2001 From: Randy Eckenrode Date: Mon, 19 Jan 2026 19:38:26 -0500 Subject: [PATCH] darwin.ICU: avoid conflicts with the system libicucore The ICU C++ ABI is not stable and can change from version to version. If the system `libicucore.A.dylib` is pulled into a process at the same time as `libicucore.A.dylib` from Nixpkgs, it can result in a crash when those two dylibs are from different ICU versions. For example, macOS 26.4 appears to have updated ICU to ICU 78, but the source release packages is still ICU 76. This causes `dotnet --info` to crash when it tries to load `libicucore.dylib`, gets both, and the symbols get mixed up. This patch avoids the issue by adding a version suffix to the C++ symbols. When `dotnet` loads `libicucore.dylib`, the symbols are resolved correctly, and it no longer crashes. Note that the C symbols are note versioned because they are exported as the stable ABI. --- pkgs/os-specific/darwin/by-name/ic/ICU/package.nix | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/pkgs/os-specific/darwin/by-name/ic/ICU/package.nix b/pkgs/os-specific/darwin/by-name/ic/ICU/package.nix index 27d7af4b0b95..f742f4743807 100644 --- a/pkgs/os-specific/darwin/by-name/ic/ICU/package.nix +++ b/pkgs/os-specific/darwin/by-name/ic/ICU/package.nix @@ -133,6 +133,16 @@ let --replace-fail '$(top_srcdir)/../LICENSE' "$NIX_BUILD_TOP/source/icu/LICENSE" substituteInPlace config/dist-data.sh \ --replace-fail "\''${top_srcdir}/../LICENSE" "$NIX_BUILD_TOP/source/icu/LICENSE" + + # Make sure this ICU build puts C++ symbols in a distinct namespace to avoid symbol clashes with other ICU + # implementations (including both the system ICU and builds of the upstream ICU). + # This breaks binary compatibility for the C++ API, but it’s not ABI stable anyway. Without doing this, + # `dotnet` crashes on macOS 26.4 when linked against `libicucore.A.dylib` from Nixpkgs. + substituteInPlace common/unicode/uvernum.h \ + --replace-fail 'U_ICU_VERSION_SUFFIX ' 'U_ICU_VERSION_SUFFIX _nix' + # Only enable symbol renaming for C++ symbols. C symbols need to remain unversioned for compatibility. + substituteInPlace common/unicode/uversion.h \ + --replace-fail U_DISABLE_RENAMING 0 ''; # remove dependency on bootstrap-tools in early stdenv build