Skip to contentSkip to conversation

toolchain/helpers.mk: fixup check_gcc_version.

PATCH New Guo Ren 2 participants 3 messages Feb 21, 2017 – Mar 10, 2017

lore
Share & tools
lore

Guo Ren

author
#0 lore raw

PATCH v2 1/1 toolchain/helpers.mk: fixup check_gcc_version.

some gcc --version ouput like this:

$ csky-linux-gcc --version
csky-linux-gcc (C-SKY Tools V2.8.08(Beta1)(Glibc,Linux 4.8.4), ABIV1,
B20161118) 4.5.1

current script just find first ')', but we need find last ')' to get correct version number.

---

---
 toolchain/helpers.mk | 19 ++++++++++++++-----
 1 file changed, 14 insertions(+), 5 deletions(-)
toolchain/helpers.mk +14 -5
index 72e7292..ede9b53 100644
@@ -136,18 +136,27 @@ check_kernel_headers_version = \
 # - 1!d
 #   - delete if not line 1
 #
-# - s/^[^)]+\) ([^[:space:]]+).*/\1/
-#   - eat all until the first ')' character followed by a space
-#   - match as many non-space chars as possible
-#   - eat all the remaining chars on the line
+# - s/^.+\)[[:space:]]*([^[:space:]]+).*/\1/
+#   - eat all until the last ')' character
+#   - eat any following spaces
+#   - match the following non-space sequence
 #   - replace by the matched expression
 #
+# The GCC version string is built up as follows:
+# GCC (PKGVERSION) BASEVER DATESTAMP DEVPHASE REVISION
+# PKGVERSION can be anything, it's a string provided at configure time.
+# BASEVER is what we need.
+# DATESTAMP is YYYYMMDD or empty
+# DEVPHASE is (experimental), (pre-release) or empty
+# REVISION is [svn revision info] or empty
+# Therefore, we need the first non-space sequence after the last ')' character
+#
 check_gcc_version = \
 	expected_version="$(strip $2)" ; \
 	if [ -z "$${expected_version}" ]; then \
 		exit 0 ; \
 	fi; \
-	real_version=`$(1) --version | sed -r -e '1!d; s/^[^)]+\) ([^[:space:]]+).*/\1/;'` ; \
+	real_version=`$(1) --version | sed -r -e '1!d; s/^.+\)[[:space:]]*([^[:space:]]+).*/\1/;'` ; \
 	if [[ ! "$${real_version}" =~ ^$${expected_version}\. ]] ; then \
 		printf "Incorrect selection of gcc version: expected %s.x, got %s\n" \
 			"$${expected_version}" "$${real_version}" ; \
Signature · 1 line
1.9.1
#1 lore raw

PATCH v2 1/1 toolchain/helpers.mk: fixup check_gcc_version.

Hello,

Quoted 9 lines · Guo Ren

some gcc --version ouput like this:

$ csky-linux-gcc --version
csky-linux-gcc (C-SKY Tools V2.8.08(Beta1)(Glibc,Linux 4.8.4), ABIV1,
B20161118) 4.5.1

current script just find first ')', but we need find last ')' to get correct version number.

A different, and much simpler fix was committed in
https://git.buildroot.org/buildroot/commit/?id=06cd604ec6d34f25b436ab729543418042a87e1c.

Best regards,

Thomas

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