gettext-rs icon indicating copy to clipboard operation
gettext-rs copied to clipboard

Fix system detection when cross-compiling with Yocto

Open tronical opened this issue 2 years ago • 5 comments

In Yocto the target can be for example aarch64-poky-linux, which is most definitely gnu, but doesn't contain the gnu infix in the target.

Instead, detect Linux using CARGO_CFG_TARGET_OS and assume that it's gnu or musl.

tronical avatar Jun 18 '23 09:06 tronical

@Minoru ping?

Is this crate still maintained?

ogoffart avatar Sep 04 '23 14:09 ogoffart

@ogoffart it is, but I haven't fixed our musl problem (#99) yet, and that blocks all further work.

Minoru avatar Sep 16 '23 15:09 Minoru

Is it still blocked after https://github.com/Koka/gettext-rs/pull/111 ?

ogoffart avatar Mar 19 '24 09:03 ogoffart

Okay, I'm back!

The assumption that on Linux it's always GNU or musl appears to be wrong:

$ rustc --print target-list | grep linux | egrep -v -- '-gnu|-musl'
aarch64-linux-android
aarch64-unknown-linux-ohos
arm-linux-androideabi
armv5te-unknown-linux-uclibceabi
armv7-linux-androideabi
armv7-unknown-linux-ohos
armv7-unknown-linux-uclibceabi
armv7-unknown-linux-uclibceabihf
i686-linux-android
mips-unknown-linux-uclibc
mipsel-unknown-linux-uclibc
riscv64-linux-android
thumbv7neon-linux-androideabi
x86_64-linux-android
x86_64-unknown-linux-ohos

Even if all of those have libintl (which I didn't check), there's no guarantee that in a few years Rust won't add a new triple for a platform that doesn't have libintl. So I think this approach is a dead end.

We could introduce a feature (force-gettext-system or assume-libc-contains-libintl or something) which always links with libc without checking if it has libintl. It'll be backed by an environment variable too. Will that be a workable solution for you?

Minoru avatar Jul 20 '24 10:07 Minoru

Okay, I'm back!

Yay :)

The assumption that on Linux it's always GNU or musl appears to be wrong:

$ rustc --print target-list | grep linux | egrep -v -- '-gnu|-musl'
aarch64-linux-android
aarch64-unknown-linux-ohos
arm-linux-androideabi
armv5te-unknown-linux-uclibceabi
armv7-linux-androideabi
armv7-unknown-linux-ohos
armv7-unknown-linux-uclibceabi
armv7-unknown-linux-uclibceabihf
i686-linux-android
mips-unknown-linux-uclibc
mipsel-unknown-linux-uclibc
riscv64-linux-android
thumbv7neon-linux-androideabi
x86_64-linux-android
x86_64-unknown-linux-ohos

Even if all of those have libintl (which I didn't check), there's no guarantee that in a few years Rust won't add a new triple for a platform that doesn't have libintl. So I think this approach is a dead end.

Fair point.

We could introduce a feature (force-gettext-system or assume-libc-contains-libintl or something) which always links with libc without checking if it has libintl. It'll be backed by an environment variable too. Will that be a workable solution for you?

In a way that’s how I expect the “gettext-system” feature to work. I think that’s also how it works with other crates: if I enable the “system-foo” feature it’s my responsibility to make sure it’s in the system.

In this crate the feature enables a kind of auto-detection (that’s failing in my case).

tronical avatar Jul 20 '24 18:07 tronical