diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2021-03-13 12:04:07 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2021-03-13 12:04:07 +0200 |
commit | 99046d23d78d341674bbad3414567f362ffc60cd (patch) | |
tree | f04f3a19c01596598f56d5e6ec8942579b4d81bb | |
parent | bf04b33fed366b93235a46279894ba9512d49804 (diff) |
Tighten Clang detection not to misdetect GCC built with Clang
GitHub issue #136.
-rw-r--r-- | libbuild2/cc/guess.cxx | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/libbuild2/cc/guess.cxx b/libbuild2/cc/guess.cxx index 1e0c77a..d80fd17 100644 --- a/libbuild2/cc/guess.cxx +++ b/libbuild2/cc/guess.cxx @@ -1016,6 +1016,8 @@ namespace build2 : guess_result ()); } + size_t p; + // The gcc -v output will have a last line in the form: // // "gcc version X.Y.Z ..." @@ -1111,7 +1113,12 @@ namespace build2 // The clang-cl output is exactly the same, which means the only way // to distinguish it is based on the executable name. // - if (l.find ("clang ") != string::npos) + // We must also watch out for potential misdetections, for example: + // + // Configured with: ../gcc/configure CC=clang CXX=clang++ ... + // + if ((p = l.find ("clang ")) != string::npos && + (p == 0 || l[p - 1] == ' ')) { if (cache.empty ()) { |