From 872cf03f26c2801ae6c3008ce5fa0d7856f5f85d Mon Sep 17 00:00:00 2001 From: Kacper Date: Sun, 14 Dec 2025 18:10:13 +0100 Subject: libc: implement err/warn functions --- makefile | 38 +++++++++++++++++++++++++++----------- 1 file changed, 27 insertions(+), 11 deletions(-) (limited to 'makefile') diff --git a/makefile b/makefile index a322da35..7f039714 100644 --- a/makefile +++ b/makefile @@ -55,6 +55,10 @@ ifdef M obj = $(M)/ endif +KCONFIG_CONFIG ?= .config + +-include ${KCONFIG_CONFIG} + # CFLAGS KBUILD_CFLAGS := -x c @@ -62,6 +66,7 @@ KBUILD_CFLAGS := -x c KBUILD_CFLAGS += -Wall -Wextra KBUILD_CFLAGS += -nostdinc KBUILD_CFLAGS += -target $(ARCH)-linux-eabi +KBUILD_CFLAGS += -ffreestanding KBUILD_CFLAGS += -I$(srctree)/include KBUILD_CFLAGS += -I$(srctree)/include/arch/$(ARCH) @@ -86,28 +91,32 @@ ifeq ($(CONFIG_WERROR),y) KBUILD_CFLAGS += -Werror endif +KBUILD_LDFLAGS := +KBUILD_ASFLAGS := ifeq ($(CONFIG_DEBUG),y) KBUILD_CFLAGS += -g -Og -fno-omit-frame-pointer -endif +else +KBUILD_CFLAGS += -O2 -fdata-sections -ffunction-sections +KBUILD_CFLAGS += -fno-unwind-tables -fomit-frame-pointer -KBUILD_ASFLAGS := +KBUILD_LDFLAGS += --gc-sections +KBUILD_LDFLAGS += --build-id=none +KBUILD_LDFLAGS += --as-needed +KBUILD_LDFLAGS += --strip-all +KBUILD_LDFLAGS += -z relro -z now -z noexecstack +KBUILD_LDFLAGS += --no-undefined +KBUILD_LDFLAGS += --icf=all + +KBUILD_ASFLAGS += +endif # Assembly does not need -nostdinc; clang warns it is unused. KBUILD_ASFLAGS += -target $(ARCH)-linux-eabi KBUILD_ASFLAGS += -I$(srctree)/include KBUILD_ASFLAGS += -I$(srctree)/include/arch/$(ARCH) -# LDFLAGS -KBUILD_LDFLAGS := - -KBUILD_LDFLAGS += --gc-sections -KBUILD_LDFLAGS += --build-id=none -KBUILD_LDFLAGS += --as-needed - PHONY := -KCONFIG_CONFIG ?= .config - export Q srctree MAKEFLAGS KCONFIG_CONFIG \ KBUILD_CFLAGS KBUILD_ASFLAGS KBUILD_LDFLAGS @@ -123,6 +132,13 @@ distclean: clean $(Q)$(MAKE) -C scripts/kconfig clean $(Q)rm -f compile_commands.json +info: + echo "CC: $(CC)" + echo "ARCH: $(ARCH)" + echo "CFLAGS: $(KBUILD_CFLAGS)" + echo "LDFLAGS: $(KBUILD_LDFLAGS)" + echo "ASFLAGS: $(KBUILD_ASFLAGS)" + $(KCONFIG_CONFIG): @echo >&2 '***' @echo >&2 '*** Configuration file "$@" not found!' -- cgit v1.2.3