Skip to contentSkip to conversation

toolchain/external: better check for gcc-5

PATCH New Yann E. MORIN 3 participants 3 messages Aug 9, 2015

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 toolchain/external: better check for gcc-5

gcc will always report a three-digit version sting, like 4.9.3 or 5.1.0.

For gcc before 5, we want to check the first two digits, while starting with gcc 5, we are only concerned about the first digit.

So, change our matching code to test for the leading part of the version string, up to the first dot after as-many version digit we're interested in.

Note: we're adding the dot in the .mk code rather than in the Kconfig symbol, because it seemed cleaner to do so.

---
 toolchain/helpers.mk | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)
toolchain/helpers.mk +4 -8
index 018f3ed..7c70d35 100644
@@ -191,16 +191,12 @@ check_kernel_headers_version = \
 #   - eat all the remaining chars on the line
 #   - replace by the matched expression
 #
-# - s/\.[[:digit:]]+$//
-#   - eat a dot followed by as many digits as possible up to the end
-#     of line
-#   - replace with nothing
-#
 check_gcc_version = \
 	expected_version="$(strip $2)" ; \
-	real_version=`$(1) --version | sed -r -e '1!d; s/^[^)]+\) ([^[:space:]]+).*/\1/; s/\.[[:digit:]]+$$//;'` ; \
-	if [ "$${real_version}" != "$${expected_version}" ] ; then \
-		echo "Incorrect selection of gcc version: expected $${expected_version}, got $${real_version}" ; \
+	real_version=`$(1) --version | sed -r -e '1!d; s/^[^)]+\) ([^[:space:]]+).*/\1/;'` ; \
+	if [[ ! "$${real_version}" =~ ^$${expected_version}\. ]] ; then \
+		printf "Incorrect selection of gcc version: expected %s.x, got %s\n" \
+			"$${expected_version}" "$${real_version}" ; \
 		exit 1 ; \
 	fi
 
Signature · 1 line
1.9.1
#1 lore raw

PATCH 1/1 toolchain/external: better check for gcc-5

Dear Yann E. MORIN,

Quoted 12 lines · Yann E. MORIN

gcc will always report a three-digit version sting, like 4.9.3 or 5.1.0.

For gcc before 5, we want to check the first two digits, while starting with gcc 5, we are only concerned about the first digit.

So, change our matching code to test for the leading part of the version string, up to the first dot after as-many version digit we're interested in.

Note: we're adding the dot in the .mk code rather than in the Kconfig symbol, because it seemed cleaner to do so.

Quoted 6 lines
---
 toolchain/helpers.mk | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

Applied, thanks.

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
#2 lore raw

PATCH 1/1 toolchain/external: better check for gcc-5

In reply to Yann E. MORIN

Dear Yann,

Quoted 52 lines · Yann E. MORIN

gcc will always report a three-digit version sting, like 4.9.3 or 5.1.0.

For gcc before 5, we want to check the first two digits, while starting
with gcc 5, we are only concerned about the first digit.

So, change our matching code to test for the leading part of the version
string, up to the first dot after as-many version digit we're interested
in.

Note: we're adding the dot in the .mk code rather than in the Kconfig symbol, because it seemed cleaner to do so.

---
 toolchain/helpers.mk | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)
toolchain/helpers.mk +2 -8
index 018f3ed..7c70d35 100644
@@ -191,16 +191,12 @@ check_kernel_headers_version = \
 #   - eat all the remaining chars on the line
 #   - replace by the matched expression
 #
-# - s/\.[[:digit:]]+$//
-#   - eat a dot followed by as many digits as possible up to the end
-#     of line
-#   - replace with nothing
-#
 check_gcc_version = \
 	expected_version="$(strip $2)" ; \
-	real_version=`$(1) --version | sed -r -e '1!d; s/^[^)]+\) 
 ([^[:space:]]+).*/\1/; s/\.[[:digit:]]+$$//;'` ; \
-	if [ "$${real_version}" != "$${expected_version}" ] ; then \
-		echo "Incorrect selection of gcc version: expected 
 $${expected_version}, got $${real_version}" ; \
+	real_version=`$(1) --version | sed -r -e '1!d; s/^[^)]+\) 
 ([^[:space:]]+).*/\1/;'` ; \
+	if [[ ! "$${real_version}" =~ ^$${expected_version}\. ]] ; 

then \

toolchain/helpers.mk +1 -0
+		printf "Incorrect selection of gcc version: expected 

%s.x, got %s\n" \

toolchain/helpers.mk +1 -0
+			"$${expected_version}" "$${real_version}" ; 

\

toolchain/helpers.mk check_kernel_headers_version = \ · line 201

Quoted 2 lines
toolchain/helpers.mk +0 -0
 		exit 1 ; \
 	fi

Many thanks! This works fine for my gcc 5.2.0 toolchain. Although, it is already commited and applied: