aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2019-09-05 12:10:59 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2019-09-05 12:10:59 +0200
commit5344acce78702871fba6506a3bd0d05750d90037 (patch)
tree7760065c9911677aecee40957b8ff8b0568deb9d
parent1dc3b7357db363c51e449adf0a3779924fb13e01 (diff)
Tighten versioned shared library cleanup logic
-rw-r--r--libbuild2/cc/link-rule.cxx35
1 files changed, 23 insertions, 12 deletions
diff --git a/libbuild2/cc/link-rule.cxx b/libbuild2/cc/link-rule.cxx
index 26a9955..2eeebda 100644
--- a/libbuild2/cc/link-rule.cxx
+++ b/libbuild2/cc/link-rule.cxx
@@ -2679,29 +2679,40 @@ namespace build2
{
if (!interm)
{
- if (m.extension () == "d") // Strip .d.
- m.make_base ();
-
- // Filter out paths that match one of the current paths.
+ // Filter out paths that match one of the current paths or a
+ // prefix of the real path (the latter takes care of auxiliary
+ // things like .d, .t, etc., that are normally derived from the
+ // target name).
//
// Yes, we are basically ad hoc-excluding things that break.
// Maybe we should use something more powerful for the pattern,
// such as regex? We could have a filesystem pattern which we
// then filter against a regex pattern?
//
- if (m != *paths.real &&
- m != paths.interm &&
- m != paths.soname &&
- m != paths.load &&
+ auto prefix = [&m] (const path& p)
+ {
+ return path::traits_type::compare (m.string (),
+ p.string (),
+ p.string ().size ()) == 0;
+ };
+
+ if (!prefix (*paths.real) &&
+ m != paths.interm &&
+ m != paths.soname &&
+ m != paths.load &&
m != paths.link)
{
try_rmfile (m);
- try_rmfile (m + ".d");
- if (tsys == "win32-msvc")
+ if (m.extension () != "d")
{
- try_rmfile (m.base () += ".ilk");
- try_rmfile (m += ".pdb");
+ try_rmfile (m + ".d");
+
+ if (tsys == "win32-msvc")
+ {
+ try_rmfile (m.base () += ".ilk");
+ try_rmfile (m += ".pdb");
+ }
}
}
}