Skip to content

fix: add Cross.toml to fix OpenSSL cross-compilation failures#33

Merged
grunch merged 1 commit intomainfrom
fix/cross-compilation-openssl
Mar 14, 2026
Merged

fix: add Cross.toml to fix OpenSSL cross-compilation failures#33
grunch merged 1 commit intomainfrom
fix/cross-compilation-openssl

Conversation

@mostronatorcoder
Copy link
Contributor

@mostronatorcoder mostronatorcoder bot commented Mar 14, 2026

Summary

Fixes the OpenSSL cross-compilation failures that caused the v0.1.1 release workflow to fail on all target architectures.


Problem

Release workflow run failed: https://github.com/MostroP2P/mostrix/actions/runs/23092367046

All 5 cross-compilation targets failed with:

error: failed to run custom build command for `openssl-sys v0.9.111`
Could not find directory of OpenSSL installation

Root cause: reqwest uses native-tls feature → depends on openssl-sys → needs OpenSSL dev headers for target architecture → cross-compilation containers don't include these by default.


Solution

Add Cross.toml configuration file with pre-build hook:

[build]
pre-build = [
    "dpkg --add-architecture $CROSS_DEB_ARCH",
    "apt-get update",
    "apt-get install -y libssl-dev:$CROSS_DEB_ARCH pkg-config"
]

This installs OpenSSL development headers for the target architecture before compilation, allowing openssl-sys build script to locate them.


Validation

  • cargo fmt — no changes
  • cargo clippy --all-targets --all-features -- -D warnings — passes
  • cargo test — 10 passed, 0 failed

Next step: After merge, re-trigger release workflow to verify cross-compilation succeeds.


Alternative Considered

Switch to rustls-tls:

reqwest = { version = "0.13.2", default-features = false, features = ["rustls-tls", "json", "http2"] }

Pros:

  • No OpenSSL dependency
  • Pure Rust TLS stack
  • Easier cross-compilation

Cons:

  • Changes TLS behavior (different certificate validation, cipher suites)
  • Requires thorough testing of HTTPS connections
  • May break compatibility with some servers
  • Larger binary size (rustls is bigger than linking to system OpenSSL)

Decision: Use Cross.toml fix for now (minimal risk). Consider rustls-tls migration in a future PR with proper testing.


References

Summary by CodeRabbit

Release Notes

  • Chores
    • Enhanced build infrastructure to support cross-compilation across multiple target architectures, ensuring proper dependency resolution during compilation.

Problem: Release workflow v0.1.1 failed on all cross-compilation targets
with error:
  failed to run custom build command for openssl-sys v0.9.111
  Could not find directory of OpenSSL installation

Root cause: reqwest dependency uses native-tls feature which requires
openssl-sys. Cross-compilation Docker containers don't include OpenSSL
development headers for target architectures by default.

Solution: Add Cross.toml configuration file with pre-build hook that:
1. Adds target architecture to dpkg
2. Updates apt package lists
3. Installs libssl-dev and pkg-config for the target architecture

This allows openssl-sys build script to locate headers during cross-
compilation.

References:
- Failed run: https://github.com/MostroP2P/mostrix/actions/runs/23092367046
- Cross docs: https://github.com/cross-rs/cross/wiki/Configuration
- Similar fix in cargo-chef, diesel_cli, and other Rust cross-compiled tools

Alternative considered: Switch reqwest to rustls-tls feature to avoid
OpenSSL entirely. Rejected because it would change TLS behavior and
require thorough testing of HTTPS connections.
@grunch
Copy link
Member

grunch commented Mar 14, 2026

@coderabbitai review

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 14, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 14, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: afc72c22-8662-43de-9268-b5d66625e17b

📥 Commits

Reviewing files that changed from the base of the PR and between 532af65 and cfae28e.

📒 Files selected for processing (1)
  • Cross.toml

Walkthrough

Adds a Cross.toml configuration file to enable cross-compilation targeting multiple architectures. The configuration includes a pre-build hook that prepares the build environment by adding Debian architectures, updating package lists, and installing OpenSSL development libraries and pkg-config.

Changes

Cohort / File(s) Summary
Cross-Compilation Configuration
Cross.toml
Introduces build configuration with pre-build hook that executes shell commands to install libssl-dev and pkg-config for target architecture support during cross-compilation.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Possibly related PRs

Poem

🐰 Across the architectures we hop,
With Cross.toml, we'll never stop!
OpenSSL libraries, all in place,
Building swift for every space. 🏗️

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/cross-compilation-openssl
📝 Coding Plan
  • Generate coding plan for human review comments

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 and usage tips.

@grunch grunch merged commit ef38ab4 into main Mar 14, 2026
10 checks passed
@grunch grunch deleted the fix/cross-compilation-openssl branch March 14, 2026 17:35
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