From 8997b47acf4cc79cf7052fb284c0199d02a54abf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=BD=D0=B0=D0=B1?= Date: Wed, 6 Dec 2023 03:10:34 +0100 Subject: [PATCH] Common objects need to be in an archive to get correctly -flto/--as-neededed Partial revert of e78ba80bc90fdb78f4ce47d12519280fe2e5981c --- Makefile | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 74c7ea4..d910be6 100644 --- a/Makefile +++ b/Makefile @@ -60,6 +60,10 @@ endif ifneq "$(findstring clang,$(shell $(CXX) --version))" "" # GCC doesn't have this granularity CXXFLAGS += -flto=full -pedantic -Wno-gnu-statement-expression -Wno-gnu-include-next -Wno-gnu-conditional-omitted-operand -Wno-c++20-designator + ifeq "$(AR)" "ar" + # Need this because -flto=full produces objects FSF ranlib (ar s) can't index + override AR := llvm-ar + endif else CXXFLAGS += -flto endif @@ -134,8 +138,11 @@ $(OUTDIR)man/style.css : man/style.css @mkdir -p $(dir $@) cp $^ $@ +$(BLDDIR)libtzpfms.a : $(subst src/,$(BLDDIR)obj/,$(subst .cpp,.o,$(COMMON_SOURCES))) + $(AR) crs $@ $^ -$(OUTDIR)% : $(BLDDIR)obj/bin/%.o $(subst src/,$(BLDDIR)obj/,$(subst .cpp,.o,$(COMMON_SOURCES))) + +$(OUTDIR)% : $(BLDDIR)obj/bin/%.o $(BLDDIR)libtzpfms.a @mkdir -p $(dir $@) $(CXX) $(CXXFLAGS) $(LDFLAGS) -o $@ $^ $(LDLIBS)