From 887fb40f3fa17bd476d4d42ec0de83752a2f006c Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Mon, 27 Jan 2025 17:29:00 +0100 Subject: [PATCH] MT#61993 build: Force recursive variables into simple ones MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Starting with GNU make 4.4, build time have massively regressed where before they would take 5m on amd64 now can take 2h40m. While this seems clearly broken, the release notes are filled with notices for breaking changes, and in particular the one for passing all make variables down to the invoked programs executed via the «shell» GNU make function, so it is not clear what is expected breakage and what is not. This has been reported in Debian, but not yet upstream, and while it seems like a clear regression, it's not clear what will be the upstream take on it. For now apply workarounds that do not change semantics, and which do not regress with older GNU make versions. Use the GNU make «origin» function instead of «?=» which defaults to defining a variable as a recursive one. Coerce already defined variables into simple ones to avoid GNU make re-evaluating these variables for each «shell» function invocation. Ref: https://bugs.debian.org/1092051 Change-Id: I076fc05dd616918473a22e7e942fecfdc9851d47 --- Makefile | 6 +++++- daemon/Makefile | 9 ++++++--- debian/rules | 2 +- kernel-module/Makefile | 8 ++++---- lib/g729.Makefile | 4 ++-- lib/lib.Makefile | 20 ++++++++------------ lib/mqtt.Makefile | 7 ++----- perf-tester/Makefile | 6 +++++- recording-daemon/Makefile | 6 +++++- t/Makefile | 6 +++++- 10 files changed, 43 insertions(+), 31 deletions(-) diff --git a/Makefile b/Makefile index 1f8e1be58..5bddebc12 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,11 @@ with_transcoding ?= yes ifeq ($(DO_ASAN_FLAGS),1) ASAN_FLAGS = -ggdb -O0 -fsanitize=address -fsanitize=leak -fsanitize=undefined -CFLAGS ?= -Wall -Wextra -Wno-sign-compare -Wno-unused-parameter -Wstrict-prototypes +ifeq ($(origin CFLAGS),undefined) +CFLAGS := -Wall -Wextra -Wno-sign-compare -Wno-unused-parameter -Wstrict-prototypes +else +CFLAGS := $(CFLAGS) +endif CFLAGS += $(ASAN_FLAGS) CFLAGS += -DASAN_BUILD LDFLAGS += $(ASAN_FLAGS) diff --git a/daemon/Makefile b/daemon/Makefile index 8599cdab5..51274b781 100644 --- a/daemon/Makefile +++ b/daemon/Makefile @@ -3,9 +3,12 @@ TARGET= rtpengine with_iptables_option ?= yes with_transcoding ?= yes - -CFLAGS?= -g -Wall -Wextra -Wno-sign-compare -Wno-unused-parameter -Wstrict-prototypes -Werror=return-type \ +ifeq ($(origin CFLAGS),undefined) +CFLAGS:= -g -Wall -Wextra -Wno-sign-compare -Wno-unused-parameter -Wstrict-prototypes -Werror=return-type \ -Wshadow +else +CFLAGS:= $(CFLAGS) +endif CFLAGS+= -pthread CFLAGS+= -std=c11 CFLAGS+= $(shell pkg-config --cflags glib-2.0) @@ -49,7 +52,7 @@ endif #CFLAGS+= -DSRTCP_KEY_DERIVATION_RFC_COMPLIANCE #CFLAGS+= -DSTRICT_SDES_KEY_LIFETIME -LDLIBS= -lm -ldl +LDLIBS:= -lm -ldl LDLIBS+= $(shell pkg-config --libs glib-2.0) LDLIBS+= $(shell pkg-config --libs gthread-2.0) LDLIBS+= $(shell pkg-config --libs zlib) diff --git a/debian/rules b/debian/rules index 861816ee8..4792edbe2 100755 --- a/debian/rules +++ b/debian/rules @@ -21,7 +21,7 @@ endif export FIXTURES_PATH = /usr/share/rtpengine-perftest -export deb_systemdsystemunitdir = $(shell pkg-config --variable=systemdsystemunitdir systemd) +export deb_systemdsystemunitdir := $(shell pkg-config --variable=systemdsystemunitdir systemd) %: dh $@ diff --git a/kernel-module/Makefile b/kernel-module/Makefile index a4bf76100..70d0a5599 100644 --- a/kernel-module/Makefile +++ b/kernel-module/Makefile @@ -4,12 +4,12 @@ KBUILD := $(KSRC) M ?= $(PWD) ifeq ($(RTPENGINE_VERSION),) - DPKG_PRSCHNGLG= $(shell which dpkg-parsechangelog 2>/dev/null) - DEB_CHANGELOG=$(shell test -f $(M)/../debian/changelog && echo $(M)/../debian/changelog || echo $(M)/debian/changelog) + DPKG_PRSCHNGLG := $(shell which dpkg-parsechangelog 2>/dev/null) + DEB_CHANGELOG := $(shell test -f $(M)/../debian/changelog && echo $(M)/../debian/changelog || echo $(M)/debian/changelog) ifneq ($(DPKG_PRSCHNGLG),) - DPKG_PRSCHNGLG=$(shell dpkg-parsechangelog -l$(DEB_CHANGELOG) | awk '/^Version: / {print $$2}') + DPKG_PRSCHNGLG := $(shell dpkg-parsechangelog -l$(DEB_CHANGELOG) | awk '/^Version: / {print $$2}') endif - GIT_BR_COMMIT=git-$(shell cd $(M) && git rev-parse --abbrev-ref --symbolic-full-name HEAD 2> /dev/null)-$(shell cd $(M) && git rev-parse --short HEAD 2> /dev/null) + GIT_BR_COMMIT := git-$(shell cd $(M) && git rev-parse --abbrev-ref --symbolic-full-name HEAD 2> /dev/null)-$(shell cd $(M) && git rev-parse --short HEAD 2> /dev/null) ifneq ($(DPKG_PRSCHNGLG),) RTPENGINE_VERSION+=$(DPKG_PRSCHNGLG) diff --git a/lib/g729.Makefile b/lib/g729.Makefile index 20f4ea613..abeef264a 100644 --- a/lib/g729.Makefile +++ b/lib/g729.Makefile @@ -1,8 +1,8 @@ ifeq (,$(filter pkg.ngcp-rtpengine.nobcg729,${DEB_BUILD_PROFILES})) # look for bcg729 # system pkg-config -ifeq ($(shell pkg-config --exists libbcg729 && echo yes),yes) -have_bcg729 := yes +have_bcg729 := $(shell pkg-config --exists libbcg729 && echo yes) +ifeq ($(have_bcg729),yes) bcg729_inc := $(shell pkg-config --cflags libbcg729) bcg729_lib := $(shell pkg-config --libs libbcg729) else diff --git a/lib/lib.Makefile b/lib/lib.Makefile index 568d14a41..8bc92e4f6 100644 --- a/lib/lib.Makefile +++ b/lib/lib.Makefile @@ -5,22 +5,22 @@ ifeq ($(RTPENGINE_ROOT_DIR),) RTPENGINE_ROOT_DIR=.. endif -HAVE_DPKG_PARSECHANGELOG?=$(shell which dpkg-parsechangelog 2>/dev/null) +HAVE_DPKG_PARSECHANGELOG := $(shell which dpkg-parsechangelog 2>/dev/null) ifeq ($(RELEASE_DATE),) ifneq ($(HAVE_DPKG_PARSECHANGELOG),) - RELEASE_DATE=$(shell date -u -d "@$$(dpkg-parsechangelog -l$(RTPENGINE_ROOT_DIR)/debian/changelog -STimestamp)" '+%F') + RELEASE_DATE := $(shell date -u -d "@$$(dpkg-parsechangelog -l$(RTPENGINE_ROOT_DIR)/debian/changelog -STimestamp)" '+%F') endif ifeq ($(RELEASE_DATE),) - RELEASE_DATE=undefined + RELEASE_DATE := undefined endif endif ifeq ($(RTPENGINE_VERSION),) ifneq ($(HAVE_DPKG_PARSECHANGELOG),) - DPKG_PRSCHNGLG=$(shell dpkg-parsechangelog -l$(RTPENGINE_ROOT_DIR)/debian/changelog | awk '/^Version: / {print $$2}') + DPKG_PRSCHNGLG := $(shell dpkg-parsechangelog -l$(RTPENGINE_ROOT_DIR)/debian/changelog | awk '/^Version: / {print $$2}') endif - GIT_BR_COMMIT=git-$(shell git rev-parse --abbrev-ref --symbolic-full-name HEAD 2> /dev/null)-$(shell git rev-parse --short HEAD 2> /dev/null) + GIT_BR_COMMIT := git-$(shell git rev-parse --abbrev-ref --symbolic-full-name HEAD 2> /dev/null)-$(shell git rev-parse --short HEAD 2> /dev/null) ifneq ($(DPKG_PRSCHNGLG),) RTPENGINE_VERSION+=$(DPKG_PRSCHNGLG) @@ -36,9 +36,7 @@ endif CFLAGS+= -DRTPENGINE_VERSION="\"$(RTPENGINE_VERSION)\"" # look for libsystemd -ifeq ($(shell pkg-config --exists libsystemd && echo yes),yes) -have_libsystemd := yes -endif +have_libsystemd := $(shell pkg-config --exists libsystemd && echo yes) ifeq ($(have_libsystemd),yes) CFLAGS+= $(shell pkg-config --cflags libsystemd) CFLAGS+= -DHAVE_LIBSYSTEMD @@ -47,9 +45,7 @@ endif # look for liburing ifeq (,$(filter pkg.ngcp-rtpengine.nouring,${DEB_BUILD_PROFILES})) -ifeq ($(shell pkg-config --atleast-version=2.3 liburing && echo yes),yes) -have_liburing := yes -endif +have_liburing := $(shell pkg-config --atleast-version=2.3 liburing && echo yes) ifeq ($(have_liburing),yes) CFLAGS+= $(shell pkg-config --cflags liburing) CFLAGS+= -DHAVE_LIBURING @@ -66,7 +62,7 @@ LDFLAGS += -rdynamic ifneq ($(DBG),yes) ifeq (,$(filter $(CFLAGS),-O0)) - DPKG_BLDFLGS= $(shell which dpkg-buildflags 2>/dev/null) + DPKG_BLDFLGS := $(shell which dpkg-buildflags 2>/dev/null) ifneq ($(DPKG_BLDFLGS),) # support http://wiki.debian.org/Hardening for >=wheezy CFLAGS+= $(shell dpkg-buildflags --get CFLAGS) diff --git a/lib/mqtt.Makefile b/lib/mqtt.Makefile index 552007de1..37d687442 100644 --- a/lib/mqtt.Makefile +++ b/lib/mqtt.Makefile @@ -1,10 +1,7 @@ -ifeq ($(shell pkg-config --exists libmosquitto && echo yes),yes) -have_mqtt := yes +have_mqtt := $(shell pkg-config --exists libmosquitto && echo yes) +ifeq ($(have_mqtt),yes) mqtt_inc := $(shell pkg-config --cflags libmosquitto) mqtt_lib := $(shell pkg-config --libs libmosquitto) -endif - -ifeq ($(have_mqtt),yes) CFLAGS+= -DHAVE_MQTT CFLAGS+= $(mqtt_inc) endif diff --git a/perf-tester/Makefile b/perf-tester/Makefile index 387edbd12..fa7a50c7c 100644 --- a/perf-tester/Makefile +++ b/perf-tester/Makefile @@ -2,8 +2,12 @@ TARGET = rtpengine-perftest FIXTURES_PATH ?= ../fixtures +ifeq ($(origin CFLAGS),undefined) CFLAGS ?= -g -Wall -Wextra -Wno-sign-compare -Wno-unused-parameter -Wstrict-prototypes -Werror=return-type \ -Wshadow +else +CFLAGS := $(CFLAGS) +endif CFLAGS += -pthread CFLAGS += -std=c11 @@ -25,7 +29,7 @@ CFLAGS += $(shell pkg-config --cflags ncursesw) CFLAGS += -DWITH_TRANSCODING CFLAGS += $(shell pkg-config --cflags openssl) -LDLIBS = -lm -ldl +LDLIBS := -lm -ldl LDLIBS += $(shell pkg-config --libs glib-2.0) LDLIBS += $(shell pkg-config --libs json-glib-1.0) LDLIBS += $(shell pkg-config --libs gthread-2.0) diff --git a/recording-daemon/Makefile b/recording-daemon/Makefile index 22fa86c52..8fe8f75e4 100644 --- a/recording-daemon/Makefile +++ b/recording-daemon/Makefile @@ -1,7 +1,11 @@ TARGET= rtpengine-recording +ifeq ($(origin CFLAGS),undefined) CFLAGS?= -g -Wall -Wextra -Wno-sign-compare -Wno-unused-parameter -Wstrict-prototypes -Werror=return-type \ -Wshadow +else +CFLAGS:= $(CFLAGS) +endif CFLAGS+= -pthread -I. -I../lib/ -I../kernel-module/ CFLAGS+= -std=c11 CFLAGS+= -D_GNU_SOURCE -D_POSIX_SOURCE -D_POSIX_C_SOURCE @@ -19,7 +23,7 @@ CFLAGS+= $(shell mysql_config --cflags) CFLAGS+= $(shell pkg-config --cflags openssl) CFLAGS+= $(shell pkg-config --cflags libcurl) -LDLIBS= -lm -ldl +LDLIBS:= -lm -ldl LDLIBS+= $(shell pkg-config --libs glib-2.0) LDLIBS+= $(shell pkg-config --libs json-glib-1.0) LDLIBS+= $(shell pkg-config --libs gthread-2.0) diff --git a/t/Makefile b/t/Makefile index 862c08548..cc0315ea0 100644 --- a/t/Makefile +++ b/t/Makefile @@ -2,8 +2,12 @@ TARGET= all-tests with_transcoding ?= yes +ifeq ($(origin CFLAGS),undefined) CFLAGS?= -g -Wall -Wextra -Wno-sign-compare -Wno-unused-parameter -Wstrict-prototypes -Werror=return-type \ -Wshadow +else +CFLAGS:= $(CFLAGS) +endif PRELOAD_CFLAGS := $(CFLAGS) CFLAGS+= -pthread CFLAGS+= -std=c11 @@ -38,7 +42,7 @@ else CFLAGS+= -DWITHOUT_CODECLIB endif -LDLIBS= -lm -ldl +LDLIBS:= -lm -ldl LDLIBS+= $(shell pkg-config --libs glib-2.0) LDLIBS+= $(shell pkg-config --libs gthread-2.0) LDLIBS+= $(shell pkg-config --libs libcrypto)