google / rust_icu

rust_icu: rust bindings for ICU (International Components for Unicode) library
Apache License 2.0
117 stars 28 forks source link

Building rust_icu on NixOS #189

Closed suhr closed 3 years ago

suhr commented 3 years ago

The compilation of rust_icu on NixOS fails with the following message:

error: failed to run custom build command for `rust_icu_sys v0.4.1 (registry `ssh://git@gitlab.radicum.team/common-utils/crates-index.git`)`

Caused by:
  process didn't exit successfully: `/home/suhr/Projects/work/db/local-target/release/build/rust_icu_sys-11ae63ac84826367/build-script-build` (exit code: 1)
  --- stdout
  cargo:rustc-cfg=feature="renaming"
  cargo:rustc-cfg=feature="use-bindgen"
  cargo:rustc-cfg=feature="icu_config"
  icu-version-major: 67
  cargo:rustc-cfg=feature="icu_version_64_plus"
  cargo:rustc-cfg=feature="icu_version_67_plus"
  icu-version: 67.1
  icu-cppflags: -I/nix/store/7flw8mxs28mk2r1wsnyas1y59j4hjr7a-icu4c-67.1-dev/include
  icu-has-renaming: true
  include-file: '/nix/store/wn2hcvdk7dzc7l3f340sva6lhkbmmsgd-icu4c-67.1/include/unicode/ubrk.h'
  include-file: '/nix/store/wn2hcvdk7dzc7l3f340sva6lhkbmmsgd-icu4c-67.1/include/unicode/ucal.h'
  include-file: '/nix/store/wn2hcvdk7dzc7l3f340sva6lhkbmmsgd-icu4c-67.1/include/unicode/uclean.h'
  include-file: '/nix/store/wn2hcvdk7dzc7l3f340sva6lhkbmmsgd-icu4c-67.1/include/unicode/ucnv.h'
  include-file: '/nix/store/wn2hcvdk7dzc7l3f340sva6lhkbmmsgd-icu4c-67.1/include/unicode/ucol.h'
  include-file: '/nix/store/wn2hcvdk7dzc7l3f340sva6lhkbmmsgd-icu4c-67.1/include/unicode/udat.h'
  include-file: '/nix/store/wn2hcvdk7dzc7l3f340sva6lhkbmmsgd-icu4c-67.1/include/unicode/udata.h'
  include-file: '/nix/store/wn2hcvdk7dzc7l3f340sva6lhkbmmsgd-icu4c-67.1/include/unicode/uenum.h'
  include-file: '/nix/store/wn2hcvdk7dzc7l3f340sva6lhkbmmsgd-icu4c-67.1/include/unicode/umisc.h'
  include-file: '/nix/store/wn2hcvdk7dzc7l3f340sva6lhkbmmsgd-icu4c-67.1/include/unicode/umsg.h'
  include-file: '/nix/store/wn2hcvdk7dzc7l3f340sva6lhkbmmsgd-icu4c-67.1/include/unicode/unum.h'
  include-file: '/nix/store/wn2hcvdk7dzc7l3f340sva6lhkbmmsgd-icu4c-67.1/include/unicode/upluralrules.h'
  include-file: '/nix/store/wn2hcvdk7dzc7l3f340sva6lhkbmmsgd-icu4c-67.1/include/unicode/uset.h'
  include-file: '/nix/store/wn2hcvdk7dzc7l3f340sva6lhkbmmsgd-icu4c-67.1/include/unicode/ustring.h'
  include-file: '/nix/store/wn2hcvdk7dzc7l3f340sva6lhkbmmsgd-icu4c-67.1/include/unicode/utext.h'
  include-file: '/nix/store/wn2hcvdk7dzc7l3f340sva6lhkbmmsgd-icu4c-67.1/include/unicode/utrans.h'

  --- stderr
  warning: argument unused during compilation: '-L /nix/store/wn2hcvdk7dzc7l3f340sva6lhkbmmsgd-icu4c-67.1/lib -l icui18n -l icuuc -l icudata' [-Wunused-command-line-argument]
  /home/suhr/Projects/work/db/local-target/release/build/rust_icu_sys-eb191c7200baf6f8/out/wrapper.h:2:10: fatal error: '/nix/store/wn2hcvdk7dzc7l3f340sva6lhkbmmsgd-icu4c-67.1/include/unicode/ubrk.h' file not found
  warning: argument unused during compilation: '-L /nix/store/wn2hcvdk7dzc7l3f340sva6lhkbmmsgd-icu4c-67.1/lib -l icui18n -l icuuc -l icudata' [-Wunused-command-line-argument], err: false
  /home/suhr/Projects/work/db/local-target/release/build/rust_icu_sys-eb191c7200baf6f8/out/wrapper.h:2:10: fatal error: '/nix/store/wn2hcvdk7dzc7l3f340sva6lhkbmmsgd-icu4c-67.1/include/unicode/ubrk.h' file not found, err: true
  Error: while running bindgen

  Caused by:
      could not generate bindings

The reason why it does so is because Nix splits the ICU package into two outputs: out and dev, each of which has different path

While it's reasonable to rely on icu-config --prefix to provide the path for everything, it would be nice to have a way to use a split ICU package. Note that though icu-config --prefix provides an incorrect path for includes, icu-config --cppflags and pkg-config icu-uc --cflags provide correct compiler flags: -I/nix/store/7flw8mxs28mk2r1wsnyas1y59j4hjr7a-icu4c-67.1-dev/include.

A related Nixpkgs issue: https://github.com/NixOS/nixpkgs/issues/106567

filmil commented 3 years ago

Thank you for the report. I'll check if there is a way to make the setup more flexible so that this is a non-issue.

OTOH, https://github.com/NixOS/nixpkgs/issues/106567 seems to suggest that the nixpkg build process breaks the assumptions of the package it is building. I'd think that this is perhaps a more fundamental issue, and that one likely needs to be resolved as well.

filmil commented 3 years ago

@suhr could you try https://github.com/google/rust_icu/pull/190 to see if it helps?

filmil commented 3 years ago

PR #190 is now merged: it doesn't break any builds, so it doesn't make matters worse. If @suhr confirms that this helps, perhaps we can close this bug. Sadly I don't have a nix setup so can't easily confirm that the nix issue is also fixed.

suhr commented 3 years ago

Yeah, now I can build it.