Created
February 18, 2023 15:03
-
-
Save zhangw/221dea4264539910a84550ad1acb52ad to your computer and use it in GitHub Desktop.
rust + openssl + musl + archlinux
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## install musl | |
sudo pacman -Syu musl | |
## install headers of musl | |
sudo pacman -Syu kernel-headers-musl | |
## cargo add musl target and toolchain | |
rustup target add --toolchain stable x86_64-unknown-linux-musl | |
## download openssl source code, version is 3.0.7 | |
wget https://www.openssl.org/source/openssl-3.0.7.tar.gz | |
tar -zxvf openssl-3.0.7.tar.gz | |
## configure and build openssl with musl-gcc | |
cd openssl-3.0.7 | |
CC="musl-gcc -fPIE -pie" ./Configure no-shared no-async --prefix=/opt/musl/openssl3.0.7 | |
make -j `nproc` | |
make install | |
## build rust project which depends on openssl | |
OPENSSL_STATIC=1 OPENSSL_DIR=/opt/musl/openssl3.0.7 cargo build --release --target x86_64-unknown-linux-musl |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment