From bbe157b450ffd3d4aa6acb9af8c5682eb3a2ef36 Mon Sep 17 00:00:00 2001 From: Roman Podoliaka Date: Mon, 25 Nov 2024 22:32:17 +0000 Subject: [PATCH] Build and link with openssl statically Dynamic linking with openssl does not work well with cross-compilation: the Docker image `cross` uses for aarch64 is based on Ubuntu Xenial that has libssl1.0.0, while the ones available on Raspbian (and other modern distros) are libssl1.1 and libssl3. Instead, we can use the feature of `openssl-sys` that allows to build and statically link openssl to avoid the hassle with shared object versions that vary between Linux distros. This makes Cross.toml completely unnecessary. --- Cargo.lock | 11 +++++++++++ Cargo.toml | 1 + Cross.toml | 5 ----- 3 files changed, 12 insertions(+), 5 deletions(-) delete mode 100644 Cross.toml diff --git a/Cargo.lock b/Cargo.lock index 06cec60..956bf85 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1272,6 +1272,15 @@ version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" +[[package]] +name = "openssl-src" +version = "300.4.1+3.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "faa4eac4138c62414b5622d1b31c5c304f34b406b013c079c2bbc652fdd6678c" +dependencies = [ + "cc", +] + [[package]] name = "openssl-sys" version = "0.9.104" @@ -1280,6 +1289,7 @@ checksum = "45abf306cbf99debc8195b66b7346498d7b10c210de50418b5ccd7ceba08c741" dependencies = [ "cc", "libc", + "openssl-src", "pkg-config", "vcpkg", ] @@ -2806,6 +2816,7 @@ dependencies = [ "diesel", "diesel-async", "jsonwebtoken", + "openssl-sys", "percent-encoding", "rand 0.7.3", "reqwest", diff --git a/Cargo.toml b/Cargo.toml index dd01e42..78577a2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -32,6 +32,7 @@ tracing = "0.1.25" tracing-subscriber = { version = "0.3.17", features = ["env-filter"] } uuid = { version = "0.8.2", features = ["v4"] } percent-encoding = "2.1.0" +openssl-sys = { version = "0.9.104", features = ["vendored"] } [dev-dependencies] tempfile = "3.2.0" diff --git a/Cross.toml b/Cross.toml deleted file mode 100644 index 3077f59..0000000 --- a/Cross.toml +++ /dev/null @@ -1,5 +0,0 @@ -[build] -pre-build = [ - "dpkg --add-architecture $CROSS_DEB_ARCH", - "apt-get update && apt-get install --assume-yes libssl-dev:$CROSS_DEB_ARCH libpq-dev:$CROSS_DEB_ARCH" -]