[Buildroot] [git commit branch/2017.02.x] toolchain/external: use -dumpversion to check gcc version

Peter Korsgaard peter at korsgaard.com
Mon Mar 13 22:58:30 UTC 2017


commit: https://git.buildroot.net/buildroot/commit/?id=47793a94b50dc1f65bd1686c7973438c26fd2ce1
branch: https://git.buildroot.net/buildroot/commit/?id=refs/heads/2017.02.x

Currently, `--version` option is used and later matched with a regex to get
the actual gcc version.  There's a dedicated gcc option to do exactly that:
`-dumpversion`.

Also `--version` may return a string customised by a vendor that provides
the toolchain, which makes the current regex approach error prone.  In
fact, this situation has been seen with a real customised toolchain.

Signed-off-by: Krzysztof Konopko <kris at youview.com>
Signed-off-by: Tomasz Szkutkowski <tomasz.szkutkowski at youview.com>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni at free-electrons.com>
(cherry picked from commit 06cd604ec6d34f25b436ab729543418042a87e1c)
Signed-off-by: Peter Korsgaard <peter at korsgaard.com>
---
 toolchain/helpers.mk | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/toolchain/helpers.mk b/toolchain/helpers.mk
index 72e7292..0ed8fdc 100644
--- a/toolchain/helpers.mk
+++ b/toolchain/helpers.mk
@@ -147,7 +147,7 @@ check_gcc_version = \
 	if [ -z "$${expected_version}" ]; then \
 		exit 0 ; \
 	fi; \
-	real_version=`$(1) --version | sed -r -e '1!d; s/^[^)]+\) ([^[:space:]]+).*/\1/;'` ; \
+	real_version=`$(1) -dumpversion` ; \
 	if [[ ! "$${real_version}" =~ ^$${expected_version}\. ]] ; then \
 		printf "Incorrect selection of gcc version: expected %s.x, got %s\n" \
 			"$${expected_version}" "$${real_version}" ; \


More information about the buildroot mailing list