-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
libct/dmz: Support compiling on all arches
When we added nolibc, we use it unconditionally. But runc is currently being compiled on more arches than supported by nolibc, like MIPS. Let's compile using stdlib if the arch we are compiling on is not supported by nolibc. If compilation is broken in some arch, just removing it from the NOLIBC_GOARCHES variable should fix the compilation, as it will fallback to use the C stdlib. Signed-off-by: Rodrigo Campos <[email protected]>
- Loading branch information
Showing
3 changed files
with
21 additions
and
3 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,19 @@ | ||
# Get CC values for cross-compilation. | ||
# Get GO, GOARCH and CC values for cross-compilation. | ||
include ../../cc_platform.mk | ||
|
||
# We use the flags suggested in nolibc/nolibc.h, it makes the binary very small. | ||
# List of GOARCH that nolibc supports, from: | ||
# https://go.dev/doc/install/source#environment (with GOOS=linux) | ||
# | ||
# See nolibc supported arches in ./nolibc/arch-*.h | ||
NOLIBC_GOARCHES := 386 amd64 arm arm64 loong64 ppc64le riscv64 s390x | ||
|
||
ifeq ($(GOARCH), $(findstring $(GOARCH), $(NOLIBC_GOARCHES))) | ||
# We use the flags suggested in nolibc/nolibc.h, it makes the binary very small. | ||
CFLAGS += -fno-asynchronous-unwind-tables -fno-ident -s -Os -nostdlib -lgcc | ||
else | ||
CFLAGS += -DRUNC_USE_STDLIB | ||
endif | ||
|
||
runc-dmz: _dmz.c | ||
$(CC) $(CFLAGS) -fno-asynchronous-unwind-tables -fno-ident -s -Os -nostdlib -lgcc -static -o $@ $^ | ||
$(CC) $(CFLAGS) -static -o $@ $^ | ||
$(STRIP) -gs $@ |
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
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