Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trailing space interferes with regex match for GCC version #29

Open
crazybolillo opened this issue Oct 4, 2023 · 0 comments
Open

Trailing space interferes with regex match for GCC version #29

crazybolillo opened this issue Oct 4, 2023 · 0 comments

Comments

@crazybolillo
Copy link

Using Arch Linux and clang-arm-gcc-toolchain.cmake, the GCC version can't be parsed due to a trailing space on the regex.
Here is the version string generated:

arm-none-eabi-gcc (Arch Repository) 13.2.0
Copyright (C) 2023 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Running cmake generates the following error, since no version can be extracted:

CMake Error at vendor/arm-cmake/clang-arm-gcc-toolchain.cmake:20 (string):
  string sub-command STRIP requires two arguments.

Playing around, I was able to match the version and fix the issue with the following diff:

diff --git a/clang-arm-gcc-toolchain.cmake b/clang-arm-gcc-toolchain.cmake
index 627b879..afacba6 100644
--- a/clang-arm-gcc-toolchain.cmake
+++ b/clang-arm-gcc-toolchain.cmake
@@ -16,7 +16,7 @@ execute_process(COMMAND ${ARM_GCC_C_COMPILER} -print-sysroot
 # get GNU ARM GCC version
 execute_process(COMMAND ${ARM_GCC_C_COMPILER} --version
     OUTPUT_VARIABLE ARM_GCC_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE)
-string(REGEX MATCH " [0-9]+\.[0-9]+\.[0-9]+ " ARM_GCC_VERSION ${ARM_GCC_VERSION})
+string(REGEX MATCH " [0-9]+\.[0-9]+\.[0-9]+" ARM_GCC_VERSION ${ARM_GCC_VERSION})
 string(STRIP ${ARM_GCC_VERSION} ARM_GCC_VERSION)
 # set compiler triple
 set(triple ${TOOLCHAIN_TRIPLE})

Did not test it on other distributions but I wonder why the trailing spaces can't be removed altogether, it means the STRIP instruction after it would not be needed as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant