Skip to content

Consider disabling chrono default features to avoid unnecessary iana-time-zone/libbe dependency on Haiku #828

@chitao1234

Description

@chitao1234

Summary

rmcp currently depends on chrono with default features enabled. On Haiku, that can pull in iana-time-zone-haiku, which links Haiku's libbe.so. This creates an avoidable platform-library dependency, and it can interact badly with other crates that vendor libraries also used by Haiku system DSOs. In my case, this contributed to a final-link failure involving zstd-sys and Haiku libbe.so.

Environment

  • OS: Haiku x86_64 r1beta5 hrev57937+129
  • Rust/Cargo: cargo 1.89.0
  • rmcp: 1.3.0
  • chrono: 0.4.44
  • iana-time-zone: 0.1.65
  • iana-time-zone-haiku: 0.1.2

Current Dependency Behavior

In rmcp 1.3.0, the non-wasm chrono dependency is effectively:

[target.'cfg(not(all(target_family = "wasm", target_os = "unknown")))'.dependencies.chrono]
version = "0.4.38"
features = ["serde"]

Because default-features = false is not set, this enables chrono's default features.

chrono's default features include:

default = ["clock", "std", "oldtime", "wasmbind"]
clock = ["winapi", "iana-time-zone", "now"]

On Haiku, iana-time-zone pulls iana-time-zone-haiku, whose build script links libbe, libbe.so itself depends on system libzstd.so.1.

This means that using rmcp on Haiku can introduce libbe and system libzstd into the final link even if the application only needs UTC timestamps. In my case, the final binary also used Rust zstd / zstd-sys, which by default vendors zstd and hides zstd C symbols. The final link then failed on Haiku with:

error: linking with `cc` failed: exit status: 1
  = note: /boot/system/develop/tools/bin/../lib/gcc/x86_64-unknown-haiku/.../ld:
          <binary>: hidden symbol `ZSTD_compressStream` in
          target/debug/deps/libzstd_sys-...rlib(...-zstd_compress.o)
          is referenced by DSO
          final link failed: bad value
          collect2: error: ld returned 1 exit status

This is not primarily an rmcp bug, but rmcp appears to be pulling local-timezone support when it may only need UTC time.

From a quick inspection, rmcp appears to use:

  • chrono::DateTime
  • chrono::Utc::now()
  • chrono::Duration
  • RFC3339 formatting

I did not see obvious usage of chrono::Local or local timezone discovery.

Proposed Change

Would it be possible to change the non-wasm chrono dependency to disable default features and enable only the needed features?

For example:

[target.'cfg(not(all(target_family = "wasm", target_os = "unknown")))'.dependencies.chrono]
version = "0.4.38"
default-features = false
features = ["serde", "now"]

This could avoid linking Haiku libbe.so unnecessarily, and reduce dependency footprint on all platforms.

Workaround Downstream

Downstreams can sometimes work around the specific linker failure by making zstd-sys use system zstd on Haiku

ZSTD_SYS_USE_PKG_CONFIG=1 cargo build

or

[target.'cfg(target_os = "haiku")'.dependencies]
zstd = { version = "0.13", features = ["pkg-config"] }

But it would still be cleaner if rmcp did not pull local timezone support unless it actually needs it.

Related Upstream issue

Haiku: vendored hidden zstd symbols conflict with libbe.so dependency on system libzstd

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions