BUILD: makefile: reference libdl only once

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.
This commit is contained in:
Willy Tarreau 2022-12-14 18:46:48 +01:00
parent 914a668077
commit 682b78b4e6
1 changed files with 5 additions and 10 deletions

View File

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