libzim icon indicating copy to clipboard operation
libzim copied to clipboard

Fix build with ICU 76

Open cho-m opened this issue 1 year ago • 12 comments

Due to unicode-org/icu@199bc82, ICU 76 no longer adds icu-uc by default. This causes linker errors for undefined symbols like icu_76::UnicodeString::doReplace(...), referenced from: zim::removeAccents(...) in tools.cpp.o.

Meson will automatically flatten the dependencies list as documented at https://mesonbuild.com/Reference-manual_functions.html#build_target


There didn't seem to be any usage of icu_dep methods and only passing it to dependencies: [..., icu_dep, ...]. If this changes, then may need to use multiple variables.

cho-m avatar Oct 31 '24 15:10 cho-m

Linux CI has an unrelated failure trying to find software-properties-common which isn't available in Debian Trixie.


Windows CI has a related failure as it looks like icu-i18n.pc is manually created.

Maybe a workaround like:

dependency('icu-uc', required: host_machine.system() != 'windows', static:static_linkage)

or

icu_dep = [dependency('icu-i18n', required:xapian_dep.found(), static:static_linkage)]
if build_machine.system() != 'windows'
    icu_dep += [dependency('icu-uc', required:xapian_dep.found(), static:static_linkage)]
endif

cho-m avatar Oct 31 '24 18:10 cho-m

@cho-m Thank you for your PR. CI was OK a month ago, I will have a look and try to fix them so we can test your PR properly.

kelson42 avatar Oct 31 '24 18:10 kelson42

@cho-m I have fixed a few things but we have a serious problem with the Windows CI. The CI for Windows does not pass for the moment on main either... although it does not block at the line you have added. My that be that your code is not compatible with older version of libicu? https://github.com/kiwix/kiwix-build/blob/main/kiwixbuild/dependencies/icu4c.py

kelson42 avatar Dec 20 '24 17:12 kelson42

code is not compatible with older version of libicu? https://github.com/kiwix/kiwix-build/blob/main/kiwixbuild/dependencies/icu4c.py

The official (Unix) pkgconfig files are compatible (icu-uc.pc has been around as long as icu-i18n.pc, i.e. ICU 59 - https://github.com/unicode-org/icu/commit/d39075895576f183ef9756aabe34db8b64e6af38)

However, Windows build is using custom/3rd-party pkgconfig files. Ideally would have provided other pkgconfig files like Cygwin (https://cygwin.com/packages/x86_64/libicu-devel/libicu-devel-73.2-1)

    2023-08-03 01:02        1232 usr/lib/pkgconfig/icu-i18n.pc
    2023-08-03 01:02        1224 usr/lib/pkgconfig/icu-io.pc
    2023-08-03 01:02        1256 usr/lib/pkgconfig/icu-uc.pc

Anyways, PR most likely needs a build_machine.system() != 'windows' conditional to work around Windows.

cho-m avatar Dec 20 '24 18:12 cho-m

@veloman-yunkan @cho-m I can not merge this PR right now because it brakes the CI on Windows. From what I understand, I see only one way to solve this (and just ignoring Windows seems a dirty fix). Open an issue in kiwix/kiwix-build and fix how we deal with libicu on Windows there. Seems anyway pretty much linked to https://github.com/kiwix/kiwix-build/issues/750 which seems to be a blocker for that PR then. Do I'm correct?

kelson42 avatar Dec 22 '24 10:12 kelson42

@kelson42 I am fine with that.

veloman-yunkan avatar Dec 22 '24 10:12 veloman-yunkan

From what I understand, I see only one way to solve this (and just ignoring Windows seems a dirty fix).

Could do a version check - https://mesonbuild.com/Reference-manual_returned_dep.html#depversion

Maybe something like:

icu_dep = dependency('icu-i18n', static:static_linkage)
if icu_dep.version().version_compare('>= 76')
  icu_dep = [icu_dep, dependency('icu-uc', static:static_linkage)]
endif

cho-m avatar Dec 22 '24 18:12 cho-m

I've included a 9.1.0 variant of this patch in the Arch Linux icu76 rebuild.

hashworks avatar Feb 11 '25 17:02 hashworks

Also included in Nix btw

https://github.com/NixOS/nixpkgs/pull/385849

shenlebantongying avatar Mar 07 '25 15:03 shenlebantongying

Codecov Report

:white_check_mark: All modified and coverable lines are covered by tests. :white_check_mark: Project coverage is 58.13%. Comparing base (1db4abe) to head (a03846b). :warning: Report is 3 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #936   +/-   ##
=======================================
  Coverage   58.13%   58.13%           
=======================================
  Files         101      101           
  Lines        5384     5384           
  Branches     2197     2197           
=======================================
  Hits         3130     3130           
  Misses        795      795           
  Partials     1459     1459           

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

:rocket: New features to boost your workflow:
  • :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

codecov[bot] avatar Apr 16 '25 15:04 codecov[bot]

@cho-m Please

From what I understand, I see only one way to solve this (and just ignoring Windows seems a dirty fix).

Could do a version check - https://mesonbuild.com/Reference-manual_returned_dep.html#depversion

Maybe something like:

icu_dep = dependency('icu-i18n', static:static_linkage)
if icu_dep.version().version_compare('>= 76')
  icu_dep = [icu_dep, dependency('icu-uc', static:static_linkage)]
endif

@cho-m Please do and rerequest review

kelson42 avatar Apr 16 '25 15:04 kelson42

@cho-m Any feedback or have you abandoned this PR?

kelson42 avatar Jun 05 '25 09:06 kelson42

Supersseded by #1010 (same code, just with the libicu version condition proposed by @cho-m)

@shenlebantongying @hashworks So, will finally be part of the soon to be released libzim 9.4.0. If everything goes right you should not need anymore your custom patches.

kelson42 avatar Oct 08 '25 15:10 kelson42