Common objects need to be in an archive to get correctly -flto/--as-neededed

Partial revert of e78ba80bc90fdb78f4ce47d12519280fe2e5981c
This commit is contained in:
наб 2023-12-06 03:10:34 +01:00
parent a85bcbeca2
commit 8997b47acf
No known key found for this signature in database
GPG Key ID: BCFD0B018D2658F1

View File

@ -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)