Skip to content

Commit

Permalink
MT#61993 build: Force recursive variables into simple ones
Browse files Browse the repository at this point in the history
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
  • Loading branch information
guillemj committed Jan 27, 2025
1 parent bebc6f8 commit 887fb40
Show file tree
Hide file tree
Showing 10 changed files with 43 additions and 31 deletions.
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
9 changes: 6 additions & 3 deletions daemon/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion debian/rules
Original file line number Diff line number Diff line change
Expand Up @@ -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 $@
Expand Down
8 changes: 4 additions & 4 deletions kernel-module/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions lib/g729.Makefile
Original file line number Diff line number Diff line change
@@ -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
Expand Down
20 changes: 8 additions & 12 deletions lib/lib.Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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)
Expand Down
7 changes: 2 additions & 5 deletions lib/mqtt.Makefile
Original file line number Diff line number Diff line change
@@ -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
Expand Down
6 changes: 5 additions & 1 deletion perf-tester/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down
6 changes: 5 additions & 1 deletion recording-daemon/Makefile
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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)
Expand Down
6 changes: 5 additions & 1 deletion t/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 887fb40

Please sign in to comment.