Skip to content

build: generate src/version.rs without hbb_common - #707

Open
luminoso wants to merge 1 commit into
rustdesk:masterfrom
luminoso:build-script-without-hbb_common
Open

luminoso wants to merge 1 commit into
rustdesk:masterfrom
luminoso:build-script-without-hbb_common

Conversation

@luminoso

@luminoso luminoso commented Sep 22, 2026

Copy link
Copy Markdown

build.rs calls hbb_common::gen_version(), which makes hbb_common a build dependency. Cargo then compiles the whole crate for the build host, including libsodium-sys. When cross compiling with pkg-config pointed at the target sysroot, the host build script links the target libsodium and fails:

rust-lld: error: .../aarch64_generic_musl/usr/lib/libsodium.so is incompatible with elf64-x86-64
error: could not compile `hbbs` (build script)

This happens on every non-x86_64 target when packaging hbbs and hbbr for OpenWrt (openwrt/packages#30572), and only passes on x86_64 because host and target share the machine type.

The change writes src/version.rs from CARGO_PKG_VERSION with the standard library, so the build script has no dependencies at all. VERSION is unchanged. BUILD_DATE stays as an empty constant: nothing in hbbs or hbbr reads it, and a constant value makes the build reproducible. Cargo.lock does not change because hbb_common remains a normal dependency.

Tested by building 1.1.16 with this change applied for x86_64 musl in the OpenWrt SDK; hbbs --version prints hbbs 1.1.16 and the build script binary no longer links libsodium.

Summary by CodeRabbit

  • Chores
    • Streamlined application version handling during builds.
    • Improved consistency by regenerating version information whenever project metadata changes.
    • Removed an unnecessary build-time dependency.
    • No user-facing functionality or behavior changes are included in this update.

RetriggerConfidence Score: 5/5

The PR appears safe to merge and cleanly removes the problematic host dependency without changing consumed version behavior.

Summary

This PR removes hbb_common from the host-side build dependency graph and replaces its version-file generator with a standard-library-only build script.

  • Generates VERSION from Cargo’s package version.
  • Preserves the unused BUILD_DATE constant as an empty reproducible value.
  • Avoids compiling and linking target-oriented native dependencies for the build host during cross-compilation.

Reviews (1) · Last reviewed commit: "build: generate src/version.rs without h..."

build.rs called hbb_common::gen_version(), which made hbb_common a build
dependency, so cargo compiled the whole crate for the build host,
including libsodium-sys. When cross compiling with pkg-config pointed at
the target sysroot, the host build script then links the target
libsodium and fails at link time. That is what happens on every
non-x86_64 OpenWrt target.

Write src/version.rs from CARGO_PKG_VERSION with the standard library
instead. BUILD_DATE is kept as an empty constant: nothing in hbbs or
hbbr reads it, and a constant value makes the build reproducible.

Signed-off-by: Guilherme Cardoso <luminoso@gmail.com>
@coderabbitai

coderabbitai Bot commented Sep 22, 2026

Copy link
Copy Markdown

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: 27999cdf-b4f3-4409-bed2-f1af525d089f

📥 Commits

Reviewing files that changed from the base of the PR and between a7736be and 071796a.

📒 Files selected for processing (2)
  • Cargo.toml
  • build.rs
💤 Files with no reviewable changes (1)
  • Cargo.toml

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.


📝 Walkthrough

Walkthrough

The build no longer depends on hbb_common. build.rs now generates src/version.rs from CARGO_PKG_VERSION and reruns when Cargo.toml changes.

Changes

Version generation

Layer / File(s) Summary
Build-time version generation
Cargo.toml, build.rs
The hbb_common build dependency was removed. build.rs now writes public VERSION and empty BUILD_DATE constants to src/version.rs, and Cargo reruns it when Cargo.toml changes.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Merge Risk: ⚪ Minimal · up to 07179

This change preserves generated version behavior while removing the build-only dependency affecting cross-compilation, so it is ready to merge with normal checks.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 1 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: generating src/version.rs in build.rs without the hbb_common build dependency.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR

Warning

Some tools did not complete. Review the errors below.

🔧 Clippy (1.98.0)

Clippy execution failed


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant