with this patch and using cargo build --release --target x86_64-unknown-linux-musl --features bin_core,ls_filesystem,vendored you can make statically linked binary (now binary depends on glibc 2.32 and cant run on centos7 (and some other distrs))
From 218fe816aa5bcd37590868d92e4556ce0086a730 Mon Sep 17 00:00:00 2001
From: admin <admin@example.com>
Date: Fri, 18 Jun 2021 10:04:15 +0300
Subject: [PATCH] add musl support
---
Cargo.lock | 11 +++++++++++
Cargo.toml | 5 +++++
2 files changed, 16 insertions(+)
diff --git a/Cargo.lock b/Cargo.lock
index dce7bc0..df04fc8 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -808,6 +808,7 @@ dependencies = [
"hostname",
"log",
"notify",
+ "openssl-sys",
"reqwest",
"serde",
"serde_json",
@@ -1029,6 +1030,15 @@ version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "77af24da69f9d9341038eba93a073b1fdaaa1b788221b00a69bce9e762cb32de"
+[[package]]
+name = "openssl-src"
+version = "111.15.0+1.1.1k"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b1a5f6ae2ac04393b217ea9f700cd04fa9bf3d93fae2872069f3d15d908af70a"
+dependencies = [
+ "cc",
+]
+
[[package]]
name = "openssl-sys"
version = "0.9.60"
@@ -1038,6 +1048,7 @@ dependencies = [
"autocfg",
"cc",
"libc",
+ "openssl-src",
"pkg-config",
"vcpkg",
]
diff --git a/Cargo.toml b/Cargo.toml
index 51885af..a1185e0 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -14,6 +14,10 @@ ls_filesystem = ["notify"]
ls_journald = ["systemd"]
ls_docker = ["bollard"]
+# Force openssl-sys to staticly link in the openssl library. Necessary when
+# cross compiling to x86_64-unknown-linux-musl.
+vendored = ["openssl-sys/vendored"]
+
[[bin]]
name = "logram"
doc = false
@@ -28,6 +32,7 @@ path = "src/lib/mod.rs"
anyhow = "1.0"
serde = { version = "1.0", features = ["derive"] }
reqwest = { version = "0.10", features = ["blocking", "json", "socks"] }
+openssl-sys = "*"
# bin
clap = { version = "2.33", optional = true }
--
2.32.0
with this patch and using
cargo build --release --target x86_64-unknown-linux-musl --features bin_core,ls_filesystem,vendored
you can make statically linked binary (now binary depends on glibc 2.32 and cant run on centos7 (and some other distrs))