]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUILD: makefile: reference libdl only once
authorWilly Tarreau <w@1wt.eu>
Wed, 14 Dec 2022 17:46:48 +0000 (18:46 +0100)
committerWilly Tarreau <w@1wt.eu>
Fri, 23 Dec 2022 15:53:35 +0000 (16:53 +0100)
There used to be special cases where USE_DL was only for the SSL library,
then for Lua, then was used globally, but each of them kept their own copy
of -ldl. When building on a system supporting libdl, with SSL and Lua
enabled, no less than 3 -ldl are found on the linker's command line.

What matters is only that it's close to the end, so let's remove the old
specific ones and move the global one to the end. The option now uses its
own DL_LDFLAGS that is automatically collected into OPTIONS_LDFLAGS.

Makefile

index c464e78349cf2b4c8c67a90cd55b035aee58b675..803eb1489ced07216ba4cadcbb7851a237b59660 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -542,10 +542,6 @@ ifneq ($(USE_EVPORTS),)
 OPTIONS_OBJS   += src/ev_evports.o
 endif
 
-ifneq ($(USE_DL),)
-OPTIONS_LDFLAGS += -ldl
-endif
-
 ifneq ($(USE_RT),)
 OPTIONS_LDFLAGS += -lrt
 endif
@@ -572,9 +568,6 @@ ifeq ($(USE_OPENSSL_WOLFSSL),)
 OPTIONS_CFLAGS  += $(if $(SSL_INC),-I$(SSL_INC))
 OPTIONS_LDFLAGS += $(if $(SSL_LIB),-L$(SSL_LIB)) -lssl -lcrypto
 endif
-ifneq ($(USE_DL),)
-OPTIONS_LDFLAGS += -ldl
-endif
 OPTIONS_OBJS  += src/ssl_sock.o src/ssl_ckch.o src/ssl_sample.o src/ssl_crtlist.o src/cfgparse-ssl.o src/ssl_utils.o src/jwt.o src/ssl_ocsp.o
 endif
 
@@ -629,9 +622,6 @@ endif
 endif
 
 OPTIONS_LDFLAGS += $(LUA_LD_FLAGS) -l$(LUA_LIB_NAME) -lm
-ifneq ($(USE_DL),)
-OPTIONS_LDFLAGS += -ldl
-endif
 OPTIONS_OBJS    += src/hlua.o src/hlua_fcn.o
 endif
 
@@ -804,6 +794,11 @@ ifneq ($(USE_OT),)
 include addons/ot/Makefile
 endif
 
+# better keep this one close to the end, as several libs above may need it
+ifneq ($(USE_DL),)
+  DL_LDFLAGS = -ldl
+endif
+
 ifneq ($(USE_LIBATOMIC),)
   TARGET_LDFLAGS += -latomic
 endif