Repository navigation
Problem with versioned functions (FreeBSD) #236
Description
Trying to build rust_icu_ustring on FreeBSD (after getting around #235), I get a bunch of errors like this:
error[E0425]: cannot find function `u_strFromUTF8_70` in this scope
--> /home/kaj/.cargo/registry/src/github.com-1ecc6299db9ec823/rust_icu_ustring-2.0.0/src/lib.rs:160:13
|
160 | versioned_function!(u_strFromUTF8)(
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: a function with a similar name exists: `u_strFromUTF8`
|
::: /usr/home/kaj/proj/r4s/target/debug/build/rust_icu_sys-f73623289ad55f94/out/lib.rs:3:850138
|
3 | ..."] pub fn u_strFromUTF8 (dest : * mut UChar , destCapacity : i32 , pDestLength : * mut i32 , src : * const :: std :: os :: raw :: c_char , srcLength : i32 , pErrorCode : * mut UErrorCode) -> * mut UChar ; } ...
| --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- similarly named function `u_strFromUTF8` defined here
|
= note: this error originates in the macro `versioned_function` (in Nightly builds, run with -Z macro-backtrace for more info)
I get eleven such errors, all for different function names u_\w+_70. Checking the actual library, (with nm --dynamic --defined-only (libfile) it contains the symbols like u_strFromUTF8 but no symbols ending with _70 (or any other _number). The same command on linux (Fedora 35) shows u_strFromUTF8_69 (but no unversioned symbols).
The version number itself is correct, libicuuc.so on my FreeBSD host is a symlink to libicuuc.so.70.1. But the symbols in it are not versioned.
In rust_icu_sys/bindgen/macros.rs, it seems that versioning can be disabled by not using the renaming or the icu_version_in_env feature, but apparently at least one or those gets defined in my build even though it should not. Or should the cfg
rust_icu/rust_icu_sys/bindgen/macros.rs
Lines 32 to 39 in fc64773
| /// This macro will be used when no function renaming is needed. | |
| #[cfg(not(any(feature="renaming",feature="icu_version_in_env")))] | |
| #[macro_export] | |
| macro_rules! versioned_function { | |
| ($func_name:path) => { | |
| $func_name | |
| } | |
| } |
be changed to just
#[cfg(not(feature="renaming"))] ?
Activity
kaj commentedon Jan 15, 2022
I believe I have up-to-date versions of the rust_icu_* crates:
My rust toolchain is:
filmil commentedon Jan 15, 2022
It is unexpected that only some of the symbols in the ICU library are renamed and some not.
That should not be correct, as
rust_icu/rust_icu_sys/bindgen/macros.rs
Line 9 in fc64773
kaj commentedon Jan 15, 2022
@filmil huh? It seems to be line 9 and and 22 is for when
renamingis enabled, so I think line 33 should cover both the cases whenrenamingis not 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.
kaj commentedon Jan 15, 2022
I also tried to disable features by changing my dependency to:
but then I got the message:
So I changed the dependency to:
... and then I got this error:
kaj commentedon Jan 16, 2022
Some more info on this; checking out the rust_icu sources on my FreeBSD host, I find
cargo testworks fine inrust_icu_sysandrust_icu_common, but fails on versioned functions as above for other crates, such asrust_icu_ucolandrust_icu_uenum. So my present guess is thatrust_icu_sysdetects 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?
filmil commentedon Jan 16, 2022
kaj commentedon Jan 16, 2022
It seems I was actually rather close above (#236 (comment)). If I edit the dependency like this it works:
... 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_sysmakes availiable for all dependent packages.filmil commentedon Jan 17, 2022
yshui commentedon Aug 21, 2022
Same problem on Gentoo, icu-i18n.pc looks like this:
I think icu_sys only checks
--cflags?kaj commentedon Aug 30, 2022
Here's output from a bunch of pkg-config commands on my FreeBSD host:
I guess the problem is that
rust_icudoesn't find the-DU_DISABLE_RENAMING=1flag, 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 inrust_icuthat 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 theicu-*.pcfiles, so it seems that those are as intended by the icu project.Looking some more, it seems that the omission of the
U_DISABLE_RENAMINGflag from --cflags is intentional. Instead, it is defined like this inunicode/uconfig.h:So I guess the correct way of finding if renaming is enabled or not is to build and run a little program like this:
... then compile that with proper flags from pkg-config, run it, and look at the output.
ip1981 commentedon Oct 3, 2026
See #415