From 39a0e6fa74d70ea2dafa4bdcc317a52f238ed98b Mon Sep 17 00:00:00 2001 From: chao an Date: Sun, 18 Feb 2024 13:44:26 +0800 Subject: [PATCH] toolchain/lto: enable lto flags only on GNU toolchain Some commercial customized toolchains do not support these options Signed-off-by: chao an --- libs/libc/assert/Make.defs | 8 +++++--- mm/kasan/Make.defs | 8 ++++++-- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/libs/libc/assert/Make.defs b/libs/libc/assert/Make.defs index 87017b57c14..4b236fd02ab 100644 --- a/libs/libc/assert/Make.defs +++ b/libs/libc/assert/Make.defs @@ -24,9 +24,11 @@ ifeq ($(CONFIG_STACK_CANARIES),y) CSRCS += lib_stackchk.c endif -ifeq ($(CONFIG_LTO_NONE),n) -assert/lib_assert.c_CFLAGS += -fno-lto -assert/lib_stackchk.c_CFLAGS += -fno-lto +ifeq ($(CONFIG_ARCH_TOOLCHAIN_GNU),y) + ifeq ($(CONFIG_LTO_NONE),n) + assert/lib_assert.c_CFLAGS += -fno-lto + assert/lib_stackchk.c_CFLAGS += -fno-lto + endif endif # Add the assert directory to the build diff --git a/mm/kasan/Make.defs b/mm/kasan/Make.defs index e8e464da5a6..a629b48e3bb 100644 --- a/mm/kasan/Make.defs +++ b/mm/kasan/Make.defs @@ -24,8 +24,12 @@ CSRCS += kasan.c # Disable kernel-address in mm subsystem -CFLAGS += -fno-sanitize=kernel-address -CFLAGS += -fno-lto +ifeq ($(CONFIG_ARCH_TOOLCHAIN_GNU),y) + CFLAGS += -fno-sanitize=kernel-address + ifeq ($(CONFIG_LTO_NONE),n) + CFLAGS += -fno-lto + endif +endif # Add the core heap directory to the build