Make building static binaries simpler

This commit adds STATIC makefile variable to adjust LDFLAGS and build
tags accordingly.

Fixes #5824.

Signed-off-by: Kazuyoshi Kato <katokazu@amazon.com>
This commit is contained in:
Kazuyoshi Kato
2022-06-04 03:26:06 +00:00
parent 455b45708c
commit 00eb74a4ca
3 changed files with 15 additions and 5 deletions

View File

@@ -122,14 +122,13 @@ Please refer to [RUNC.md](/docs/RUNC.md) for the currently supported version of
You can build static binaries by providing a few variables to `make`:
```sh
make EXTRA_FLAGS="-buildmode pie" \
EXTRA_LDFLAGS='-linkmode external -extldflags "-fno-PIC -static"' \
BUILDTAGS="netgo osusergo static_build"
make STATIC=1
```
> *Note*:
> - static build is discouraged
> - static containerd binary does not support loading shared object plugins (`*.so`)
> - static build binaries are not position-independent
# Via Docker container