net: Support no-lto option for the network build.

Add CONFIG_NET_NO_LTO to allow compiling the network stack with -fno-lto.
This is useful for avoiding LTO-related issues in the network layer.

Signed-off-by: daichuan <daichuan@xiaomi.com>
This commit is contained in:
daichuan
2024-07-30 15:03:24 +08:00
committed by Xiang Xiao
parent 32ffc69bdd
commit d19ee93c60
3 changed files with 23 additions and 0 deletions
+4
View File
@@ -27,4 +27,8 @@ if(CONFIG_NET)
target_sources(net PRIVATE net_initialize.c)
target_include_directories(net PRIVATE ${CMAKE_CURRENT_LIST_DIR})
if(CONFIG_NET_NO_LTO)
add_compile_options(-fno-lto)
endif()
endif()
+15
View File
@@ -457,4 +457,19 @@ endmenu # Network Topologies
source "net/route/Kconfig"
config NET_NO_LTO
bool "Support no-lto option for the network Makefile"
default n
---help---
This option disables Link Time Optimization (LTO) specifically for the
network subsystem.
LTO can sometimes introduce build issues, excessive compilation time,
or difficult-to-debug runtime behaviors in complex network stacks
depending on the compiler version and architecture.
Enable this option if you encounter LTO-related issues in the network
stack or need to debug network code without the aggressive optimizations
introduced by LTO, while keeping LTO enabled for the rest of the system.
endif # NET
+4
View File
@@ -70,6 +70,10 @@ COBJS = $(CSRCS:.c=$(OBJEXT))
SRCS = $(ASRCS) $(CSRCS)
OBJS = $(AOBJS) $(COBJS)
ifeq ($(CONFIG_NET_NO_LTO),y)
CFLAGS += -fno-lto
endif
BIN = libnet$(LIBEXT)
all: $(BIN)