From 0fb7fa0dd8f0caf3b7238e3c4893dd7bcbe1dcab Mon Sep 17 00:00:00 2001 From: Yao Zi Date: Sun, 29 Jun 2025 09:06:31 +0000 Subject: [PATCH] Makefile: Respect LDFLAGS when linking shared library LDFLAGS is taken into account when linking the executable, but not the shared library, which is inconsistent and may cause issues if customized settings are passed through LDFLAGS (for example, LTO). Let's include LDFLAGS in the linking command. Fixes: b9dfb992c78e ("(1) Makefile: added a shared library target, (2) no longer compile the main function as part of libabc.a") Signed-off-by: Yao Zi --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index eeff20d24d..910e6c5084 100644 --- a/Makefile +++ b/Makefile @@ -241,7 +241,7 @@ lib$(PROG).a: $(LIBOBJ) lib$(PROG).so: $(LIBOBJ) @echo "$(MSG_PREFIX)\`\` Linking:" $(notdir $@) - $(VERBOSE)$(CXX) -shared -o $@ $^ $(LIBS) + $(VERBOSE)$(CXX) -shared -o $@ $^ $(LDFLAGS) $(LIBS) docs: @echo "$(MSG_PREFIX)\`\` Building documentation." $(notdir $@)