From: Willy Tarreau Date: Wed, 14 Dec 2022 17:46:48 +0000 (+0100) Subject: BUILD: makefile: reference libdl only once X-Git-Tag: v2.8-dev1~54 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=682b78b4e67ab6f216f482fea073d352a37d12ed;p=thirdparty%2Fhaproxy.git 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. --- diff --git a/Makefile b/Makefile index c464e78349..803eb1489c 100644 --- 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