toolchain/external: use -dumpversion to check gcc version
authorKrzysztof Konopko <kris@youview.com>
Thu, 9 Mar 2017 08:01:36 +0000 (09:01 +0100)
committerThomas Petazzoni <thomas.petazzoni@free-electrons.com>
Thu, 9 Mar 2017 20:25:24 +0000 (21:25 +0100)
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@youview.com>
Signed-off-by: Tomasz Szkutkowski <tomasz.szkutkowski@youview.com>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
toolchain/helpers.mk

index 6f87230796fb28e31a1f319d7556b506d3e00cbd..6044b7e5f499e7591663317f8a28fe5c84151f26 100644 (file)
@@ -148,7 +148,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}" ; \