From 449dff997c29a247fe36000420fb0fcaf5542867 Mon Sep 17 00:00:00 2001 From: Chris-Savinovich <csavinovich@digium.com> Date: Thu, 7 Mar 2019 13:48:04 -0600 Subject: [PATCH] partial-inlining: disable partial-inlining if gcc>=8.2.1 Apply flag -fno-partial-inlining on default optimization if and only if gcc version >= 8.2.1 (this is the current ver on Fedora and Ubuntu). This is done to avoid a bug that causes arithmetic calculations to fail if the following conditions are met: 1. TEST_FRAMEWORK on 2. DONT_OPTIMIZE off 3. Fedora and Ubuntu 4. GCC 8.2.1 5. There must exist a certain combination of multithreading. 6. Optimization level -O2 and -O3 7. Flag -fpartial-inline activated (default when optimization level>=2) The following link points to a similar gcc bug reported in 2015. This leads me to believe the bug has regressed. Note I am not able to replicate this bug in an environment other than Asterisk + Test Framework + Test_cel because the multithreading combination that causes it seems to be unique. Therefore I am temporarily abandoning any thoughts of reporting the new occurrence of this bug to gcc.gnu.org. https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65307 Change-Id: Ibd1afe60e0a38b88e85fdcd9b051004601c2f102 --- Makefile.rules | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Makefile.rules b/Makefile.rules index b9799272b8..c148af4173 100644 --- a/Makefile.rules +++ b/Makefile.rules @@ -70,6 +70,12 @@ ifneq ($(findstring darwin,$(OSARCH)),) endif endif +# gcc version 8.2.1 and above must have partial-inlining disabled to avoid documented bug +GCC_VER_GTE821:=$(shell expr `gcc --version | grep ^gcc | cut -d ' ' -f 3 | sed -e 's/\.\([0-9][0-9]\)/\1/g' -e 's/\.\([0-9]\)/0\1/g' -e 's/^[0-9]\{3,4\}$$/&00/'` \>= 80201) +ifeq ($(GCC_VER_GTE821),1) + OPTIMIZE+=-fno-partial-inlining +endif + ifeq ($(findstring DONT_OPTIMIZE,$(MENUSELECT_CFLAGS))$(AST_CODE_COVERAGE),no) _ASTCFLAGS+=$(OPTIMIZE) else -- GitLab