From cde4690721ad54043239db000a46537a9169ca02 Mon Sep 17 00:00:00 2001 From: Marius Hillenbrand Date: Tue, 16 Jun 2020 15:45:59 +0200 Subject: [PATCH] RFC: Use gcc -dumpfullversion to get minor version with gcc-7.x In gcc-7.1, the behavior of -dumpversion changed to be configured at compile-time. On some distributions it only dumps the major version (e.g., Ubuntu), so the current checks for the gcc minor version report false negatives. As a replacement, gcc-7.1 introduced -dumpfullversion which always prints the full version. Update the gcc version detection in Makefile.system to employ -dumpfullversion with gcc-7 and newer. Posting this patch for discussion, since it emerged from discussions around issue #2668 and PR #2669. It is not solving a problem right now, but may be useful in the future. Signed-off-by: Marius Hillenbrand --- Makefile.system | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Makefile.system b/Makefile.system index 63cdbccd8..7e0b2757e 100644 --- a/Makefile.system +++ b/Makefile.system @@ -286,8 +286,15 @@ GCCVERSIONEQ5 := $(shell expr `$(CC) -dumpversion | cut -f1 -d.` = 5) GCCVERSIONGT5 := $(shell expr `$(CC) -dumpversion | cut -f1 -d.` \> 5) GCCVERSIONGTEQ7 := $(shell expr `$(CC) -dumpversion | cut -f1 -d.` \>= 7) GCCVERSIONGTEQ9 := $(shell expr `$(CC) -dumpversion | cut -f1 -d.` \>= 9) -GCCMINORVERSIONGTEQ2 := $(shell expr `$(CC) -dumpversion | cut -f2 -d.` \>= 2) -GCCMINORVERSIONGTEQ7 := $(shell expr `$(CC) -dumpversion | cut -f2 -d.` \>= 7) +# Note that the behavior of -dumpversion is compile-time-configurable for +# gcc-7.x and newer. Use -dumpfullversion there +ifeq ($(GCCVERSIONGTEQ7),1) + GCCDUMPVERSION_PARAM := -dumpfullversion +else + GCCDUMPVERSION_PARAM := -dumpversion +endif +GCCMINORVERSIONGTEQ2 := $(shell expr `$(CC) $(GCCDUMPVERSION_PARAM) | cut -f2 -d.` \>= 2) +GCCMINORVERSIONGTEQ7 := $(shell expr `$(CC) $(GCCDUMPVERSION_PARAM) | cut -f2 -d.` \>= 7) endif #