aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2018-02-22 18:43:55 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2018-02-22 18:43:55 +0200
commit272e053941c75349144d4b8b18dfea2f3cb02e9f (patch)
tree2095bff65a214b90459e52fb2b9fcb86305f65bb
parent5ab4bc13f618b75937dce33d497e370b212561c2 (diff)
Fortify GNU binutils detection against vendor customizations
-rw-r--r--build2/bin/guess.cxx27
1 files changed, 16 insertions, 11 deletions
diff --git a/build2/bin/guess.cxx b/build2/bin/guess.cxx
index 795477e..fc40605 100644
--- a/build2/bin/guess.cxx
+++ b/build2/bin/guess.cxx
@@ -48,10 +48,12 @@ namespace build2
{
auto f = [] (string& l) -> guess_result
{
- // Binutils ar --version output has a line that starts with
- // "GNU ar ".
+ // Binutils ar --version output has a line that starts with "GNU ar"
+ // and/or contains "GNU Binutils" (some embedded toolchain makers
+ // customize this stuff in all kinds of ways). So let's just look
+ // for "GNU ".
//
- if (l.compare (0, 7, "GNU ar ") == 0)
+ if (l.find ("GNU ") != string::npos)
return guess_result ("gnu", move (l));
// LLVM ar --version output has a line that starts with
@@ -122,9 +124,10 @@ namespace build2
{
auto f = [] (string& l) -> guess_result
{
- // "GNU ranlib ".
+ // The same story as with ar: normally starts with "GNU ranlib "
+ // but can vary.
//
- if (l.compare (0, 11, "GNU ranlib ") == 0)
+ if (l.find ("GNU ") != string::npos)
return guess_result ("gnu", move (l));
// "LLVM version ".
@@ -208,14 +211,16 @@ namespace build2
return guess_result ("msvc", move (l));
// Binutils ld.bfd --version output has a line that starts with
- // "GNU ld " while ld.gold -- "GNU gold".
+ // "GNU ld " while ld.gold -- "GNU gold". Again, fortify it against
+ // embedded toolchain customizations by search for "GNU " in the
+ // former case.
//
- if (l.compare (0, 7, "GNU ld ") == 0)
- return guess_result ("gnu", move (l));
-
if (l.compare (0, 9, "GNU gold ") == 0)
return guess_result ("gold", move (l));
+ if (l.find ("GNU ") != string::npos)
+ return guess_result ("gnu", move (l));
+
return guess_result ();
};
@@ -310,9 +315,9 @@ namespace build2
auto f = [] (string& l) -> guess_result
{
// Binutils windres --version output has a line that starts with
- // "GNU windres ".
+ // "GNU windres " but search for "GNU ", similar to other tools.
//
- if (l.compare (0, 12, "GNU windres ") == 0)
+ if (l.find ("GNU ") != string::npos)
return guess_result ("gnu", move (l));
return guess_result ();