add doc about static linking

This commit is contained in:
Zhang Jingqiang 2023-08-16 16:24:05 +08:00
parent c54a0efe4b
commit 5f6395826b
3 changed files with 36 additions and 1 deletions

View file

@ -116,6 +116,10 @@ It is recommended to build packages yourself if you want to install them in a pr
For testing purpose, we have built and uploaded some packages to
[cloudsmith](https://cloudsmith.io/~g3-oqh/repos/g3-J0E/packages/), you can find installation instructions there.
### Static Linking
See [Static Linking](doc/static-linking.md).
## Contribution
Please check [Contributing](CONTRIBUTING.md) for more details.

View file

@ -110,7 +110,11 @@ Cloudflare Keyless Server的简单实现。
如需在生产环境使用,建议自行打包。
测试环境的话,部分包已经编译上传到
[cloudsmith](https://cloudsmith.io/~g3-oqh/repos/g3-J0E/packages/), 可参考该链接页面的说明进行安装.
[cloudsmith](https://cloudsmith.io/~g3-oqh/repos/g3-J0E/packages/), 可参考该链接页面的说明进行安装。
### 静态链接
参考 [Static Linking](doc/static-linking.md)。
## 贡献指南

27
doc/static-linking.md Normal file
View file

@ -0,0 +1,27 @@
# Static Linking
## Install musl
[musl](https://musl.libc.org/) is needed to enable static linking.
You can use the following instructions to install musl on Debian:
```shell
apt install musl-tools musl-dev
```
## Install rustc target
Then you need to install the corresponding musl rust target (see `rustc --print target-list | grep musl`):
```shell
rustup target add x86_64-unknown-linux-musl
```
## Compile
Then compile with the features that do not require dynamic linking:
```shell
cargo build --target=x86_64-unknown-linux-musl --no-default-features --features vendored-openssl,c-ares
```