rapiz1 / rathole

A lightweight and high-performance reverse proxy for NAT traversal, written in Rust. An alternative to frp and ngrok.
Apache License 2.0
8.82k stars 441 forks source link

compile to target aarch64-unknown-linux-musl fail? #263

Closed jm-observer closed 11 months ago

jm-observer commented 1 year ago

I used cross to cross-compile the target aarch64-unknown-linux-musl, but encountered an error: failed to run custom build command for openssl-sys v0.9.83. So why were you able to successfully cross-compile on GitHub's CI/CD?

here is my cross.toml:

[target.aarch64-unknown-linux-musl]
pre-build = [
    "dpkg --add-architecture arm64",
    "apt-get update && apt-get install --assume-yes libssl-dev:arm64 libssl-dev"
]
kLiHz commented 11 months ago

The CI builds artifacts with cross-rs/cross. I'm not familiar with it, but it seems to have Docker working under the hood.

The openssl is required by the tls feature, and since you're doing cross-compiling, the ssl library of that target platform should be present. Maybe you can refer to openssl-sys or tokio-native-tls's documentation (I'm not sure if it will work though) for how to configure the build/cargo to find them.

And if the tls feature is not nesserary to you, try disable it by passing --no-default-features --features client,server to cargo. You may also want to pass --config target.$TARGET.linker=\"rust-lld\" to cargo for it to use some linker other than the system's default.

kLiHz commented 11 months ago

By the way, I personally don't recommend messing around with Docker. I just build for aarch64-unknown-linux-musl in GitHub Codespace (which is a x86_64 Linux platform I think) with just:

export TARGET=aarch64-unknown-linux-musl
rustup target add $TARGET
cargo build --release --target $TARGET \
  --no-default-features --features noise,client,server,hot-reload \
  --config target.$TARGET.linker=\"rust-lld\"