]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
core/buildsystem: check the actual compiler being version
authorGuido Falsi <madpilot@freebsd.org>
Sun, 7 Apr 2019 16:36:55 +0000 (18:36 +0200)
committerGeorge Joseph <gjoseph@digium.com>
Mon, 22 Apr 2019 13:04:40 +0000 (07:04 -0600)
Make compiler check use the output of the actual compiler being
used as reported by the CC variable, instead of unconditionally
running the "gcc" binary.  Also only run the check if the compiler
is gcc or a cross-compile gcc.

ASTERISK-28374

Change-Id: Icaacf6d93686ad21076878aa1504a23b4fc9d0f4

Makefile.rules

index dc23a9e6247a4775cd641c913fa411de56f520cd..c45d9d002d087c5b7d780889e397f596f36434aa 100644 (file)
@@ -67,11 +67,16 @@ 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)
+# gcc version 8.2.1 and above must have partial-inlining disabled to avoid documented bug.
+# We must handle cross-compiling and clang so make sure the compiler version string has "gcc"
+# somewhere in it before testing the version.
+CC_VERS_STRING=$(shell $(CC) --version | grep -i gcc)
+ifneq ($(CC_VERS_STRING),)
+GCC_VER_GTE821:=$(shell expr `echo '$(CC_VERS_STRING)' | 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
+endif
 
 ifeq ($(findstring DONT_OPTIMIZE,$(MENUSELECT_CFLAGS))$(AST_CODE_COVERAGE),no)
     _ASTCFLAGS+=$(OPTIMIZE)