aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2018-10-19 09:44:59 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2018-10-19 09:44:59 +0200
commit9f9a7c8b7ab245fd20706ff9f6e834899b86b4e6 (patch)
treeeeac1777f43770f3fd4074c5c9807ac2c8d493b9
parentd7ebc7cf20ed05c4a7e437b407e75f0dbd747c9c (diff)
Fix bug in binutils pattern derivation logic
-rw-r--r--build2/cc/guess.cxx22
1 files changed, 15 insertions, 7 deletions
diff --git a/build2/cc/guess.cxx b/build2/cc/guess.cxx
index 0a60ffd..e9f85e3 100644
--- a/build2/cc/guess.cxx
+++ b/build2/cc/guess.cxx
@@ -1551,16 +1551,24 @@ namespace build2
// still want to try the target in case we could not pre-guess (think
// x86_64-w64-mingw32-c++).
//
- // BTW, for GCC we also get gcc-{ar,ranlib} which add support for the
- // LTO plugin though it seems more recent GNU binutils (2.25) are able
- // to load the plugin when needed automatically. So it doesn't seem we
- // should bother trying to support this on our end (one way we could do
- // it is by passing config.bin.{ar,ranlib} as hints). Actually, it seems
- // there are cases with just -gcc-ar and no -ar.
+ // BTW, for GCC we also get gcc-{ar,ranlib} (but not -ld) which add
+ // support for the LTO plugin though it seems more recent GNU binutils
+ // (2.25) are able to load the plugin when needed automatically. So it
+ // doesn't seem we should bother trying to support this on our end (one
+ // way we could do it is by passing config.bin.{ar,ranlib} as hints).
+ //
+ // It's also normal for native (i.e., non-cross-compiler) builds of GCC
+ // and Clang to not have binutils installed in the same directory and
+ // instead relying on the system ones. In this case, if the compiler is
+ // specified with the absolute path, the pattern will be the fallback
+ // search directory (though it feels like it should be checked first
+ // rather than last).
//
if (r.bin_pattern.empty ())
{
- if (pre.second != 0 && pre.second != string::npos)
+ if (pre.second != 0 &&
+ pre.second != string::npos &&
+ !path::traits::is_separator (xc.string ()[pre.second - 1]))
{
r.bin_pattern.assign (xc.string (), 0, pre.second);
r.bin_pattern += '*'; // '-' or similar is already there.