File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -102,6 +102,19 @@ endif
102102
103103LDFLAGS ?= -L./lib/
104104
105+ # ─── Link-Time Optimization (LTO) Type Detection ───────────────────────────────
106+
107+ # Automatically select LTO type based on compiler
108+ ifeq ($(CXX ) ,clang++)
109+ LTO_FLAG := -flto=thin # Clang: thin LTO is more compatible and faster
110+ else ifeq ($(CXX ) ,clang)
111+ LTO_FLAG := -flto=thin
112+ else ifneq ($(findstring clang,$(CXX)),)
113+ LTO_FLAG := -flto=thin # Any clang-like compiler
114+ else
115+ LTO_FLAG := -flto=auto # GCC: use auto LTO for better optimization
116+ endif
117+
105118# ─── Optimization Flags ───────────────────────────────────────────────────────
106119
107120ifeq ($(BUILD_TYPE ) ,release)
@@ -110,8 +123,10 @@ ifeq ($(BUILD_TYPE),release)
110123 OPTFLAGS += -march=$(ARCH )
111124 endif
112125 ifeq ($(USE_LTO),true)
113- OPTFLAGS += -flto=auto
114- LDFLAGS += -flto=auto
126+ ifneq ($(LTO_FLAG),)
127+ OPTFLAGS += $(LTO_FLAG )
128+ LDFLAGS += $(LTO_FLAG )
129+ endif
115130 endif
116131else ifeq ($(BUILD_TYPE),debug)
117132 OPTFLAGS := $(OPT_DEBUG ) -ggdb3 -DDEBUG -D_GLIBCXX_DEBUG
Original file line number Diff line number Diff line change @@ -102,6 +102,19 @@ endif
102102
103103LDFLAGS ?= -L./lib/
104104
105+ # ─── Link-Time Optimization (LTO) Type Detection ───────────────────────────────
106+
107+ # Automatically select LTO type based on compiler
108+ ifeq ($(CXX ) ,clang++)
109+ LTO_FLAG := -flto=thin # Clang: thin LTO is more compatible and faster
110+ else ifeq ($(CXX ) ,clang)
111+ LTO_FLAG := -flto=thin
112+ else ifneq ($(findstring clang,$(CXX)),)
113+ LTO_FLAG := -flto=thin # Any clang-like compiler
114+ else
115+ LTO_FLAG := -flto=auto # GCC: use auto LTO for better optimization
116+ endif
117+
105118# ─── Optimization Flags ───────────────────────────────────────────────────────
106119
107120ifeq ($(BUILD_TYPE ) ,release)
@@ -110,8 +123,10 @@ ifeq ($(BUILD_TYPE),release)
110123 OPTFLAGS += -march=$(ARCH )
111124 endif
112125 ifeq ($(USE_LTO),true)
113- OPTFLAGS += -flto=auto
114- LDFLAGS += -flto=auto
126+ ifneq ($(LTO_FLAG),)
127+ OPTFLAGS += $(LTO_FLAG )
128+ LDFLAGS += $(LTO_FLAG )
129+ endif
115130 endif
116131else ifeq ($(BUILD_TYPE),debug)
117132 OPTFLAGS := $(OPT_DEBUG ) -ggdb3 -DDEBUG -D_GLIBCXX_DEBUG
You can’t perform that action at this time.
0 commit comments