File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -15,32 +15,32 @@ endif
1515CXX ?= g++
1616AR ?= ar
1717
18- # Base flags
19- CXXFLAGS ?= -std=c++17 -Wall -Wextra -Werror -O2
18+ # Base flags with LTO for smaller binaries
19+ CXXFLAGS ?= -std=c++17 -Wall -Wextra -Werror -O2 -flto -ffunction-sections -fdata-sections
2020INCLUDES = -I./include -I./extern/json/single_include
2121
2222# Platform-specific settings
2323ifeq ($(UNAME ) ,Darwin)
2424 # macOS
25- LDFLAGS ?=
25+ LDFLAGS ?= -flto -Wl,-dead_strip
2626 SHARED_EXT = .dylib
2727 SHARED_FLAGS = -dynamiclib
2828 STATIC_EXT = .a
2929else ifeq ($(UNAME),Linux)
3030 # Linux
31- LDFLAGS ?= -ldl
31+ LDFLAGS ?= -flto -Wl,--gc-sections - ldl
3232 SHARED_EXT = .so
3333 SHARED_FLAGS = -shared -fPIC
3434 STATIC_EXT = .a
3535else ifeq ($(UNAME),FreeBSD)
3636 # FreeBSD
37- LDFLAGS ?=
37+ LDFLAGS ?= -flto -Wl,--gc-sections
3838 SHARED_EXT = .so
3939 SHARED_FLAGS = -shared -fPIC
4040 STATIC_EXT = .a
4141else ifeq ($(UNAME),Windows)
4242 # Windows (MinGW)
43- LDFLAGS ?=
43+ LDFLAGS ?= -flto -Wl,--gc-sections
4444 SHARED_EXT = .dll
4545 SHARED_FLAGS = -shared
4646 STATIC_EXT = .a
You can’t perform that action at this time.
0 commit comments