File tree Expand file tree Collapse file tree 3 files changed +23
-5
lines changed Expand file tree Collapse file tree 3 files changed +23
-5
lines changed Original file line number Diff line number Diff line change 1- # Get CC values for cross-compilation.
1+ # Get GO, GOARCH and CC values for cross-compilation.
22include ../../cc_platform.mk
33
4- # We use the flags suggested in nolibc/nolibc.h, it makes the binary very small.
4+ # List of GOARCH that nolibc supports, from:
5+ # https://go.dev/doc/install/source#environment (with GOOS=linux)
6+ #
7+ # See nolibc supported arches in ./nolibc/arch-*.h
8+ NOLIBC_GOARCHES := 386 amd64 arm arm64 loong64 ppc64le riscv64 s390x
9+
10+ ifneq (,$(filter $(GOARCH ) , $(NOLIBC_GOARCHES ) ) )
11+ # We use the flags suggested in nolibc/nolibc.h, it makes the binary very small.
12+ CFLAGS += -fno-asynchronous-unwind-tables -fno-ident -s -Os -nostdlib -lgcc
13+ else
14+ CFLAGS += -DRUNC_USE_STDLIB
15+ endif
16+
517runc-dmz : _dmz.c
6- $(CC ) $(CFLAGS ) -fno-asynchronous-unwind-tables -fno-ident -s -Os -nostdlib -lgcc - static -o $@ $^
18+ $(CC ) $(CFLAGS ) -static -o $@ $^
719 $(STRIP ) -gs $@
Original file line number Diff line number Diff line change @@ -13,4 +13,6 @@ The current version in that folder is from Linux 6.6-rc3 tag (556fb7131e03b02836
1313
1414It also support all the architectures we support in runc.
1515
16+ If the GOARCH we use for compiling doesn't support nolibc, it fallbacks to using the C stdlib.
17+
1618[ nolibc-upstream ] : https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/tools/include/nolibc?h=v6.6-rc3
Original file line number Diff line number Diff line change 1- #include "xstat.h"
2- #include "nolibc/nolibc.h"
1+ #ifdef RUNC_USE_STDLIB
2+ # include <unistd.h>
3+ #else
4+ # include "xstat.h"
5+ # include "nolibc/nolibc.h"
6+ #endif
37
48extern char * * environ ;
59
You can’t perform that action at this time.
0 commit comments