Giter VIP home page Giter VIP logo

Comments (10)

kaj avatar kaj commented on June 1, 2024

I believe I have up-to-date versions of the rust_icu_* crates:

: guran%; cargo tree -i rust_icu_sys
rust_icu_sys v2.0.0
├── rust_icu_common v2.0.0
│   ├── rust_icu_ucol v2.0.0
│   │   └── r4s v0.1.0 (/usr/home/kaj/proj/r4s)
│   ├── rust_icu_uenum v2.0.0
│   │   └── rust_icu_ucol v2.0.0 (*)
│   └── rust_icu_ustring v2.0.0
│       └── rust_icu_ucol v2.0.0 (*)
├── rust_icu_ucol v2.0.0 (*)
├── rust_icu_uenum v2.0.0 (*)
└── rust_icu_ustring v2.0.0 (*)

My rust toolchain is:

  stable-x86_64-unknown-freebsd unchanged - rustc 1.58.0 (02072b482 2022-01-11)

from rust_icu.

filmil avatar filmil commented on June 1, 2024

It is unexpected that only some of the symbols in the ICU library are renamed and some not.

be changed to just

#[cfg(not(feature="renaming"))]

That should not be correct, as

#[cfg(all(feature="renaming",not(feature="icu_version_in_env")))]
is supposed to cover that feature combination.

from rust_icu.

kaj avatar kaj commented on June 1, 2024

@filmil huh? It seems to be line 9 and and 22 is for when renaming is enabled, so I think line 33 should cover both the cases when renaming is not enabled.

renaming icu_version_in_env selected
enabled enabled line 22
enabled disabled line 9
disabled disabled line 33
disabled enabled ??

But maybe icu_version_in_env is never enabled unless renaming is? It seems to me that renaming is enabled when building on FreeBSD but should not be.

from rust_icu.

kaj avatar kaj commented on June 1, 2024

I also tried to disable features by changing my dependency to:

rust_icu_ucol = { version = "2.0.0", default-features = false }

but then I got the message:

error: You must use `renaming` when not using `use-bindgen`

So I changed the dependency to:

rust_icu_ucol = { version = "2.0.0", default-features = false, features = ["use-bindgen"] }

... and then I got this error:

error: couldn't read /usr/home/kaj/proj/r4s/target/debug/build/rust_icu_sys-00ce2788a020995a/out/macros.rs: No such file or directory (os error 2)
  --> /home/kaj/.cargo/registry/src/github.com-1ecc6299db9ec823/rust_icu_sys-2.0.0/src/lib.rs:45:1
   |
45 | include!(concat!(env!("OUT_DIR"), "/macros.rs"));
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: this error originates in the macro `include` (in Nightly builds, run with -Z macro-backtrace for more info)

from rust_icu.

kaj avatar kaj commented on June 1, 2024

Some more info on this; checking out the rust_icu sources on my FreeBSD host, I find cargo test works fine in rust_icu_sys and rust_icu_common, but fails on versioned functions as above for other crates, such as rust_icu_ucol and rust_icu_uenum. So my present guess is that rust_icu_sys detects the unversioned symbol fine and works with them, but somehow fails to communicate this to downstream crates.

Thoughts on that? Any suggestions for things I can try?

from rust_icu.

filmil avatar filmil commented on June 1, 2024

from rust_icu.

kaj avatar kaj commented on June 1, 2024

It seems I was actually rather close above (#236 (comment)). If I edit the dependency like this it works:

rust_icu_ucol = { version = "2.0.0", default-features = false, features = ["use-bindgen", "icu_config"] }

... but of course, like that it does not build on Linux anymore. So I really think these flags should not be cargo features to be enabled or not from the consuming package at all, but instead autodetected flags that rust_icy_sys makes availiable for all dependent packages.

from rust_icu.

filmil avatar filmil commented on June 1, 2024

from rust_icu.

yshui avatar yshui commented on June 1, 2024

Same problem on Gentoo, icu-i18n.pc looks like this:

# Copyright (C) 2016 and later: Unicode, Inc. and others.
# License & terms of use: http://www.unicode.org/copyright.html
# Copyright (C) 2010-2013, International Business Machines Corporation. All Rights Reserved.

# CFLAGS contains only anything end users should set
CFLAGS =
# CXXFLAGS contains only anything end users should set
CXXFLAGS =
# DEFS only contains those UCONFIG_CPPFLAGS which are not auto-set by platform.h
DEFS =  -DU_DISABLE_RENAMING=1
prefix = /usr
exec_prefix = ${prefix}
#bindir = ${exec_prefix}/bin
libdir = /usr/lib
includedir = ${prefix}/include
baselibs = -lpthread -lm
#datarootdir = /usr/share
#datadir = /usr/share
#sbindir = ${exec_prefix}/sbin
#mandir = /usr/share/man
#sysconfdir = /etc
UNICODE_VERSION=14.0
ICUPREFIX=icu
ICULIBSUFFIX=
LIBICU=lib${ICUPREFIX}
#SHAREDLIBCFLAGS=-fPIC
pkglibdir=${libdir}/icu${ICULIBSUFFIX}/71.1
#pkgdatadir=${datadir}/icu${ICULIBSUFFIX}/71.1
ICUDATA_NAME = icudt71l
#ICUPKGDATA_DIR=/usr/lib
#ICUDATA_DIR=${pkgdatadir}
ICUDESC=International Components for Unicode

Version: 71.1
Cflags: -I${includedir}
# end of icu.pc.in
Description: International Components for Unicode: Internationalization library
Name: icu-i18n
Requires: icu-uc
Libs: -licui18n

I think icu_sys only checks --cflags?

from rust_icu.

kaj avatar kaj commented on June 1, 2024

Here's output from a bunch of pkg-config commands on my FreeBSD host:

:; pkg-config icu-i18n --cflags
-I/usr/local/include 
:; pkg-config icu-i18n --libs
-licui18n -L/usr/local/lib -licuuc -licudata 
:; pkg-config icu-i18n --variable=DEFS
-DU_DISABLE_RENAMING=1
:;
:; pkg-config icu-i18n --print-requires
icu-uc
:;
:; pkg-config icu-uc --cflags
-I/usr/local/include 
:; pkg-config icu-uc --libs
-L/usr/local/lib -licuuc -licudata 
:; pkg-config icu-uc --variable=DEFS
-DU_DISABLE_RENAMING=1

I guess the problem is that rust_icu doesn't find the -DU_DISABLE_RENAMING=1 flag, but I don't know if it is a bug in the FreeBSD pkgconfig data that it is not included in cflags or a bug in rust_icu that it doesn't look at --variable=DEFS.

The FreeBSD port of icu runs configure for icu with --disable-renaming (and some other flags) and does not seem to mess with the icu-*.pc files, so it seems that those are as intended by the icu project.


Looking some more, it seems that the omission of the U_DISABLE_RENAMING flag from --cflags is intentional. Instead, it is defined like this in unicode/uconfig.h:

/**
 * \def U_DISABLE_RENAMING
 * Determines whether to disable renaming or not.
 * @internal
 */
#ifndef U_DISABLE_RENAMING
#define U_DISABLE_RENAMING 1
#endif

So I guess the correct way of finding if renaming is enabled or not is to build and run a little program like this:

#include <unicode/uconfig.h>
#include <stdio.h>

int main() {
  if (U_DISABLE_RENAMING) {
    printf("Renaming disabled");
  } else {
    printf("Renaming enabled");
  }
}

... then compile that with proper flags from pkg-config, run it, and look at the output.

from rust_icu.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.