text-icu icon indicating copy to clipboard operation
text-icu copied to clipboard

`ld: warning: search path '/usr/local/opt/icu4c/lib' not found` on ghcup GHC+cabal & homebrew icu4c setup

Open benjaminweb opened this issue 1 year ago • 1 comments

cabal build raises ld: warning: search path '/usr/local/opt/icu4c/lib' not found

environment: GHC 9.10.1 cabal 3.12.1.0 managed through ghcup

icu4c managed through homebrew:

> brew info icu4c
==> icu4c@76: stable 76.1 (bottled) [keg-only]
C/C++ and Java libraries for Unicode and globalization
https://icu.unicode.org/home
Installed
/opt/homebrew/Cellar/icu4c@76/76.1_1 (277 files, 81MB) *
  Poured from bottle using the formulae.brew.sh API on 2024-11-11 at 14:41:47
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/i/[email protected]
License: ICU
==> Caveats
icu4c@76 is keg-only, which means it was not symlinked into /opt/homebrew,
because macOS provides libicucore.dylib (but nothing else).

If you need to have icu4c@76 first in your PATH, run:
  fish_add_path /opt/homebrew/opt/icu4c@76/bin
  fish_add_path /opt/homebrew/opt/icu4c@76/sbin

For compilers to find icu4c@76 you may need to set:
  set -gx LDFLAGS "-L/opt/homebrew/opt/icu4c@76/lib"
  set -gx CPPFLAGS "-I/opt/homebrew/opt/icu4c@76/include"

For pkg-config to find icu4c@76 you may need to set:
  set -gx PKG_CONFIG_PATH "/opt/homebrew/opt/icu4c@76/lib/pkgconfig"
> echo $PKG_CONFIG_PATH
/opt/homebrew/opt/icu4c@76/lib/pkgconfig

benjaminweb avatar Nov 13 '24 12:11 benjaminweb

/usr/local/opt/icu4c/libis searched because it is specified at https://github.com/haskell/text-icu/blob/32a90ab4c66980621d56b1a1dc70bd6016e28141/text-icu.cabal#L132

It doesn't exist on Apple silicon machines.

This could be solved by switching

  • /usr/local/opt/icu4c/lib for non-Apple silicon
  • /opt/homebrew/opt/icu4c/lib for Apple silicon

To my knowledge there is no way to determine whether we are on Apple silicon within a cabal file. Is that true?

benjaminweb avatar Nov 13 '24 12:11 benjaminweb

There is the arch condition, maybe that could be used: https://cabal.readthedocs.io/en/3.14/cabal-package-description-file.html#conditions

if os(darwin) && arch(aarch64)

andreasabel avatar May 13 '25 08:05 andreasabel